summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-08-02 10:07:19 -0700
committerPaul Phillips <paulp@improving.org>2012-08-11 20:27:46 -0700
commita55788e275faed91cb9223686a3aef6ee54213a8 (patch)
tree4ac92fc704d7e06edb38680114321309c84dbd5b /src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
parent4459e5abb2b765cbdca34eb19c5d8b705203f771 (diff)
downloadscala-a55788e275faed91cb9223686a3aef6ee54213a8.tar.gz
scala-a55788e275faed91cb9223686a3aef6ee54213a8.tar.bz2
scala-a55788e275faed91cb9223686a3aef6ee54213a8.zip
More resilience to missing classes.
The situation (I don't know how to make partest test this) is package s class A ; class S { def f(): A = ??? } If one compiles this and removes A.class, should references to class S cause the compiler to explode eagerly and fail to load S, or explode lazily if and when it needs to know something about A? This patch takes us from the former strategy to the latter. Review by @xeno-by.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index 10a946c318..005d26e119 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -452,7 +452,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
def survivingParams(params: List[Symbol], env: TypeEnv) =
params filter {
p =>
- !p.isSpecialized ||
+ !p.isSpecialized ||
!env.contains(p) ||
!isPrimitiveValueType(env(p))
}
@@ -506,16 +506,16 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
* was both already used for a map and mucho long. So "sClass" is the
* specialized subclass of "clazz" throughout this file.
*/
-
+
// SI-5545: Eliminate classes with the same name loaded from the bytecode already present - all we need to do is
// to force .info on them, as their lazy type will be evaluated and the symbols will be eliminated. Unfortunately
// evaluating the info after creating the specialized class will mess the specialized class signature, so we'd
- // better evaluate it before creating the new class symbol
+ // better evaluate it before creating the new class symbol
val clazzName = specializedName(clazz, env0).toTypeName
- val bytecodeClazz = clazz.owner.info.decl(clazzName)
+ val bytecodeClazz = clazz.owner.info.decl(clazzName)
// debuglog("Specializing " + clazz + ", but found " + bytecodeClazz + " already there")
bytecodeClazz.info
-
+
val sClass = clazz.owner.newClass(clazzName, clazz.pos, (clazz.flags | SPECIALIZED) & ~CASE)
def cloneInSpecializedClass(member: Symbol, flagFn: Long => Long, newName: Name = null) =
@@ -762,7 +762,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
}
}
}
-
+
val subclasses = specializations(clazz.info.typeParams) filter satisfiable
subclasses foreach {
env =>
@@ -1006,7 +1006,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
* Fails if such an environment cannot be found.
*
* If `strict` is true, a UnifyError is thrown if unification is impossible.
- *
+ *
* If `tparams` is true, then the methods tries to unify over type params in polytypes as well.
*/
private def unify(tp1: Type, tp2: Type, env: TypeEnv, strict: Boolean, tparams: Boolean = false): TypeEnv = (tp1, tp2) match {
@@ -1185,7 +1185,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
|| specializedTypeVars(t1).nonEmpty
|| specializedTypeVars(t2).nonEmpty)
}
-
+
env forall { case (tvar, tpe) =>
matches(tvar.info.bounds.lo, tpe) && matches(tpe, tvar.info.bounds.hi) || {
if (warnings)
@@ -1201,7 +1201,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
}
}
}
-
+
def satisfiabilityConstraints(env: TypeEnv): Option[TypeEnv] = {
val noconstraints = Some(emptyEnv)
def matches(tpe1: Type, tpe2: Type): Option[TypeEnv] = {
@@ -1232,7 +1232,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
} with typechecker.Duplicators {
private val (castfrom, castto) = casts.unzip
private object CastMap extends SubstTypeMap(castfrom.toList, castto.toList)
-
+
class BodyDuplicator(_context: Context) extends super.BodyDuplicator(_context) {
override def castType(tree: Tree, pt: Type): Tree = {
// log(" expected type: " + pt)
@@ -1249,9 +1249,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
ntree
}
}
-
+
protected override def newBodyDuplicator(context: Context) = new BodyDuplicator(context)
-
+
}
/** A tree symbol substituter that substitutes on type skolems.
@@ -1359,7 +1359,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
}
}
}
-
+
def reportError[T](body: =>T)(handler: TypeError => T): T =
try body
catch {
@@ -1396,7 +1396,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
else None
} else None
}
-
+
curTree = tree
tree match {
case Apply(Select(New(tpt), nme.CONSTRUCTOR), args) =>
@@ -1570,7 +1570,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
})
debuglog("created special overload tree " + t)
debuglog("created " + t)
- reportError {
+ reportError {
localTyper.typed(t)
} {
_ => super.transform(tree)
@@ -1629,9 +1629,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
super.transform(tree)
}
}
-
+
/** Duplicate the body of the given method `tree` to the new symbol `source`.
- *
+ *
* Knowing that the method can be invoked only in the `castmap` type environment,
* this method will insert casts for all the expressions of types mappend in the
* `castmap`.