Skip to content

Commit 2c357e0

Browse files
committed
Fix bug where ambiguous references were not reported
There was a mssing condition which meant Tyepr thought it was at the outermost scope where but was mistaken. Fixes #1145
1 parent 9e577f7 commit 2c357e0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
235235
}
236236
}
237237
val curImport = ctx.importInfo
238-
if (curImport != null && curImport.isRootImport && previous.exists) return previous
238+
if (ctx.owner.is(Package) && curImport != null && curImport.isRootImport && previous.exists)
239+
return previous // no more conflicts possible in this case
239240
// would import of kind `prec` be not shadowed by a nested higher-precedence definition?
240241
def isPossibleImport(prec: Int) =
241242
prevPrec < prec || prevPrec == prec && (prevCtx.scope eq ctx.scope)

tests/neg/i1145.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object A {
2+
def x = 3
3+
4+
def y = {
5+
import B._
6+
x // error: ambiguous
7+
}
8+
}
9+
object B {
10+
def x = 3
11+
}

0 commit comments

Comments
 (0)