diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index dcdabaf3a72d..5c6e7e20ccd1 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -1190,7 +1190,7 @@ object RefChecks { } } .exists - if !target.typeSymbol.denot.isAliasType && !target.typeSymbol.denot.isOpaqueAlias && hidden + if !target.typeSymbol.isOpaqueAlias && hidden then report.warning(ExtensionNullifiedByMember(sym, target.typeSymbol), sym.srcPos) end checkExtensionMethods diff --git a/tests/pos/ext-override.scala b/tests/warn/ext-override.scala similarity index 100% rename from tests/pos/ext-override.scala rename to tests/warn/ext-override.scala diff --git a/tests/warn/i16743.check b/tests/warn/i16743.check index 6fa1f2c83357..9fdf80e71f2b 100644 --- a/tests/warn/i16743.check +++ b/tests/warn/i16743.check @@ -1,3 +1,10 @@ +-- [E194] Potential Issue Warning: tests/warn/i16743.scala:90:8 -------------------------------------------------------- +90 | def length() = 42 // warn This extension method will be shadowed by .length() on String. + | ^ + | Extension method length will never be selected from type String + | because String already has a member with the same name and compatible parameter types. + | + | longer explanation available when compiling with `-explain` -- [E194] Potential Issue Warning: tests/warn/i16743.scala:30:6 -------------------------------------------------------- 30 | def t = 27 // warn | ^ diff --git a/tests/warn/i16743.scala b/tests/warn/i16743.scala index 4c9c99cf30d0..e8860aeabaae 100644 --- a/tests/warn/i16743.scala +++ b/tests/warn/i16743.scala @@ -87,7 +87,7 @@ class Depends: object Depending: extension (using depends: Depends)(x: depends.Thing) def y = 42 - def length() = 42 // nowarn see Quote above + def length() = 42 // warn This extension method will be shadowed by .length() on String. def f(using d: Depends) = d.thing.y def g(using d: Depends) = d.thing.length() diff --git a/tests/warn/i22233.scala b/tests/warn/i22233.scala new file mode 100644 index 000000000000..08caea1c25fb --- /dev/null +++ b/tests/warn/i22233.scala @@ -0,0 +1 @@ +extension (s: String) def length = 42 // warn