diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-03-14 09:38:11 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-03-14 09:38:11 -0700 |
commit | efc0905f6b7a78bf3b454fbd9adb50aab5ffe20d (patch) | |
tree | 5361954d9341627aee453e00f504e622ed23f24b | |
parent | 8d7f73316570a4325111da3b4c0529793ced8b97 (diff) | |
parent | 0226345811636d05d67bbd574829df1515dff136 (diff) | |
download | scala-efc0905f6b7a78bf3b454fbd9adb50aab5ffe20d.tar.gz scala-efc0905f6b7a78bf3b454fbd9adb50aab5ffe20d.tar.bz2 scala-efc0905f6b7a78bf3b454fbd9adb50aab5ffe20d.zip |
Merge pull request #3625 from retronym/ticket/8403
SI-8403 Fix regression in name binding with imports in templates
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 6 | ||||
-rw-r--r-- | test/files/pos/t8403.scala | 9 |
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 + } +} |