diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2010-05-12 16:35:47 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2010-05-12 16:35:47 +0000 |
commit | 0ed53d4d686db74a54315cd5ccf79bda3690b036 (patch) | |
tree | 8738ca84ba2bdaaafa992d431e6c12fc03086bbe /src | |
parent | ba1c91710f44862ec5b9d05307ddf04884bc23ac (diff) | |
download | scala-0ed53d4d686db74a54315cd5ccf79bda3690b036.tar.gz scala-0ed53d4d686db74a54315cd5ccf79bda3690b036.tar.bz2 scala-0ed53d4d686db74a54315cd5ccf79bda3690b036.zip |
Closes #3424, double definition when overriding...
Closes #3424, double definition when overriding a generic method with
specialized types, inherited from a specialized class. no review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 0fb5065248..293494b919 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -54,7 +54,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { } /** Reduce the given environment to contain mappings only for type variables in tps. */ - def reduce(env: TypeEnv, tps: immutable.Set[Symbol]): TypeEnv = { + def restrict(env: TypeEnv, tps: immutable.Set[Symbol]): TypeEnv = { env filter { kv => tps.contains(kv._1)} } @@ -681,8 +681,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { if (settings.debug.value) log("\toverriding pairs: " + overridden.fullName + ": " + overridden.info + " overriden by " + overriding.fullName + ": " + overriding.info) - if (overriding.owner == clazz && !specializedTypeVars(overridden.info).isEmpty) { - if (settings.debug.value) log("\t\tspecializedTVars: " + specializedTypeVars(overridden.info)) + val stvars = specializedTypeVars(overridden.info) + if (overriding.owner == clazz && !stvars.isEmpty) { + if (settings.debug.value) log("\t\tspecializedTVars: " + stvars) val env = unify(overridden.info, overriding.info, emptyEnv) if (settings.debug.value) log("\t\tenv: " + env + "isValid: " @@ -690,14 +691,14 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { + " looking for: " + specializedName(overridden, env) + " in:\n" + atPhase(phase.next)(overridden.owner.info.decls) + "found: " + atPhase(phase.next)(overridden.owner.info.decl(specializedName(overridden, env)))) - if (!env.isEmpty + if (!TypeEnv.restrict(env, stvars).isEmpty && TypeEnv.isValid(env, overridden) && atPhase(phase.next)(overridden.owner.info.decl(specializedName(overridden, env))) != NoSymbol) { log("Added specialized overload for " + overriding.fullName + " in env: " + env) val om = specializedOverload(clazz, overridden, env) typeEnv(om) = env concreteSpecMethods += overriding - if (!overriding.isDeferred) { + if (!overriding.isDeferred) { // concrete method // if the override is a normalized member, 'om' gets the implementation from // its original target, and adds the environment of the normalized member (that is, // any specialized /method/ type parameter bindings) @@ -708,9 +709,8 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { case _ => SpecialOverride(overriding) } info(overriding) = Forward(om) - om setPos overriding.pos // set the position of the concrete, overriding member - } else { - // abstract override + om setPos overriding.pos + } else { // abstract override if (settings.debug.value) log("abstract override " + overriding.fullName + " with specialized " + om.fullName) info(om) = Forward(overriding) } @@ -1290,11 +1290,14 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { } } if (hasSpecializedFields) { + import definitions.BooleanClass + + val isSpecializedInstance = cls.hasFlag(SPECIALIZED) || cls.info.parents.exists(_.typeSymbol.hasFlag(SPECIALIZED)) val sym = cls.newMethod(nme.SPECIALIZED_INSTANCE, cls.pos) - .setInfo(MethodType(Nil, definitions.BooleanClass.tpe)) + .setInfo(MethodType(Nil, BooleanClass.tpe)) cls.info.decls.enter(sym) mbrs += atPos(sym.pos) { - DefDef(sym, Literal(cls.hasFlag(SPECIALIZED)).setType(sym.tpe.finalResultType)).setType(NoType) + DefDef(sym, Literal(isSpecializedInstance).setType(BooleanClass.tpe)).setType(NoType) } } mbrs.toList |