diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-18 01:08:33 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-20 12:10:46 +0200 |
commit | 440d28d027f2a1910ec6c4c09ad02602b67c7ea9 (patch) | |
tree | 95651abb4a895636fb68d68507ff11641218119d /src | |
parent | 66603a2c003852d39faec20a9763fb0e25049cf4 (diff) | |
download | scala-440d28d027f2a1910ec6c4c09ad02602b67c7ea9.tar.gz scala-440d28d027f2a1910ec6c4c09ad02602b67c7ea9.tar.bz2 scala-440d28d027f2a1910ec6c4c09ad02602b67c7ea9.zip |
SI-5943 toolboxes now autoimport Predef and scala
Previously tb.typeCheck used default typer, which builds upon NoContext.
Changing the context to analyzer.rootContext(NoCompilationUnit, EmptyTree)
fixed the missing imports problem.
Unfortunately this doesn't help in cases like "math.sqrt(4.0)" because of
https://issues.scala-lang.org/browse/SI-6393. But anyways I'm adding
this test case to pending.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/reflect/reify/package.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/reflect/ToolBoxFactory.scala | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala index a76f147dc4..a7ff51a4f1 100644 --- a/src/compiler/scala/reflect/reify/package.scala +++ b/src/compiler/scala/reflect/reify/package.scala @@ -73,7 +73,7 @@ package object reify { def reifyEnclosingRuntimeClass(global: Global)(typer0: global.analyzer.Typer): global.Tree = { import global._ import definitions._ - def isThisInScope = typer0.context.enclosingContextChain exists (_.tree.isInstanceOf[Template]) + def isThisInScope = typer0.context.enclosingContextChain exists (_.tree.isInstanceOf[ImplDef]) if (isThisInScope) { val enclosingClasses = typer0.context.enclosingContextChain map (_.tree) collect { case classDef: ClassDef => classDef } val classInScope = enclosingClasses.headOption getOrElse EmptyTree diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index d941519958..c2310ed851 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -111,7 +111,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => val ownerClass = rootMirror.EmptyPackageClass.newClassSymbol(newTypeName("<expression-owner>")) build.setTypeSignature(ownerClass, ClassInfoType(List(ObjectClass.tpe), newScope, ownerClass)) val owner = ownerClass.newLocalDummy(expr.pos) - var currentTyper = typer.atOwner(expr, owner) + var currentTyper = analyzer.newTyper(analyzer.rootContext(NoCompilationUnit, EmptyTree).make(expr, owner)) val wrapper1 = if (!withImplicitViewsDisabled) (currentTyper.context.withImplicitsEnabled[Tree] _) else (currentTyper.context.withImplicitsDisabled[Tree] _) val wrapper2 = if (!withMacrosDisabled) (currentTyper.context.withMacrosEnabled[Tree] _) else (currentTyper.context.withMacrosDisabled[Tree] _) def wrapper (tree: => Tree) = wrapper1(wrapper2(tree)) |