diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-02-10 17:06:04 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-02-10 17:18:51 +0100 |
commit | ea36cada85e77b7dde85db62ddb4a6da88f76eb4 (patch) | |
tree | f34e609047d9f84f7b786f10c3b84e37ca2dab4b /src | |
parent | 0c16bb0af13c1b30224dcb9de0b88354663d834b (diff) | |
download | scala-ea36cada85e77b7dde85db62ddb4a6da88f76eb4.tar.gz scala-ea36cada85e77b7dde85db62ddb4a6da88f76eb4.tar.bz2 scala-ea36cada85e77b7dde85db62ddb4a6da88f76eb4.zip |
SI-8258 Revert "SI-7335 Remove special case for import of Predef._
This reverts commit 66904556ef34dc81cbb7c09257b013b3ddb76f78.
Conflicts:
src/reflect/scala/reflect/internal/TreeInfo.scala
As evidenced by the highlights of the stack trace in Scala IDE,
my assertion in the 66904556e wasn't universally true.
The change was only motivated by removing a special case, not in
order to fix some other problem. So the revert is the most straight
forward course of action for now.
I haven't pinned this down with a test outside of Eclipse, and
given the lateness of the hour wrt 2.11.0, I'll have to submit
without one.
2013-03-10 08:38:04,690 ERROR [main] - org.scala-ide.sdt.core - org.scala-ide.sdt.core - org.scala-ide.sdt.core - 0 - Error during askOption
scala.reflect.internal.Symbols$CyclicReference: illegal cyclic reference involving object Predef
...
at scala.reflect.internal.Symbols$Symbol.lock(Symbols.scala:482)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1216)
at scala.reflect.internal.Symbols$Symbol.tpe(Symbols.scala:1200)
at scala.reflect.internal.Symbols$Symbol.tpeHK(Symbols.scala:1201)
at scala.reflect.internal.Types$Type.computeMemberType(Types.scala:784)
at scala.reflect.internal.Types$Type.memberType(Types.scala:781)
at scala.reflect.internal.TreeGen.mkAttributedSelect(TreeGen.scala:203)
...
at scala.reflect.internal.TreeGen.mkAttributedStableRef(TreeGen.scala:162)
at scala.tools.nsc.ast.TreeGen.mkWildcardImport(TreeGen.scala:39)
at scala.tools.nsc.typechecker.Contexts$Context.makeNewImport(Contexts.scala:308)
at scala.tools.nsc.typechecker.Contexts$class.rootContext(Contexts.scala:69)
at scala.tools.nsc.Global$$anon$1.rootContext(Global.scala:492)
at scala.tools.nsc.typechecker.Contexts$class.rootContext(Contexts.scala:64)
at scala.tools.nsc.Global$$anon$1.rootContext(Global.scala:492)
at scala.tools.nsc.typechecker.Analyzer$namerFactory$$anon$1.apply(Analyzer.scala:43)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:463)
...
at scala.tools.nsc.Global$Run.compileLate(Global.scala:1681)
at scala.tools.nsc.Global$Run.compileLate(Global.scala:1671)
at scala.tools.nsc.symtab.SymbolLoaders$SourcefileLoader.doComplete(SymbolLoaders.scala:284)
at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:187)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1229)
at scala.reflect.internal.Symbols$Symbol.tpe(Symbols.scala:1200)
at scala.reflect.internal.Symbols$Symbol.tpeHK(Symbols.scala:1201)
at scala.reflect.internal.Types$Type.computeMemberType(Types.scala:784)
at scala.reflect.internal.Types$Type.memberType(Types.scala:781)
at scala.reflect.internal.TreeGen.mkAttributedSelect(TreeGen.scala:203)
at scala.reflect.internal.TreeGen.mkAttributedRef(TreeGen.scala:124)
at scala.reflect.internal.TreeGen.mkAttributedRef(TreeGen.scala:130)
at scala.reflect.internal.TreeGen.mkAttributedStableRef(TreeGen.scala:162)
at scala.tools.nsc.ast.TreeGen.mkWildcardImport(TreeGen.scala:39)
...
at scala.tools.nsc.Global$$anon$1.rootContext(Global.scala:492)
at scala.tools.nsc.typechecker.Analyzer$namerFactory$$anon$1.apply(Analyzer.scala:43)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:463)
...
at scala.tools.nsc.Global$Run.compileLate(Global.scala:1671)
at scala.tools.nsc.symtab.SymbolLoaders$SourcefileLoader.doComplete(SymbolLoaders.scala:284)
at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:187)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1229)
at scala.reflect.internal.Symbols$Symbol.initialize(Symbols.scala:1365)
...
at scala.collection.immutable.HashSet$HashSet1.foreach(HashSet.scala:153)
at scala.collection.immutable.HashSet$HashTrieSet.foreach(HashSet.scala:306)
at scala.tools.eclipse.javaelements.ScalaJavaMapper$class.initializeRequiredSymbols(ScalaJavaMapper.scala:29)
...
at scala.tools.nsc.util.InterruptReq.execute(InterruptReq.scala:26)
at scala.tools.nsc.interactive.Global.pollForWork(Global.scala:340)
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 2 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/TreeInfo.scala | 22 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index e5907e1a0f..a99c01de39 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -89,6 +89,8 @@ trait Contexts { self: Analyzer => if (settings.noimports) Nil else if (unit.isJava) RootImports.javaList else if (settings.nopredef || treeInfo.noPredefImportForUnit(unit.body)) { + // SI-8258 Needed for the presentation compiler using -sourcepath, otherwise cycles can occur. See the commit + // message for this ticket for an example. debuglog("Omitted import of Predef._ for " + unit) RootImports.javaAndScalaList } diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index 7bab15b0f4..8cad2497c1 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -735,6 +735,17 @@ abstract class TreeInfo { unapply(dissectApplied(tree)) } + /** Does list of trees start with a definition of + * a class of module with given name (ignoring imports) + */ + def firstDefinesClassOrObject(trees: List[Tree], name: Name): Boolean = trees match { + case Import(_, _) :: xs => firstDefinesClassOrObject(xs, name) + case Annotated(_, tree1) :: _ => firstDefinesClassOrObject(List(tree1), name) + case ModuleDef(_, `name`, _) :: _ => true + case ClassDef(_, `name`, _, _) :: _ => true + case _ => false + } + /** Locates the synthetic Apply node corresponding to an extractor's call to * unapply (unwrapping nested Applies) and returns the fun part of that Apply. */ @@ -750,8 +761,7 @@ abstract class TreeInfo { } /** Is this file the body of a compilation unit which should not - * have Predef imported? This is the case iff the first import in the - * unit explicitly refers to Predef. + * have Predef imported? */ def noPredefImportForUnit(body: Tree) = { // Top-level definition whose leading imports include Predef. @@ -760,7 +770,13 @@ abstract class TreeInfo { case Import(expr, _) => isReferenceToPredef(expr) case _ => false } - isLeadingPredefImport(body) + // Compilation unit is class or object 'name' in package 'scala' + def isUnitInScala(tree: Tree, name: Name) = tree match { + case PackageDef(Ident(nme.scala_), defs) => firstDefinesClassOrObject(defs, name) + case _ => false + } + + isUnitInScala(body, nme.Predef) || isLeadingPredefImport(body) } def isAbsTypeDef(tree: Tree) = tree match { |