Skip to content

Commit b635f21

Browse files
committed
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.
1 parent 6c172db commit b635f21

File tree

5 files changed

+13
-23
lines changed

5 files changed

+13
-23
lines changed

src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class TypeApplications(val self: Type) extends AnyVal {
286286
*/
287287
final def baseArgInfos(base: Symbol)(implicit ctx: Context): List[Type] =
288288
if (self derivesFrom base)
289-
base.typeParams map (param => self.member(param.name).info.argInfo(param))
289+
base.typeParams map (param => self.member(param.name).info.argInfo)
290290
else
291291
Nil
292292

@@ -311,7 +311,7 @@ class TypeApplications(val self: Type) extends AnyVal {
311311
/** The first type argument of the base type instance wrt `base` of this type */
312312
final def firstBaseArgInfo(base: Symbol)(implicit ctx: Context): Type = base.typeParams match {
313313
case param :: _ if self derivesFrom base =>
314-
self.member(param.name).info.argInfo(param)
314+
self.member(param.name).info.argInfo
315315
case _ =>
316316
NoType
317317
}
@@ -371,7 +371,7 @@ class TypeApplications(val self: Type) extends AnyVal {
371371
* Existential types in arguments are returned as TypeBounds instances.
372372
* @param interpolate See argInfo
373373
*/
374-
final def argInfos(interpolate: Boolean)(implicit ctx: Context): List[Type] = {
374+
final def argInfos(implicit ctx: Context): List[Type] = {
375375
var tparams: List[TypeSymbol] = null
376376
def recur(tp: Type, refineCount: Int): mutable.ListBuffer[Type] = tp.stripTypeVar match {
377377
case tp @ RefinedType(tycon, name) =>
@@ -381,7 +381,7 @@ class TypeApplications(val self: Type) extends AnyVal {
381381
if (tparams == null) tparams = tycon.typeParams
382382
if (buf.size < tparams.length) {
383383
val tparam = tparams(buf.size)
384-
if (name == tparam.name) buf += tp.refinedInfo.argInfo(tparam, interpolate)
384+
if (name == tparam.name) buf += tp.refinedInfo.argInfo
385385
else null
386386
} else null
387387
}
@@ -393,8 +393,6 @@ class TypeApplications(val self: Type) extends AnyVal {
393393
if (buf == null) Nil else buf.toList
394394
}
395395

396-
final def argInfos(implicit ctx: Context): List[Type] = argInfos(interpolate = true)
397-
398396
/** Argument types where existential types in arguments are disallowed */
399397
def argTypes(implicit ctx: Context) = argInfos mapConserve noBounds
400398

@@ -428,18 +426,10 @@ class TypeApplications(val self: Type) extends AnyVal {
428426
*
429427
* for a contravariant type-parameter becomes L.
430428
*/
431-
final def argInfo(tparam: Symbol, interpolate: Boolean = true)(implicit ctx: Context): Type = self match {
429+
final def argInfo(implicit ctx: Context): Type = self match {
432430
case self: TypeAlias => self.alias
433-
case TypeBounds(lo, hi) =>
434-
if (interpolate) {
435-
val v = tparam.variance
436-
if (v > 0 && (lo isRef defn.NothingClass)) hi
437-
else if (v < 0 && (hi isRef defn.AnyClass)) lo
438-
else self
439-
}
440-
else self
441-
case _ =>
442-
NoType
431+
case self: TypeBounds => self
432+
case _ => NoType
443433
}
444434

445435
/** The element type of a sequence or array */

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
140140

141141
private def firstTry(tp1: Type, tp2: Type): Boolean = tp2 match {
142142
case tp2: NamedType =>
143-
def compareNamed = {
143+
def compareNamed(tp1: Type, tp2: NamedType): Boolean = {
144144
implicit val ctx: Context = this.ctx
145145
tp2.info match {
146146
case info2: TypeAlias => firstTry(tp1, info2.alias)
147147
case _ => tp1 match {
148148
case tp1: NamedType =>
149149
tp1.info match {
150-
case info1: TypeAlias => firstTry(info1.alias, tp2)
150+
case info1: TypeAlias => compareNamed(info1.alias, tp2)
151151
case _ =>
152152
val sym1 = tp1.symbol
153153
(if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol))
@@ -171,7 +171,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
171171
}
172172
}
173173
}
174-
compareNamed
174+
compareNamed(tp1, tp2)
175175
case tp2: ProtoType =>
176176
isMatchedByProto(tp2, tp1)
177177
case tp2: BoundType =>

src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class TreePickler(pickler: TastyPickler) {
211211
case tpe: SkolemType =>
212212
pickleType(tpe.info)
213213
case tpe: RefinedType =>
214-
val args = tpe.argInfos(interpolate = false)
214+
val args = tpe.argInfos
215215
if (args.isEmpty) {
216216
writeByte(REFINEDtype)
217217
withLength {

src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
109109
}
110110
homogenize(tp) match {
111111
case tp: RefinedType =>
112-
val args = tp.argInfos(interpolate = false)
112+
val args = tp.argInfos
113113
if (args.nonEmpty) {
114114
val tycon = tp.unrefine
115115
val cls = tycon.typeSymbol

src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ class Namer { typer: Typer =>
848848
def apply(tp: Type): Type = {
849849
tp match {
850850
case tp: RefinedType =>
851-
val args = tp.argInfos(interpolate = false).mapconserve(this)
851+
val args = tp.argInfos.mapconserve(this)
852852
if (args.nonEmpty) {
853853
val tycon = tp.withoutArgs(args)
854854
val tparams = tycon.typeParams

0 commit comments

Comments
 (0)