diff options
author | Paul Phillips <paulp@improving.org> | 2009-05-20 17:57:27 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-05-20 17:57:27 +0000 |
commit | f151228bbd902d48c1d66e99b3779659f4a1b478 (patch) | |
tree | e19629c2fc272e14ceb6a4e4e74e07bb2cc1b165 | |
parent | 14a4920c0c3381d8992673e3994739b1e2783c84 (diff) | |
download | scala-f151228bbd902d48c1d66e99b3779659f4a1b478.tar.gz scala-f151228bbd902d48c1d66e99b3779659f4a1b478.tar.bz2 scala-f151228bbd902d48c1d66e99b3779659f4a1b478.zip |
Unreasonably satisfying patch which sets immuta...
Unreasonably satisfying patch which sets immutable final val inIDE = false
and then performs dead code elimination (human style.)
18 files changed, 89 insertions, 345 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 4422a8b1ba..5b23ce2c45 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -867,7 +867,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable def forCLDC: Boolean = settings.target.value == "cldc" def forJVM : Boolean = settings.target.value startsWith "jvm" def forMSIL: Boolean = settings.target.value == "msil" - def onlyPresentation = inIDE + def onlyPresentation = false private val unpickleIDEHook0 : (( => Type) => Type) = f => f def unpickleIDEHook : (( => Type) => Type) = unpickleIDEHook0 diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 1367b37729..0257faae88 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -573,12 +573,9 @@ trait Trees { // create parameters for <init> var vparamss1 = vparamss map (vps => vps.map { vd => - val ret = ValDef( + ValDef( Modifiers(vd.mods.flags & IMPLICIT | PARAM) withAnnotations vd.mods.annotations, vd.name, vd.tpt.duplicate, EmptyTree).setPos(vd.pos) - if (inIDE && vd.symbol != NoSymbol) - ret.symbol = vd.symbol - ret }) val (edefs, rest) = body span treeInfo.isEarlyDef val (evdefs, etdefs) = edefs partition treeInfo.isEarlyValDef diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 6c795b66d0..abe7c1f951 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1984,13 +1984,6 @@ self => newmods = newmods | Flags.DEFERRED EmptyTree } - var originalUsed = false - for ((pos, name) <- lhs.toList) yield atPos(pos) { - if (inIDE && !originalUsed) { - originalUsed = true - ValDef(newmods, name, tp, rhs) - } else ValDef(newmods, name, tp.duplicate, rhs.duplicate) - } } */ diff --git a/src/compiler/scala/tools/nsc/doc/ModelExtractor.scala b/src/compiler/scala/tools/nsc/doc/ModelExtractor.scala index 0e94ab90f7..8b900e44a7 100644 --- a/src/compiler/scala/tools/nsc/doc/ModelExtractor.scala +++ b/src/compiler/scala/tools/nsc/doc/ModelExtractor.scala @@ -345,7 +345,10 @@ trait ModelExtractor { if (sym.isLocalClass) return false if (sym.isLocal) return false if (sym.isPrivateLocal) return false - if (sym hasFlag PRIVATE) return !inIDE //false + // the next line used to return !inIDE - now it returns true. The underlying + // logic being applied here is somewhat mysterious (if PRIVATE return isVisible == true?) + // but changing it causes the docgenerator.scala test case to break, so I leave as-is. + if (sym hasFlag PRIVATE) return true if (sym hasFlag SYNTHETIC) return false if (sym hasFlag BRIDGE) return false if ((sym.nameString indexOf "$") != -1) return false diff --git a/src/compiler/scala/tools/nsc/symtab/IdeSupport.scala b/src/compiler/scala/tools/nsc/symtab/IdeSupport.scala index b1e0843b15..e52658baa9 100644 --- a/src/compiler/scala/tools/nsc/symtab/IdeSupport.scala +++ b/src/compiler/scala/tools/nsc/symtab/IdeSupport.scala @@ -17,7 +17,6 @@ trait IdeSupport extends SymbolTable { // added to global, not analyzers. condition } - override def inIDE = true import CompatibleResult._ trait TrackedPosition extends Position with ReallyHasClients { // symbols without scopes! diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 22c4d8a631..b24aadb909 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -48,29 +48,6 @@ abstract class SymbolLoaders { protected def sourceString: String override def complete(root: Symbol) : Unit = { - if (inIDE && root.owner != NoSymbol) { - assert(root.rawInfo == this) - if (root.isModuleClass) { - val clazz = root.sourceModule.linkedClassOfModule - assert(root.rawInfo == this) - if (clazz != NoSymbol && !clazz.rawInfo.isInstanceOf[SymbolLoader]) { - // bail - root.setInfo(ErrorType) - Console.println("ditch " + root) - return - } - } else if (root.isClass) { - val module = root.linkedModuleOfClass - assert(root.rawInfo == this) - if (module != NoSymbol && !module.rawInfo.isInstanceOf[SymbolLoader]) { - root.setInfo(ErrorType) - Console.println("ditch " + root) - return - } - } else { - assert(root.isModule) - } - } try { val start = currentTime val currentphase = phase @@ -124,11 +101,10 @@ abstract class SymbolLoaders { def enterPackage(name: String, completer: SymbolLoader) { val preExisting = root.info.decls.lookup(newTermName(name)) - if (preExisting != NoSymbol) { - if (inIDE) return - else throw new TypeError( + if (preExisting != NoSymbol) + throw new TypeError( root+" contains object and package with same name: "+name+"\none of them needs to be removed from classpath") - } + val pkg = root.newPackage(NoPosition, newTermName(name)) pkg.moduleClass.setInfo(completer) pkg.setInfo(pkg.moduleClass.tpe) @@ -181,7 +157,7 @@ abstract class SymbolLoaders { } } - for (dir <- directory.entries) if ((dir.location ne null) && (!inIDE || dir.location.isDirectory)) { + for (dir <- directory.entries) if ((dir.location ne null) && dir.location.isDirectory) { for (file <- dir.location) { if (file.isDirectory && directory.validPackage(file.name) && !packages.isDefinedAt(file.name)) packages(file.name) = directory.find(file.name, true); diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala index 090d534f3a..3559b1f5b1 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala @@ -35,8 +35,6 @@ abstract class SymbolTable extends Names /** Are we compiling for .NET ? */ def forMSIL: Boolean - /** are we in a lampion presentation compiler? cannot get inIDE flag from global */ - def inIDE : Boolean = false protected def trackTypeIDE(sym : Symbol) : Boolean = true def compare(sym : Symbol, name : Name) = sym.name == name def verifyAndPrioritize[T](g : Symbol => Symbol)(pt : Type)(f : => T) = f diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index 64f108b644..23a5d858e9 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -626,7 +626,6 @@ trait Symbols { var cnt = 0 while (validTo == NoPeriod) { //if (settings.debug.value) System.out.println("completing " + this);//DEBUG - if (inIDE && (infos eq null)) return ErrorType assert(infos ne null, this.name) assert(infos.prev eq null, this.name) val tp = infos.info @@ -683,8 +682,7 @@ trait Symbols { val curPeriod = currentPeriod val curPid = phaseId(curPeriod) - if (!inIDE && validTo != NoPeriod) { // IDE doesn't adapt. - + if (validTo != NoPeriod) { // skip any infos that concern later phases while (curPid < phaseId(infos.validFrom) && infos.prev != null) infos = infos.prev @@ -908,11 +906,7 @@ trait Symbols { def suchThat(cond: Symbol => Boolean): Symbol = { val result = filter(cond) - // @S: seems like NoSymbol has the overloaded flag???? - if (inIDE && (this eq result) && result != NoSymbol && (result hasFlag OVERLOADED)) { - return result - } - if (!inIDE) assert(!(result hasFlag OVERLOADED), result.alternatives) + assert(!(result hasFlag OVERLOADED), result.alternatives) result } @@ -1259,15 +1253,8 @@ trait Symbols { newTermName(fullNameString('$') + nme.EXPAND_SEPARATOR_STRING + name) } - def sourceFile: AbstractFile = { - var ret = (if (isModule) moduleClass else toplevelClass).sourceFile - if (ret == null && inIDE && !isModule) this match { - case sym : ModuleSymbol if sym.referenced != null => - ret = sym.referenced.sourceFile - case _ => - } - ret - } + def sourceFile: AbstractFile = + (if (isModule) moduleClass else toplevelClass).sourceFile def sourceFile_=(f: AbstractFile) { throw new Error("sourceFile_= inapplicable for " + this) @@ -1502,14 +1489,8 @@ trait Symbols { } def setLazyAccessor(sym: Symbol): TermSymbol = { - // @S: in IDE setLazyAccessor can be called multiple times on same sym - if (inIDE && referenced != NoSymbol && referenced != sym) { - // do nothing - recycle(referenced) - } else { - assert(hasFlag(LAZY) && (referenced == NoSymbol || referenced == sym), this) - referenced = sym - } + assert(hasFlag(LAZY) && (referenced == NoSymbol || referenced == sym), this) + referenced = sym this } diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 272b9cbe69..f5e33a0ac9 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -669,7 +669,6 @@ trait Types { // See (t0851) for a situation where this happens. if (!this.isGround) return typeVarToOriginMap(this).findMember(name, excludedFlags, requiredFlags, stableOnly)(from) - if (inIDE) trackTypeIDE(typeSymbol) if (util.Statistics.enabled) findMemberCount += 1 val startTime = if (util.Statistics.enabled) currentTime else 0l @@ -832,11 +831,7 @@ trait Types { override def baseType(clazz: Symbol): Type = supertype.baseType(clazz) override def baseTypeSeq: BaseTypeSeq = supertype.baseTypeSeq override def baseTypeSeqDepth: Int = supertype.baseTypeSeqDepth - override def baseClasses: List[Symbol] = { - val supertype = this.supertype - if (inIDE && supertype == null) Nil - else supertype.baseClasses - } + override def baseClasses: List[Symbol] = supertype.baseClasses override def isNotNull = supertype.isNotNull } @@ -966,8 +961,6 @@ trait Types { private var underlyingCache: Type = NoType private var underlyingPeriod = NoPeriod override def underlying: Type = { - // this kind of caching here won't work in the IDE - if (inIDE) return pre.memberType(sym).resultType val period = underlyingPeriod if (period != currentPeriod) { underlyingPeriod = currentPeriod @@ -1064,7 +1057,6 @@ trait Types { override def baseTypeSeqDepth: Int = baseTypeSeq.maxDepth override def baseClasses: List[Symbol] = { - if (inIDE) trackTypeIDE(typeSymbol) def computeBaseClasses: List[Symbol] = if (parents.isEmpty) List(typeSymbol) else { @@ -1113,16 +1105,11 @@ trait Types { } override def baseType(sym: Symbol): Type = { - if (inIDE) { trackTypeIDE(sym); trackTypeIDE(typeSymbol); } val index = baseTypeIndex(sym) if (index >= 0) baseTypeSeq(index) else NoType } - override def narrow: Type = { - if (inIDE) trackTypeIDE(typeSymbol) - typeSymbol.thisType - } - + override def narrow: Type = typeSymbol.thisType override def isNotNull: Boolean = parents exists (_.isNotNull) // override def isNullable: Boolean = @@ -1691,11 +1678,6 @@ A type's typeSymbol should never be inspected directly. override def baseType(clazz: Symbol): Type = resultType.baseType(clazz) override def narrow: Type = resultType.narrow override def isVolatile = resultType.isVolatile - - override def deconst = - if (inIDE) PolyType(typeParams, resultType.deconst) - else super.deconst - override def finalResultType: Type = resultType.finalResultType /** @M: abstractTypeSig now wraps a TypeBounds in a PolyType @@ -2040,13 +2022,10 @@ A type's typeSymbol should never be inspected directly. if (phase.erasedTypes) if (parents.isEmpty) ObjectClass.tpe else parents.head else { - val clazz = recycle(owner.newRefinementClass(if (inIDE) pos else NoPosition)) - if (!inIDE || !parents.isEmpty) { - val result = refinementOfClass(clazz, parents, decls) - clazz.setInfo(result) - result - } else clazz.info - //result + val clazz = recycle(owner.newRefinementClass(NoPosition)) + val result = refinementOfClass(clazz, parents, decls) + clazz.setInfo(result) + result } } @@ -2770,14 +2749,10 @@ A type's typeSymbol should never be inspected directly. if ((pre eq NoType) || (pre eq NoPrefix) || !clazz.isClass) mapOver(tp) //@M! see test pos/tcpoly_return_overriding.scala why mapOver is necessary else { - def throwError : Nothing = - // IDE: in the IDE, this will occur because we complete everything - // too eagerly. It doesn't matter, the error will be fixed when - // the node is re-typed. - if (inIDE) throw new TypeError("internal error: " + tp + " in " + sym.owner + - " cannot be instantiated from " + pre.widen) - else throw new Error("" + tp + sym.locationString + - " cannot be instantiated from " + pre.widen) + def throwError : Nothing = throw new Error( + "" + tp + sym.locationString + " cannot be instantiated from " + pre.widen + ) + def instParam(ps: List[Symbol], as: List[Type]): Type = if (ps.isEmpty) throwError else if (sym eq ps.head) @@ -2824,7 +2799,6 @@ A type's typeSymbol should never be inspected directly. def subst(tp: Type, sym: Symbol, from: List[Symbol], to: List[T]): Type = if (from.isEmpty) tp - else if (to.isEmpty && inIDE) throw new TypeError(NoPosition, "type parameter list problem"); else if (matches(from.head, sym)) toType(tp, to.head) else subst(tp, sym, from.tail, to.tail) @@ -3200,8 +3174,7 @@ A type's typeSymbol should never be inspected directly. object adaptToNewRunMap extends TypeMap { private def adaptToNewRun(pre: Type, sym: Symbol): Symbol = { - if (inIDE) sym // dependecies adapted at a finer granularity in IDE - else if (sym.isModuleClass && !phase.flatClasses) { + if (sym.isModuleClass && !phase.flatClasses) { adaptToNewRun(pre, sym.sourceModule).moduleClass } else if ((pre eq NoPrefix) || (pre eq NoType) || sym.owner.isPackageClass) { sym @@ -3660,12 +3633,9 @@ A type's typeSymbol should never be inspected directly. case (SingleType(_, _), ThisType(_)) => tp1 =:= tp2 case (SingleType(_, _), SingleType(_, _)) => tp1 =:= tp2 case (ConstantType(_), ConstantType(_)) => tp1 =:= tp2 - case (TypeRef(pre1, sym1: TypeSkolem, args1), TypeRef(pre2, sym2: TypeSkolem, args2)) - if (inIDE && args1 == args2 && pre1 == pre2 && sym1.deSkolemize == sym2.deSkolemize) => true case (TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) if !(tp1.isHigherKinded || tp2.isHigherKinded) => //Console.println("isSubType " + tp1 + " " + tp2);//DEBUG - if (inIDE) { trackTypeIDE(sym1); trackTypeIDE(sym2); } def isSubArgs(tps1: List[Type], tps2: List[Type], tparams: List[Symbol]): Boolean = ( @@ -3736,8 +3706,7 @@ A type's typeSymbol should never be inspected directly. isSubType0(tp1a, tp2a, depth) }) case (_, TypeRef(pre2, sym2, args2)) - if (sym2.isAbstractType && isDifferentType(tp2, tp2.bounds.lo) && (tp1 <:< tp2.bounds.lo) && - (if (!inIDE) true else trackTypeIDE(sym2)) || + if (sym2.isAbstractType && isDifferentType(tp2, tp2.bounds.lo) && (tp1 <:< tp2.bounds.lo) || sym2 == NotNullClass && tp1.isNotNull) => true case (_, TypeRef(pre2, sym2, args2)) @@ -3768,7 +3737,6 @@ A type's typeSymbol should never be inspected directly. tp1.underlying <:< tp2 case (TypeRef(pre1, sym1, args1), _) => - if (inIDE) trackTypeIDE(sym1) (sym1 == NothingClass && tp2 <:< AnyClass.tpe || sym1 == NullClass && tp2.isInstanceOf[SingletonType] && (tp1 <:< tp2.widen) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 77cc8359b8..110bf32a46 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -371,11 +371,8 @@ abstract class ClassfileParser { externalName = pool.getClassName(nameIdx) val c = if (externalName.toString.indexOf('$') < 0) pool.getClassSymbol(nameIdx) else clazz if (c != clazz && externalName.toString.indexOf("$") < 0) { - if ((clazz eq NoSymbol) && (c ne NoSymbol)) { // XXX: needed for build compiler, so can't protect with inIDE - clazz = c - } else if (inIDE) { - Console.println("WRONG CLASS: expected: " + clazz + " found " + c) - } else throw new IOException("class file '" + in.file + "' contains wrong " + c) + if ((clazz eq NoSymbol) && (c ne NoSymbol)) clazz = c + else throw new IOException("class file '" + in.file + "' contains wrong " + c) } addEnclosingTParams(clazz) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala index be9b3e949f..1e368b9664 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala @@ -773,8 +773,7 @@ abstract class UnPickler { private def errorBadSignature(msg: String) = - if (inIDE) throw new TypeError(msg) - else throw new RuntimeException("malformed Scala signature of " + classRoot.name + " at " + readIndex + "; " + msg) + throw new RuntimeException("malformed Scala signature of " + classRoot.name + " at " + readIndex + "; " + msg) private var printedReflectAnnotationWarning = false private def reflectAnnotationWarning() { @@ -790,10 +789,9 @@ abstract class UnPickler { // In IDE, captures class files dependencies so they can be reloaded when their dependencies change. private val ideHook = unpickleIDEHook override def complete(sym: Symbol) : Unit = { - if (sym.rawInfo != this && inIDE) return val tp = ideHook(at(i, readType)) sym setInfo tp - if (!inIDE && currentRunId != definedAtRunId) sym.setInfo(adaptToNewRunMap(tp)) + if (currentRunId != definedAtRunId) sym.setInfo(adaptToNewRunMap(tp)) } override def load(sym: Symbol) { complete(sym) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala index 1cdc1563e8..31bb361d68 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala @@ -41,7 +41,7 @@ trait Analyzer extends AnyRef val runsAfter = List[String]() val runsRightAfter = Some("namer") def newPhase(_prev: Phase): StdPhase = new StdPhase(_prev) { - if (!inIDE) resetTyper() + resetTyper() def apply(unit: CompilationUnit) { try { unit.body = newTyper(rootContext(unit)).typed(unit.body) diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 373716806b..80b8189b5f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -145,65 +145,10 @@ trait Contexts { self: Analyzer => txt } override def equals(that: Any): Boolean = that match { - case that: AnyRef if (this eq that) => - true - case that if !inIDE => - super.equals(that) - //case NoContext => false - case that: Context => - if (that eq NoContext) return this eq NoContext - assert(that ne NoContext) - if (this eq NoContext) return false - assert(inIDE) - def eq[T](x : T, y : T) = x == y - val a0 = { - if ((tree ne null) && (tree ne EmptyTree)) tree.setType(null) - if ((tree eq null) || (that.tree eq null)) tree == that.tree else - tree equalsStructure that.tree; - } - val a1 = eq(owner, that.owner) - val a2 = eq(scope, that.scope) - def fix(txt0 : Context, txt1 : Context) = - ((this eq txt0) && (that eq txt1)) || (txt0 eq txt1) - - val a3 = fix(outer, that.outer) - val a4 = fix(enclClass, that.enclClass) - val a5 = fix(enclMethod, that.enclMethod) - val a6 = eq(variance, that.variance) - val a7 = eq(_undetparams, that._undetparams) - val a8 = eq(depth, that.depth) - val a9 = eq(imports, that.imports) - - val a10 = eq(openImplicits, that.openImplicits) - val a11 = eq(prefix, that.prefix) - val a12 = eq(inConstructorSuffix, that.inConstructorSuffix) - val a13 = eq(implicitsEnabled, that.implicitsEnabled) - val a14 = eq(checking, that.checking) - val a15 = eq(retyping, that.retyping) - val a16 = eq(savedTypeBounds, that.savedTypeBounds) - val a17 = eq(unit, that.unit) - val ret = a0 && a1 && a2 && a3 && a4 && a5 && a6 && a7 && a8 && a9 && a10 && a11 && a12 && a13 && a14 && a15 && a16 && a17 - val a18 = { - if (implicitsRunId > that.implicitsRunId) { - that.implicitsRunId = NoRunId - that.implicitsCache = null - } - else if (that.implicitsRunId > implicitsRunId) { - implicitsRunId = NoRunId - implicitsCache = null - } - implicitsCache == that.implicitsCache - } - if (ret) { - if (!a18) { - //assert(this.implicitsCache == null || that.implicitsCache == null) - } - } - ret - case _ => false + case that: AnyRef if this eq that => true + case that => super.equals(that) } - def undetparams = _undetparams def undetparams_=(ps: List[Symbol]) = { //System.out.println("undetparams = " + ps);//debug @@ -345,7 +290,7 @@ trait Contexts { self: Analyzer => def error(pos: Position, err: Error) { val msg = err.getMessage() - if (reportGeneralErrors || inIDE) + if (reportGeneralErrors) unit.error(pos, if (checking) "**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg) else throw err @@ -439,8 +384,6 @@ trait Contexts { self: Analyzer => def accessWithin(owner: Symbol): Boolean = { var c = this while (c != NoContext && c.owner != owner) { - if (false && inIDE) // XXX: we didn't get to update these syms.... - assert(c.owner.fullNameString != owner.fullNameString) if (c.outer eq null) assert(false, "accessWithin(" + owner + ") " + c);//debug if (c.outer.enclClass eq null) assert(false, "accessWithin(" + owner + ") " + c);//debug c = c.outer.enclClass @@ -632,12 +575,10 @@ trait Contexts { self: Analyzer => case class ImportType(expr: Tree) extends Type { override def equals(that : Any) = that match { - case ImportType(expr) => - if (inIDE) this.expr equalsStructure expr - else this.expr == expr - case _ => false + case ImportType(expr) => this.expr == expr + case _ => false } - override def hashCode = if (inIDE) expr.hashCodeStructure else expr.hashCode + override def hashCode = expr.hashCode override def safeToString = "ImportType("+expr+")" } protected def intern(txt : Context) = txt diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala index b8e7822abd..dde27ece10 100644 --- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala +++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala @@ -49,22 +49,18 @@ trait EtaExpansion { self: Analyzer => */ def etaExpand(unit : CompilationUnit, tree: Tree): Tree = { val tpe = tree.tpe - val symbolHash = if (!inIDE) "" else Integer.toString(tree.symbol.hashCode, 10 + ('z' - 'a')) + "$" + val symbolHash = "" var cnt = 0 // for NoPosition def freshName(pos : util.Position, n : Int) = { cnt += 1 - if (!inIDE) { - newTermName(unit.fresh.newName(pos, "eta$" + (cnt - 1) + "$")) - } else if (pos == util.NoPosition) { - // nothing we can do, hope for no conflict! - newTermName(("eta$" + symbolHash + (cnt - 1))) - } else - newTermName(unit.fresh.newName(pos, "eta$" + symbolHash + (cnt - 1) + "$")) - // Martin to Sean: I removed the - // else if (n == 0) branch and changed `n' in the line above to `(cnt - 1)' - // this was necessary because otherwise curried eta-expansions would get the same - // symbol. An example which failes test/files/run/Course-2002-02.scala - // todo: review and get rid of the `n' argument (which is unused right now). + newTermName(unit.fresh.newName(pos, "eta$" + (cnt - 1) + "$")) + // Note - the comment below made more sense before I ripped inIDE out - + // I leave it in to give context to the todo: at the bottom. + // Martin to Sean: I removed the + // else if (n == 0) branch and changed `n' in the line above to `(cnt - 1)' + // this was necessary because otherwise curried eta-expansions would get the same + // symbol. An example which failes test/files/run/Course-2002-02.scala + // todo: review and get rid of the `n' argument (which is unused right now). } // { cnt = cnt + 1; newTermName("eta$" + cnt) } val defs = new ListBuffer[Tree] diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 6f1bd8a5d2..ee892b7b21 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -293,7 +293,7 @@ trait Infer { private def withDisambiguation[T](tp1: Type, tp2: Type)(op: => T): T = { def explainName(sym: Symbol) = { - if (!sym.name.toString.endsWith(")") && !inIDE) { + if (!sym.name.toString.endsWith(")")) { sym.name = newTypeName(sym.name.toString+"(in "+sym.owner+")") } } @@ -307,7 +307,7 @@ trait Infer { val name = sym1.name explainName(sym1) explainName(sym2) - if (sym1.owner == sym2.owner && !inIDE) sym2.name = newTypeName("(some other)"+sym2.name) + if (sym1.owner == sym2.owner) sym2.name = newTypeName("(some other)"+sym2.name) patches += ((sym1, sym2, name)) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 325ed5f8f1..ad27f3010b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -116,7 +116,7 @@ trait Namers { self: Analyzer => if (sym.isTerm) { if (sym.hasFlag(PARAM) && sym.owner.isPrimaryConstructor) primaryConstructorParamNamer - else if (sym.hasFlag(PARAMACCESSOR) && !inIDE) + else if (sym.hasFlag(PARAMACCESSOR)) primaryConstructorParamNamer else innerNamer } else innerNamer @@ -153,29 +153,9 @@ trait Namers { self: Analyzer => // allow for overloaded methods if (!(sym.isSourceMethod && sym.owner.isClass && !sym.owner.isPackageClass)) { var prev = scope.lookupEntryWithContext(sym.name)(context.owner); - if ((prev ne null) && inIDE) { - var guess = prev - while ((guess ne null) && (guess.sym ne sym)) guess = scope.lookupNextEntry(guess) - if (guess != null) prev = guess - while (prev != null && (!prev.sym.hasRawInfo || !prev.sym.rawInfo.isComplete || - (prev.sym.sourceFile == null && sym.getClass == prev.sym.getClass))) { - if (!prev.sym.hasRawInfo || prev.sym.rawInfo.isComplete) { - Console.println("DITCHING: " + prev.sym) - } - scope unlink prev.sym - prev = scope.lookupNextEntry(prev) - } - val sym0 = scope enter sym - if (sym0 ne sym) { - Console.println("WEIRD: " + sym0 + " vs. " + sym + " " + sym0.id + " " + sym.id + " " + sym.sourceFile + " " + sym0.sourceFile) - } - if (prev != null && (sym0 ne prev.sym) && conflict(sym0,prev.sym)) { - doubleDefError(sym0.pos, prev.sym) - } - sym0 - } else if ((prev ne null) && prev.owner == scope && conflict(sym, prev.sym)) { + if ((prev ne null) && prev.owner == scope && conflict(sym, prev.sym)) { doubleDefError(sym.pos, prev.sym) - sym setInfo ErrorType // don't do this in IDE for stability + sym setInfo ErrorType scope unlink prev.sym // let them co-exist... scope enter sym } else scope enter sym @@ -191,8 +171,6 @@ trait Namers { self: Analyzer => p } else { val pkg = cowner.newPackage(pos, name) - // IDE: newScope should be ok because packages are never destroyed. - if (inIDE) assert(!pkg.moduleClass.hasRawInfo || !pkg.moduleClass.rawInfo.isComplete) pkg.moduleClass.setInfo(new PackageClassInfoType(newScope, pkg.moduleClass, null)) pkg.setInfo(pkg.moduleClass.tpe) enterInScope(pkg, cscope) @@ -201,7 +179,7 @@ trait Namers { self: Analyzer => def enterClassSymbol(tree : ClassDef): Symbol = { var c: Symbol = context.scope.lookupWithContext(tree.name)(context.owner); - if (!inIDE && c.isType && c.owner.isPackageClass && context.scope == c.owner.info.decls && !currentRun.compiles(c)) { + if (c.isType && c.owner.isPackageClass && context.scope == c.owner.info.decls && !currentRun.compiles(c)) { updatePosFlags(c, tree.pos, tree.mods.flags) setPrivateWithin(tree, c, tree.mods) } else { @@ -218,7 +196,7 @@ trait Namers { self: Analyzer => } clazz.sourceFile = file if (clazz.sourceFile ne null) { - assert(inIDE || !currentRun.compiles(clazz) || clazz.sourceFile == currentRun.symSource(c)); + assert(!currentRun.compiles(clazz) || clazz.sourceFile == currentRun.symSource(c)); currentRun.symSource(c) = clazz.sourceFile } } @@ -233,7 +211,7 @@ trait Namers { self: Analyzer => var m: Symbol = context.scope.lookupWithContext(tree.name)(context.owner) val moduleFlags = tree.mods.flags | MODULE | FINAL if (m.isModule && !m.isPackage && inCurrentScope(m) && - ((!inIDE && !currentRun.compiles(m)) || (m hasFlag SYNTHETIC))) { + (!currentRun.compiles(m) || (m hasFlag SYNTHETIC))) { updatePosFlags(m, tree.pos, moduleFlags) setPrivateWithin(tree, m, tree.mods) context.unit.synthetics -= m @@ -282,8 +260,7 @@ trait Namers { self: Analyzer => } def applicableTypeParams(owner: Symbol): List[Symbol] = - if (inIDE && (owner eq NoSymbol)) List() - else if (owner.isTerm || owner.isPackageClass) List() + if (owner.isTerm || owner.isPackageClass) List() else applicableTypeParams(owner.owner) ::: owner.typeParams /** If no companion object for clazz exists yet, create one by applying `creator` to @@ -292,7 +269,7 @@ trait Namers { self: Analyzer => */ def ensureCompanionObject(tree: ClassDef, creator: ClassDef => Tree): Symbol = { val m: Symbol = context.scope.lookupWithContext(tree.name.toTermName)(context.owner).filter(! _.isSourceMethod) - if (m.isModule && inCurrentScope(m) && (inIDE || currentRun.compiles(m))) m + if (m.isModule && inCurrentScope(m) && currentRun.compiles(m)) m else enterSyntheticSym(creator(tree)) } @@ -451,9 +428,6 @@ trait Namers { self: Analyzer => mkTypeCompleter(tree) { sym => val moduleSymbol = tree.symbol assert(moduleSymbol.moduleClass == sym) - if (inIDE && moduleSymbol.rawInfo.isComplete) { - // reset! - } moduleSymbol.info // sets moduleClass info as a side effect. //assert(sym.rawInfo.isComplete) } @@ -507,15 +481,7 @@ trait Namers { self: Analyzer => def enterValueParams(owner: Symbol, vparamss: List[List[ValDef]]): List[List[Symbol]] = { def enterValueParam(param: ValDef): Symbol = { - if (inIDE) param.symbol = { - var sym = owner.newValueParameter(param.pos, param.name). - setFlag(param.mods.flags & (BYNAMEPARAM | IMPLICIT)) - setPrivateWithin(param, sym, param.mods) - sym = enterInScope(sym).asInstanceOf[TermSymbol] - if (!sym.hasRawInfo || sym.rawInfo.isComplete) - setInfo(sym)(typeCompleter(param)) - sym - } else param.symbol = setInfo( + param.symbol = setInfo( enterInScope{ val sym = owner.newValueParameter(param.pos, param.name). setFlag(param.mods.flags & (BYNAMEPARAM | IMPLICIT)) @@ -633,18 +599,8 @@ trait Namers { self: Analyzer => // unless they exist already Namers.this.caseClassOfModuleClass get clazz match { case Some(cdef) => - val go = if (inIDE) { // garbage collect in the presentaiton compiler. - assert(cdef.symbol != null && cdef.symbol != NoSymbol) - if (!cdef.symbol.isClass || !cdef.symbol.hasFlag(CASE) || cdef.symbol.rawInfo == NoType) false - else true - } else true - if (go) - addApplyUnapply(cdef, templateNamer) - if (!go || !inIDE) caseClassOfModuleClass -= clazz - if (!go) { - val rem = clazz.linkedModuleOfClass - assert(rem != NoSymbol) - } + addApplyUnapply(cdef, templateNamer) + caseClassOfModuleClass -= clazz case None => } ClassInfoType(parents, decls, clazz) @@ -658,14 +614,8 @@ trait Namers { self: Analyzer => val meth = context.owner val tparamSyms = typer.reenterTypeParams(tparams) - var vparamSymss = - if (inIDE && meth.isPrimaryConstructor) { - // @S: because they have already been entered this way.... + var vparamSymss = enterValueParams(meth, vparamss) - enterValueParams(meth.owner.owner, vparamss) - } else { - enterValueParams(meth, vparamss) - } if (tpt.isEmpty && meth.name == nme.CONSTRUCTOR) { tpt.tpe = context.enclClass.owner.tpe tpt setPos meth.pos @@ -1008,7 +958,7 @@ trait Namers { self: Analyzer => if (sym.hasFlag(IMPLICIT) && !sym.isTerm) context.error(sym.pos, "`implicit' modifier can be used only for values, variables and methods") - if (sym.hasFlag(IMPLICIT) && sym.owner.isPackageClass && !inIDE) + if (sym.hasFlag(IMPLICIT) && sym.owner.isPackageClass) context.error(sym.pos, "`implicit' modifier cannot be used for top-level objects") if (sym.hasFlag(SEALED) && !sym.isClass) context.error(sym.pos, "`sealed' modifier can be used only for classes") @@ -1077,7 +1027,6 @@ trait Namers { self: Analyzer => if (member hasFlag ACCESSOR) { if (member.isDeferred) { val getter = if (member.isSetter) member.getter(member.owner) else member - if (inIDE && getter == NoSymbol) return NoSymbol; val result = getter.owner.newValue(getter.pos, getter.name) .setInfo(getter.tpe.resultType) .setFlag(DEFERRED) diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 6e55404414..22ad123aae 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -46,12 +46,12 @@ trait SyntheticMethods { self: Analyzer => val localContext = if (reporter.hasErrors) context.makeSilent(false) else context val localTyper = newTyper(localContext) - def hasImplementation(name: Name): Boolean = if (inIDE) true else { + def hasImplementation(name: Name): Boolean = { val sym = clazz.info.member(name) // member and not nonPrivateMember: bug #1385 sym.isTerm && !(sym hasFlag DEFERRED) } - def hasOverridingImplementation(meth: Symbol): Boolean = if (inIDE) true else { + def hasOverridingImplementation(meth: Symbol): Boolean = { val sym = clazz.info.nonPrivateMember(meth.name) sym.alternatives exists { sym => sym != meth && !(sym hasFlag DEFERRED) && !(sym hasFlag (SYNTHETIC | SYNTHETICMETH)) && @@ -64,7 +64,7 @@ trait SyntheticMethods { self: Analyzer => def newSyntheticMethod(name: Name, flags: Int, tpe: Type) = { var method = clazz.newMethod(clazz.pos, name) - .setFlag(flags | (if (inIDE) SYNTHETIC else SYNTHETICMETH)) + .setFlag(flags | SYNTHETICMETH) .setInfo(tpe) method = clazz.info.decls.enter(method).asInstanceOf[TermSymbol] method diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 71ec6d417d..a272d7aa28 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -432,7 +432,7 @@ trait Typers { self: Analyzer => this.scope = scope hiddenSymbols = List() val tp1 = apply(tree.tpe) - if (hiddenSymbols.isEmpty || inIDE) tree setType tp1 // @S: because arguments of classes are owned by the classes' owner + if (hiddenSymbols.isEmpty) tree setType tp1 else if (hiddenSymbols exists (_.isErroneous)) setError(tree) else if (isFullyDefined(pt)) tree setType pt //todo: eliminate else if (tp1.typeSymbol.isAnonymousClass) // todo: eliminate @@ -716,7 +716,7 @@ trait Typers { self: Analyzer => protected def adapt(tree: Tree, mode: Int, pt: Type): Tree = tree.tpe match { case atp @ AnnotatedType(_, _, _) if canAdaptAnnotations(tree, mode, pt) => // (-1) adaptAnnotations(tree, mode, pt) - case ct @ ConstantType(value) if ((mode & (TYPEmode | FUNmode)) == 0 && (ct <:< pt) && !inIDE) => // (0) + case ct @ ConstantType(value) if ((mode & (TYPEmode | FUNmode)) == 0 && (ct <:< pt)) => // (0) copy.Literal(tree, value) case OverloadedType(pre, alts) if ((mode & FUNmode) == 0) => // (1) inferExprAlternative(tree, pt) @@ -1109,8 +1109,7 @@ trait Typers { self: Analyzer => //Console.println(context.owner);//DEBUG //Console.println(context.owner.unsafeTypeParams);//DEBUG //Console.println(List.fromArray(context.owner.info.closure));//DEBUG - // disable in IDE, don't know how else to avoid it on refresh - if (!inIDE) error(parent.pos, "illegal inheritance;\n self-type "+ + error(parent.pos, "illegal inheritance;\n self-type "+ selfType+" does not conform to "+parent + "'s selftype "+parent.tpe.typeOfThis) if (settings.explaintypes.value) explainTypes(selfType, parent.tpe.typeOfThis) @@ -1159,9 +1158,6 @@ trait Typers { self: Analyzer => // attributes(cdef) val typedMods = typedModifiers(cdef.mods) val clazz = cdef.symbol; - if (inIDE && clazz == NoSymbol) { - throw new TypeError("type signature typing failed") - } assert(clazz != NoSymbol) reenterTypeParams(cdef.tparams) val tparams1 = List.mapConserve(cdef.tparams)(typedTypeDef) @@ -1187,7 +1183,6 @@ trait Typers { self: Analyzer => // attributes(mdef) val typedMods = typedModifiers(mdef.mods) val clazz = mdef.symbol.moduleClass - if (inIDE && clazz == NoSymbol) throw new TypeError("bad signature") assert(clazz != NoSymbol) val impl1 = newTyper(context.make(mdef.impl, clazz, scopeFor(mdef.impl, TypedDefScopeKind))) .typedTemplate(mdef.impl, parentTypes(mdef.impl)) @@ -1208,9 +1203,6 @@ trait Typers { self: Analyzer => val vdef = copy.ValDef(stat, mods | PRIVATE | LOCAL, nme.getterToLocal(name), tpt, rhs) val value = vdef.symbol val getter = if ((mods hasFlag DEFERRED)) value else value.getter(value.owner) - // XXX: - if (inIDE && getter == NoSymbol) - return Nil assert(getter != NoSymbol, stat) if (getter hasFlag OVERLOADED) error(getter.pos, getter+" is defined twice") @@ -1318,9 +1310,7 @@ trait Typers { self: Analyzer => val typer1 = constrTyperIf(sym.hasFlag(PARAM) && sym.owner.isConstructor) val typedMods = typedModifiers(vdef.mods) - var tpt1 = checkNoEscaping.privates(sym, typer1.typedType( - if (inIDE) vdef.tpt.duplicate // avoids wrong context sticking - else vdef.tpt)) + var tpt1 = checkNoEscaping.privates(sym, typer1.typedType(vdef.tpt)) checkNonCyclic(vdef, tpt1) val rhs1 = if (vdef.rhs.isEmpty) { @@ -1328,9 +1318,7 @@ trait Typers { self: Analyzer => error(vdef.pos, "local variables must be initialized") vdef.rhs } else { - //assert(vdef.rhs.tpe == null) - val rhs = if (inIDE && vdef.rhs.tpe != null) vdef.rhs.duplicate else vdef.rhs - newTyper(typer1.context.make(vdef, sym)).transformedOrTyped(rhs, tpt1.tpe) + newTyper(typer1.context.make(vdef, sym)).transformedOrTyped(vdef.rhs, tpt1.tpe) } copy.ValDef(vdef, typedMods, vdef.name, tpt1, checkDead(rhs1)) setType NoType } @@ -1346,14 +1334,11 @@ trait Typers { self: Analyzer => def decompose(call: Tree): (Tree, List[Tree]) = call match { case Apply(fn, args) => val (superConstr, args1) = decompose(fn) - val formals = (if (fn.tpe == null && inIDE) ErrorType else fn.tpe).paramTypes + val formals = fn.tpe.paramTypes val args2 = if (formals.isEmpty || formals.last.typeSymbol != RepeatedParamClass) args else args.take(formals.length - 1) ::: List(EmptyTree) - if (args2.length != formals.length) { - if (!inIDE) - assert(false, "mismatch " + clazz + " " + formals + " " + args2);//debug - else error(call.pos, "XXX: mismatch " + clazz + " " + formals + " " + args2) - } + if (args2.length != formals.length) + assert(false, "mismatch " + clazz + " " + formals + " " + args2);//debug (superConstr, args1 ::: args2) case Block(stats, expr) if !stats.isEmpty => decompose(stats.last) @@ -1401,12 +1386,6 @@ trait Typers { self: Analyzer => } () } - } else if (inIDE) { // XXX: maybe add later - Console.println("" + superClazz + ":" + - superClazz.info.decls.toList.filter(_.hasFlag(PARAMACCESSOR))) - error(rhs.pos, "mismatch: " + superParamAccessors + - ";" + rhs + ";" + superClazz.info.decls)//debug - return } } } @@ -1424,7 +1403,6 @@ trait Typers { self: Analyzer => */ def typedDefDef(ddef: DefDef): DefDef = { val meth = ddef.symbol - if (inIDE && meth == NoSymbol) throw new TypeError("bad signature") reenterTypeParams(ddef.tparams) reenterValueParams(ddef.vparamss) val tparams1 = List.mapConserve(ddef.tparams)(typedTypeDef) @@ -1454,8 +1432,7 @@ trait Typers { self: Analyzer => error(ddef.pos, "constructor definition not allowed here") typed(ddef.rhs) } else { - if (inIDE && ddef.rhs == EmptyTree) EmptyTree - else transformedOrTyped(ddef.rhs, tpt1.tpe) + transformedOrTyped(ddef.rhs, tpt1.tpe) } if (meth.isPrimaryConstructor && meth.isClassConstructor && phase.id <= currentRun.typerPhase.id && !reporter.hasErrors) @@ -1678,21 +1655,14 @@ trait Typers { self: Analyzer => context = context.makeNewImport(imp0) imp0.symbol.initialize } - if ((imp0 ne null) && inIDE) { - imp0.symbol.info match { - case ImportType(exr) => - imp0.expr.tpe = exr.tpe - case _ => - } - imp0 - } else EmptyTree + EmptyTree case _ => val localTyper = if (inBlock || (stat.isDef && !stat.isInstanceOf[LabelDef])) this else newTyper(context.make(stat, exprOwner)) val result = checkDead(localTyper.typed(stat)) if (treeInfo.isSelfOrSuperConstrCall(result)) { context.inConstructorSuffix = true - if (!inIDE && treeInfo.isSelfConstrCall(result) && result.symbol.pos.offset.getOrElse(0) >= exprOwner.enclMethod.pos.offset.getOrElse(0)) + if (treeInfo.isSelfConstrCall(result) && result.symbol.pos.offset.getOrElse(0) >= exprOwner.enclMethod.pos.offset.getOrElse(0)) error(stat.pos, "called constructor's definition must precede calling constructor's definition") } result @@ -1715,7 +1685,7 @@ trait Typers { self: Analyzer => while ((e1 ne null) && e1.owner == scope) { if (!accesses(e.sym, e1.sym) && !accesses(e1.sym, e.sym) && (e.sym.isType || inBlock || (e.sym.tpe matches e1.sym.tpe))) - if (!e.sym.isErroneous && !e1.sym.isErroneous && !inIDE) + if (!e.sym.isErroneous && !e1.sym.isErroneous) error(e.sym.pos, e1.sym+" is defined twice"+ {if(!settings.debug.value) "" else " in "+unit.toString}) e1 = scope.lookupNextEntry(e1); @@ -1891,13 +1861,13 @@ trait Typers { self: Analyzer => } } - if (!inIDE && fun.symbol == List_apply && args.isEmpty) { + if (fun.symbol == List_apply && args.isEmpty) { atPos(tree.pos) { gen.mkNil setType restpe } } else { constfold(copy.Apply(tree, fun, args2).setType(ifPatternSkipFormals(restpe))) } /* Would like to do the following instead, but curiously this fails; todo: investigate - if (!inIDE && fun.symbol.name == nme.apply && fun.symbol.owner == ListClass && args.isEmpty) { + if (fun.symbol.name == nme.apply && fun.symbol.owner == ListClass && args.isEmpty) { atPos(tree.pos) { gen.mkNil setType restpe } } else { constfold(copy.Apply(tree, fun, args2).setType(ifPatternSkipFormals(restpe))) @@ -2114,7 +2084,7 @@ trait Typers { self: Analyzer => def annotArg(tree: Tree): AnnotationArgument = { val arg = new AnnotationArgument(tree) - if(needsConstant && !arg.isConstant && !inIDE) + if (needsConstant && !arg.isConstant) needConst(tree) arg } @@ -2541,9 +2511,6 @@ trait Typers { self: Analyzer => } else { val DefDef(_, _, _, _, restpt, _) = enclMethod.tree var restpt0 = restpt - if (inIDE && (restpt0.tpe eq null)) { - restpt0 = typed(restpt0, TYPEmode, WildcardType) - } if (restpt0.tpe eq null) { errorTree(tree, "" + enclMethod.owner + " has return statement; needs result type") @@ -2917,8 +2884,7 @@ trait Typers { self: Analyzer => } tree.symbol } else { - if (!inIDE) member(qual, name)(context.owner) - else verifyAndPrioritize(_ filter (alt => context.isAccessible(alt, qual.tpe, qual.isInstanceOf[Super])))(pt)(member(qual,name)(context.owner)) + member(qual, name)(context.owner) } if (sym == NoSymbol && name != nme.CONSTRUCTOR && (mode & EXPRmode) != 0) { val qual1 = adaptToName(qual, name) @@ -2932,7 +2898,7 @@ trait Typers { self: Analyzer => qual.tpe.widen+" does not have a constructor" else decode(name)+" is not a member of "+qual.tpe.widen + - (if (!inIDE && (context.unit ne null) && + (if ((context.unit ne null) && ((for(a <- qual.pos.line; b <- tree.pos.line) yield a < b).getOrElse(false))) "\npossible cause: maybe a semicolon is missing before `"+decode(name)+"'?" else "")) @@ -3016,24 +2982,11 @@ trait Typers { self: Analyzer => while (defSym == NoSymbol && cx != NoContext) { pre = cx.enclClass.prefix - defEntry = if (!inIDE) cx.scope.lookupEntryWithContext(name)(context.owner) - else verifyAndPrioritize(sym => sym)(pt)(cx.scope.lookupEntryWithContext(name)(context.owner)) + defEntry = cx.scope.lookupEntryWithContext(name)(context.owner) if ((defEntry ne null) && qualifies(defEntry.sym)) { defSym = defEntry.sym - } else if (inIDE) { // IDE: cannot rely on linked scopes. - if (cx.outer.owner eq cx.enclClass.owner) { - //cx = cx.outer - defSym = - verifyAndPrioritize{ // enables filtering of auto completion - _ filter (sym => qualifies(sym) && context.isAccessible(sym, pre, false)) - }(pt)(pre.member(name) filter ( - sym => qualifies(sym) && context.isAccessible(sym, pre, false))) - } - val oldScope = cx.scope - cx = cx.outer - while (cx.scope == oldScope && !(cx.outer.owner eq cx.enclClass.owner)) // can't skip - cx = cx.outer - } else { + } + else { cx = cx.enclClass defSym = pre.member(name) filter ( sym => qualifies(sym) && context.isAccessible(sym, pre, false)) @@ -3059,7 +3012,7 @@ trait Typers { self: Analyzer => // imported symbols take precedence over package-owned symbols in different // compilation units. Defined symbols take precedence over errenous imports. if (defSym.definedInPackage && - ((!inIDE && !currentRun.compiles(defSym)) || + (!currentRun.compiles(defSym) || (context.unit ne null) && defSym.sourceFile != context.unit.source.file)) defSym = NoSymbol else if (impSym.isError) @@ -3112,10 +3065,7 @@ trait Typers { self: Analyzer => } if (defSym.owner.isPackageClass) pre = defSym.owner.thisType if (defSym.isThisSym) { - val tree1 = typed1(This(defSym.owner) setPos tree.pos, mode, pt) - if (inIDE) { - Ident(defSym.name) setType tree1.tpe setSymbol defSym setPos tree.pos - } else tree1 + typed1(This(defSym.owner) setPos tree.pos, mode, pt) } else { val tree1 = if (qual == EmptyTree) tree else atPos(tree.pos)(Select(qual, name)) @@ -3433,7 +3383,6 @@ trait Typers { self: Analyzer => // and we try again (@see tryTypedApply). In that case we can assign // whatever type to tree; we just have to survive until a real error message is issued. tree setType AnyClass.tpe - case EmptyTree if inIDE => EmptyTree // just tolerate it in the IDE. case _ => throw new Error("unexpected tree: " + tree.getClass + "\n" + tree)//debug } @@ -3473,13 +3422,12 @@ trait Typers { self: Analyzer => tree1.tpe = addAnnotations(tree1, tree1.tpe) - val result = if (tree1.isEmpty || (inIDE && tree1.tpe == null)) tree1 else adapt(tree1, mode, pt) + val result = if (tree1.isEmpty) tree1 else adapt(tree1, mode, pt) if (printTypings) println("adapted "+tree1+":"+tree1.tpe+" to "+pt+", "+context.undetparams); //DEBUG // if ((mode & TYPEmode) != 0) println("type: "+tree1+" has type "+tree1.tpe) result } catch { case ex: TypeError => - if (inIDE) throw ex tree.tpe = null //Console.println("caught "+ex+" in typed");//DEBUG reportTypeError(tree.pos, ex) |