File tree 3 files changed +22
-3
lines changed
compiler/src/dotty/tools/dotc/typer
3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -439,8 +439,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
439
439
if owner.is(Package ) then
440
440
owner.denot.asClass.membersNamed(name)
441
441
.filterWithPredicate(d => ! d.symbol.is(Package )
442
- && denot.symbol.source.exists
443
- && d.symbol.source == denot.symbol.source)
442
+ && denot.alternatives.exists(alt => alt.symbol.source.exists && alt.symbol.source == d.symbol.source))
444
443
else
445
444
val scope = if owner.isClass then owner.info.decls else outer.scope
446
445
scope.denotsNamed(name)
@@ -481,7 +480,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
481
480
result = checkNewOrShadowed(found, Definition ) // no need to go further out, we found highest prec entry
482
481
found match
483
482
case found : NamedType
484
- if curOwner.isClass && found.denot.exists && isInherited(found.denot) && ! ctx.compilationUnit.isJava =>
483
+ if curOwner.isClass && isInherited(found.denot) && ! ctx.compilationUnit.isJava =>
485
484
checkNoOuterDefs(found.denot, ctx, ctx)
486
485
case _ =>
487
486
else
Original file line number Diff line number Diff line change
1
+ -- [E049] Reference Error: tests/neg/i17433.scala:9:10 -----------------------------------------------------------------
2
+ 9 | def g = f(42) // error
3
+ | ^
4
+ | Reference to f is ambiguous.
5
+ | It is both defined in package <empty>
6
+ | and inherited subsequently in class D
7
+ |
8
+ | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change
1
+
2
+ class C :
3
+ def f (i : Int ) = i + 1
4
+ def f (s : String ) = s + " _1"
5
+
6
+ def f = 42
7
+
8
+ class D extends C :
9
+ def g = f(42 ) // error
10
+
11
+ @ main def test () = println :
12
+ D ().g
You can’t perform that action at this time.
0 commit comments