Skip to content

Commit

Permalink
Check only existing conflicting def with source
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt authored and lrytz committed May 9, 2023
1 parent 830230f commit c6d4c47
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
val found =
if owner.is(Package) then
owner.denot.asClass.membersNamed(name)
.filterWithPredicate(d => !d.symbol.is(Package) && d.symbol.source == denot.symbol.source)
.filterWithPredicate(d => !d.symbol.is(Package)
&& denot.symbol.source.exists
&& d.symbol.source == denot.symbol.source)
else
val scope = if owner.isClass then owner.info.decls else outer.scope
scope.denotsNamed(name)
Expand Down Expand Up @@ -479,7 +481,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
result = checkNewOrShadowed(found, Definition) // no need to go further out, we found highest prec entry
found match
case found: NamedType
if curOwner.isClass && isInherited(found.denot) && !ctx.compilationUnit.isJava =>
if curOwner.isClass && found.denot.exists && isInherited(found.denot) && !ctx.compilationUnit.isJava =>
checkNoOuterDefs(found.denot, ctx, ctx)
case _ =>
else
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/17433/A_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package p

object Value
5 changes: 5 additions & 0 deletions tests/pos/17433/B_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package p

object B extends Enumeration {
val A = Value
}

0 comments on commit c6d4c47

Please sign in to comment.