Skip to content

Commit 08bb0bb

Browse files
authored
Merge pull request #10913 from dotty-staging/fix-#10495
Take expected and excluded flags into account when checking for ambig…
2 parents d8a6056 + c5fb986 commit 08bb0bb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,11 @@ class Typer extends Namer
334334
checkNoOuterDefs(denot, outer, prevCtx)
335335
else if !owner.is(Package) then
336336
val scope = if owner.isClass then owner.info.decls else outer.scope
337-
if scope.lookup(name).exists then
338-
val symsMatch = scope.lookupAll(name).exists(denot.containsSym)
337+
val competing = scope.denotsNamed(name).filterWithFlags(required, excluded)
338+
if competing.exists then
339+
val symsMatch = competing
340+
.filterWithPredicate(sd => denot.containsSym(sd.symbol))
341+
.exists
339342
if !symsMatch && !suppressErrors then
340343
report.errorOrMigrationWarning(
341344
AmbiguousReference(name, Definition, Inheritance, prevCtx)(using outer),

tests/pos/i10495.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Foo:
2+
extension(x: String) def run: Unit = ???
3+
4+
object Bar extends Foo:
5+
def run(v: Int): Unit = ???
6+
7+
"ABC".run // Failed before: Reference to run is ambiguous...

0 commit comments

Comments
 (0)