summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-05-20 17:57:27 +0000
committerPaul Phillips <paulp@improving.org>2009-05-20 17:57:27 +0000
commitf151228bbd902d48c1d66e99b3779659f4a1b478 (patch)
treee19629c2fc272e14ceb6a4e4e74e07bb2cc1b165 /src/compiler/scala/tools/nsc/typechecker
parent14a4920c0c3381d8992673e3994739b1e2783c84 (diff)
downloadscala-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.)
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Analyzer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala71
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala22
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala77
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala98
7 files changed, 57 insertions, 223 deletions
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)