summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/TreeInfo.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-02-10 17:06:04 +0100
committerJason Zaugg <jzaugg@gmail.com>2014-02-10 17:18:51 +0100
commitea36cada85e77b7dde85db62ddb4a6da88f76eb4 (patch)
treef34e609047d9f84f7b786f10c3b84e37ca2dab4b /src/reflect/scala/reflect/internal/TreeInfo.scala
parent0c16bb0af13c1b30224dcb9de0b88354663d834b (diff)
downloadscala-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/reflect/scala/reflect/internal/TreeInfo.scala')
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala22
1 files changed, 19 insertions, 3 deletions
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 {