summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala6
-rw-r--r--test/files/pos/t8403.scala9
2 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 133e80788b..994a2a4f4f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -433,8 +433,10 @@ trait Contexts { self: Analyzer =>
case _ => false
}
val isImport = tree match {
- case _: Import => true
- case _ => false
+ // The guard is for SI-8403. It prevents adding imports again in the context created by
+ // `Namer#createInnerNamer`
+ case _: Import if tree != this.tree => true
+ case _ => false
}
val sameOwner = owner == this.owner
val prefixInChild =
diff --git a/test/files/pos/t8403.scala b/test/files/pos/t8403.scala
new file mode 100644
index 0000000000..eea60ed7ff
--- /dev/null
+++ b/test/files/pos/t8403.scala
@@ -0,0 +1,9 @@
+trait Bug {
+ val u: { type Amb } = ???
+ import u._
+
+ class Amb { def x = 0 }
+ class C(x: Amb) { // after dbd8457e4, "reference to Amb is ambiguous"
+ x.x
+ }
+}