diff options
author | Paul Phillips <paulp@improving.org> | 2012-12-03 11:53:17 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-12-17 17:47:59 -0800 |
commit | 5f1e18b1cd8f76f40bb01d257ae3b81cb70e3e07 (patch) | |
tree | b2e850946257461fe20941b078da6be3f42273be /src/compiler | |
parent | e14917528e1c080a7f10785e21de36f3a7769718 (diff) | |
download | scala-5f1e18b1cd8f76f40bb01d257ae3b81cb70e3e07.tar.gz scala-5f1e18b1cd8f76f40bb01d257ae3b81cb70e3e07.tar.bz2 scala-5f1e18b1cd8f76f40bb01d257ae3b81cb70e3e07.zip |
Optimization in SpecializeTypes.
Avoid time traveling to find type parameters which will
never be there.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | 15 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 9 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 4e4c1b98ac..e3239313de 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -403,11 +403,16 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { case _ => false }) def specializedTypeVars(tpes: List[Type]): immutable.Set[Symbol] = { - val buf = Set.newBuilder[Symbol] - tpes foreach (tp => buf ++= specializedTypeVars(tp)) - buf.result + if (tpes.isEmpty) immutable.Set.empty else { + val buf = Set.newBuilder[Symbol] + tpes foreach (tp => buf ++= specializedTypeVars(tp)) + buf.result + } } - def specializedTypeVars(sym: Symbol): immutable.Set[Symbol] = enteringTyper(specializedTypeVars(sym.info)) + def specializedTypeVars(sym: Symbol): immutable.Set[Symbol] = ( + if (definitions.neverHasTypeParameters(sym)) immutable.Set.empty + else enteringTyper(specializedTypeVars(sym.info)) + ) /** Return the set of @specialized type variables mentioned by the given type. * It only counts type variables that appear: @@ -436,7 +441,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { case AnnotatedType(_, tp, _) => specializedTypeVars(tp) case TypeBounds(lo, hi) => specializedTypeVars(lo :: hi :: Nil) case RefinedType(parents, _) => parents flatMap specializedTypeVars toSet - case _ => Set() + case _ => immutable.Set.empty } /** Returns the type parameter in the specialized class `sClass` that corresponds to type parameter diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index a1c1b53cce..703c12038f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2716,13 +2716,8 @@ trait Typers extends Modes with Adaptations with Tags { val att = templ.attachments.get[CompoundTypeTreeOriginalAttachment].getOrElse(CompoundTypeTreeOriginalAttachment(Nil, Nil)) templ.removeAttachment[CompoundTypeTreeOriginalAttachment] templ updateAttachment att.copy(stats = stats1) - for (stat <- stats1 if stat.isDef) { - val member = stat.symbol - if (!(context.owner.ancestors forall - (bc => member.matchingSymbol(bc, context.owner.thisType) == NoSymbol))) { - member setFlag OVERRIDE - } - } + for (stat <- stats1 if stat.isDef && stat.symbol.isOverridingSymbol) + stat.symbol setFlag OVERRIDE } } |