summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-02-04 21:48:37 +0100
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-02-10 11:00:07 -0800
commit127a7679c105ed1ff18350978d3ddf81a5dd07fa (patch)
tree45a063adb3a38de4371cc9e60abbfdeb4a58456b
parent4a8edc03653cb0f6b6ed1cdea1779a19df20f8f5 (diff)
downloadscala-127a7679c105ed1ff18350978d3ddf81a5dd07fa.tar.gz
scala-127a7679c105ed1ff18350978d3ddf81a5dd07fa.tar.bz2
scala-127a7679c105ed1ff18350978d3ddf81a5dd07fa.zip
SI-8129 Crack the case of the curiously incoherent Context
- Typer is created with Context. - Typer creates an Inferencer with said Context. - Typer mutates Typer#context after each import statement - Typer mutates its current Context (e.g to disable implicits.) - Typer asks a question of Inferencer - Inferencer, looking at the old context, thinks that implicits are allowed - Inferencer saves implicit ambiguities into the wrong Context. Because of this bug, overload resolution in blocks or template bodies for applications that follow an import have been considering implicit coercions in the first try at static overload resolution, and, in the rare case that it encounters an ambigous implicit in the process, leaking an unpositioned ambiguout error. This commit ensures coherency between `typer.context` and `typer.infer.context` by making the latter delegate to the former.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala3
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala3
-rw-r--r--test/files/pos/t8219b.scala (renamed from test/pending/pos/t8219.scala)0
3 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 997fd6fc65..2d6c94349b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -174,7 +174,8 @@ trait Infer extends Checkable {
private lazy val stdErrorValue = stdErrorClass.newErrorValue(nme.ERROR)
/** The context-dependent inferencer part */
- class Inferencer(context: Context) extends InferencerContextErrors with InferCheckable {
+ abstract class Inferencer extends InferencerContextErrors with InferCheckable {
+ def context: Context
import InferErrorGen._
/* -- Error Messages --------------------------------------------------- */
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index edec831594..088aa5216a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -109,7 +109,8 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
private val transformed: mutable.Map[Tree, Tree] = unit.transformed
- val infer = new Inferencer(context0) {
+ val infer = new Inferencer {
+ def context = Typer.this.context
// See SI-3281 re undoLog
override def isCoercible(tp: Type, pt: Type) = undoLog undo viewExists(tp, pt)
}
diff --git a/test/pending/pos/t8219.scala b/test/files/pos/t8219b.scala
index d55d3139e1..d55d3139e1 100644
--- a/test/pending/pos/t8219.scala
+++ b/test/files/pos/t8219b.scala