Skip to content

Commit c6d4c47

Browse files
som-snyttlrytz
authored andcommitted
Check only existing conflicting def with source
1 parent 830230f commit c6d4c47

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
438438
val found =
439439
if owner.is(Package) then
440440
owner.denot.asClass.membersNamed(name)
441-
.filterWithPredicate(d => !d.symbol.is(Package) && d.symbol.source == denot.symbol.source)
441+
.filterWithPredicate(d => !d.symbol.is(Package)
442+
&& denot.symbol.source.exists
443+
&& d.symbol.source == denot.symbol.source)
442444
else
443445
val scope = if owner.isClass then owner.info.decls else outer.scope
444446
scope.denotsNamed(name)
@@ -479,7 +481,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
479481
result = checkNewOrShadowed(found, Definition) // no need to go further out, we found highest prec entry
480482
found match
481483
case found: NamedType
482-
if curOwner.isClass && isInherited(found.denot) && !ctx.compilationUnit.isJava =>
484+
if curOwner.isClass && found.denot.exists && isInherited(found.denot) && !ctx.compilationUnit.isJava =>
483485
checkNoOuterDefs(found.denot, ctx, ctx)
484486
case _ =>
485487
else

tests/pos/17433/A_1.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package p
2+
3+
object Value

tests/pos/17433/B_2.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package p
2+
3+
object B extends Enumeration {
4+
val A = Value
5+
}

0 commit comments

Comments
 (0)