Skip to content

Commit 305a9f0

Browse files
committed
Merge pull request #1163 from dotty-staging/fix-#1145
Fix bug where ambiguous references were not reported
2 parents ff87310 + 8c99865 commit 305a9f0

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
@@ -232,7 +232,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
232232
}
233233
}
234234
val curImport = ctx.importInfo
235-
if (curImport != null && curImport.isRootImport && previous.exists) return previous
235+
if (ctx.owner.is(Package) && curImport != null && curImport.isRootImport && previous.exists)
236+
return previous // no more conflicts possible in this case
236237
// would import of kind `prec` be not shadowed by a nested higher-precedence definition?
237238
def isPossibleImport(prec: Int) =
238239
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)