diff options
author | Martin Odersky <odersky@gmail.com> | 2015-11-29 19:11:18 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2015-11-30 17:31:32 +0100 |
commit | e77428eb0bf0d9f68f4055d686cbabe111a4afdf (patch) | |
tree | 16c8fcfc8d8ebaf0ed3840aaa2a334fd3eab029b /src | |
parent | 4ca8744da021642d9f943224950482b3344cf089 (diff) | |
download | dotty-e77428eb0bf0d9f68f4055d686cbabe111a4afdf.tar.gz dotty-e77428eb0bf0d9f68f4055d686cbabe111a4afdf.tar.bz2 dotty-e77428eb0bf0d9f68f4055d686cbabe111a4afdf.zip |
Drop argumnt interpolation.
It turns out it's not needed because now all type arguments are
expressed as aliases. Interestingly dropping this feature shaved
20% off the time off junit tests. Which seems to indicate that the
handling of type application is really performance critical.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 24 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreePickler.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/printing/RefinedPrinter.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 2 |
5 files changed, 13 insertions, 23 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index be070dace..a023322ac 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -286,7 +286,7 @@ class TypeApplications(val self: Type) extends AnyVal { */ final def baseArgInfos(base: Symbol)(implicit ctx: Context): List[Type] = if (self derivesFrom base) - base.typeParams map (param => self.member(param.name).info.argInfo(param)) + base.typeParams map (param => self.member(param.name).info.argInfo) else Nil @@ -311,7 +311,7 @@ class TypeApplications(val self: Type) extends AnyVal { /** The first type argument of the base type instance wrt `base` of this type */ final def firstBaseArgInfo(base: Symbol)(implicit ctx: Context): Type = base.typeParams match { case param :: _ if self derivesFrom base => - self.member(param.name).info.argInfo(param) + self.member(param.name).info.argInfo case _ => NoType } @@ -371,7 +371,7 @@ class TypeApplications(val self: Type) extends AnyVal { * Existential types in arguments are returned as TypeBounds instances. * @param interpolate See argInfo */ - final def argInfos(interpolate: Boolean)(implicit ctx: Context): List[Type] = { + final def argInfos(implicit ctx: Context): List[Type] = { var tparams: List[TypeSymbol] = null def recur(tp: Type, refineCount: Int): mutable.ListBuffer[Type] = tp.stripTypeVar match { case tp @ RefinedType(tycon, name) => @@ -381,7 +381,7 @@ class TypeApplications(val self: Type) extends AnyVal { if (tparams == null) tparams = tycon.typeParams if (buf.size < tparams.length) { val tparam = tparams(buf.size) - if (name == tparam.name) buf += tp.refinedInfo.argInfo(tparam, interpolate) + if (name == tparam.name) buf += tp.refinedInfo.argInfo else null } else null } @@ -393,8 +393,6 @@ class TypeApplications(val self: Type) extends AnyVal { if (buf == null) Nil else buf.toList } - final def argInfos(implicit ctx: Context): List[Type] = argInfos(interpolate = true) - /** Argument types where existential types in arguments are disallowed */ def argTypes(implicit ctx: Context) = argInfos mapConserve noBounds @@ -428,18 +426,10 @@ class TypeApplications(val self: Type) extends AnyVal { * * for a contravariant type-parameter becomes L. */ - final def argInfo(tparam: Symbol, interpolate: Boolean = true)(implicit ctx: Context): Type = self match { + final def argInfo(implicit ctx: Context): Type = self match { case self: TypeAlias => self.alias - case TypeBounds(lo, hi) => - if (interpolate) { - val v = tparam.variance - if (v > 0 && (lo isRef defn.NothingClass)) hi - else if (v < 0 && (hi isRef defn.AnyClass)) lo - else self - } - else self - case _ => - NoType + case self: TypeBounds => self + case _ => NoType } /** The element type of a sequence or array */ diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index d94e24469..d0abe86a7 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -140,14 +140,14 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { private def firstTry(tp1: Type, tp2: Type): Boolean = tp2 match { case tp2: NamedType => - def compareNamed = { + def compareNamed(tp1: Type, tp2: NamedType): Boolean = { implicit val ctx: Context = this.ctx tp2.info match { case info2: TypeAlias => firstTry(tp1, info2.alias) case _ => tp1 match { case tp1: NamedType => tp1.info match { - case info1: TypeAlias => firstTry(info1.alias, tp2) + case info1: TypeAlias => compareNamed(info1.alias, tp2) case _ => val sym1 = tp1.symbol (if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol)) @@ -171,7 +171,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { } } } - compareNamed + compareNamed(tp1, tp2) case tp2: ProtoType => isMatchedByProto(tp2, tp1) case tp2: BoundType => diff --git a/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/src/dotty/tools/dotc/core/tasty/TreePickler.scala index d98ebb4d1..c0136538b 100644 --- a/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -211,7 +211,7 @@ class TreePickler(pickler: TastyPickler) { case tpe: SkolemType => pickleType(tpe.info) case tpe: RefinedType => - val args = tpe.argInfos(interpolate = false) + val args = tpe.argInfos if (args.isEmpty) { writeByte(REFINEDtype) withLength { diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 7065976dc..06fe0c9ef 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -109,7 +109,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { } homogenize(tp) match { case tp: RefinedType => - val args = tp.argInfos(interpolate = false) + val args = tp.argInfos if (args.nonEmpty) { val tycon = tp.unrefine val cls = tycon.typeSymbol diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 999efff09..5eebdbad1 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -848,7 +848,7 @@ class Namer { typer: Typer => def apply(tp: Type): Type = { tp match { case tp: RefinedType => - val args = tp.argInfos(interpolate = false).mapconserve(this) + val args = tp.argInfos.mapconserve(this) if (args.nonEmpty) { val tycon = tp.withoutArgs(args) val tparams = tycon.typeParams |