File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -376,6 +376,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
376
376
case denot => ! denot.hasAltWith(isCurrent)
377
377
378
378
def checkNoOuterDefs (denot : Denotation , last : Context , prevCtx : Context ): Unit =
379
+ def sameTermOrType (d1 : SingleDenotation , d2 : Denotation ) =
380
+ d2.containsSym(d1.symbol) || d2.hasUniqueSym && {
381
+ val sym1 = d1.symbol
382
+ val sym2 = d2.symbol
383
+ if sym1.isTerm then
384
+ sym1.isStableMember &&
385
+ sym2.isStableMember &&
386
+ sym1.owner.thisType.select(name, sym1) =:= sym2.owner.thisType.select(name, sym2)
387
+ else
388
+ (sym1.isAliasType || sym2.isAliasType) && d1.info =:= d2.info
389
+ }
379
390
val outer = last.outer
380
391
val owner = outer.owner
381
392
if (owner eq last.owner) && (outer.scope eq last.scope) then
@@ -385,7 +396,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
385
396
val competing = scope.denotsNamed(name).filterWithFlags(required, excluded)
386
397
if competing.exists then
387
398
val symsMatch = competing
388
- .filterWithPredicate(sd => denot.containsSym (sd.symbol ))
399
+ .filterWithPredicate(sd => sameTermOrType (sd, denot ))
389
400
.exists
390
401
if ! symsMatch && ! suppressErrors then
391
402
report.errorOrMigrationWarning(
Original file line number Diff line number Diff line change
1
+ object t1 :
2
+ class C
3
+ class A :
4
+ val c : B .c.type = B .c
5
+ object B :
6
+ val c = new C
7
+ val a = new A :
8
+ def m = c // not ambiguous, `this.c` and `B.c` are compatible paths
9
+
10
+ object t2 :
11
+ class C [T ]:
12
+ type TT = T
13
+ object O :
14
+ type TT = String
15
+ class D extends C [TT ]:
16
+ def n (x : TT ) = x // `TT` is not ambiguous, `this.TT` and `O.TT` are aliases
You can’t perform that action at this time.
0 commit comments