@@ -483,25 +483,7 @@ class TypeApplications(val self: Type) extends AnyVal {
483
483
* 3. If `T` is a polytype, instantiate it to `U1,...,Un`.
484
484
*/
485
485
final def appliedTo (args : List [Type ])(implicit ctx : Context ): Type = /* >|>*/ track(" appliedTo" ) /* <|<*/ {
486
- if (args.isEmpty || ctx.erasedTypes) self
487
- else self.stripTypeVar match { // TODO investigate why we can't do safeDealias here
488
- case self : GenericType if ! args.exists(_.isInstanceOf [TypeBounds ]) =>
489
- self.instantiate(args)
490
- case EtaExpansion (self1) =>
491
- self1.appliedTo(args)
492
- case self1 : WildcardType =>
493
- self1
494
- case _ =>
495
- self.appliedTo(args, typeParams)
496
- }
497
- }
498
-
499
- /** Encode application `T[U1, ..., Un]` without simplifications, where
500
- * @param self = `T`
501
- * @param args = `U1, ..., Un`
502
- * @param tparams are assumed to be the type parameters of `T`.
503
- */
504
- final def appliedTo (args : List [Type ], typParams : List [TypeParamInfo ])(implicit ctx : Context ): Type = {
486
+ val typParams = self.typeParams
505
487
def matchParams (t : Type , tparams : List [TypeParamInfo ], args : List [Type ])(implicit ctx : Context ): Type = args match {
506
488
case arg :: args1 =>
507
489
try {
@@ -515,8 +497,8 @@ class TypeApplications(val self: Type) extends AnyVal {
515
497
}
516
498
case nil => t
517
499
}
518
- assert (args.nonEmpty)
519
- self.stripTypeVar.safeDealias match {
500
+ if (args.isEmpty || ctx.erasedTypes) self
501
+ else self.stripTypeVar.safeDealias match {
520
502
case self : TypeLambda =>
521
503
if (! args.exists(_.isInstanceOf [TypeBounds ])) self.instantiate(args)
522
504
else {
@@ -525,14 +507,18 @@ class TypeApplications(val self: Type) extends AnyVal {
525
507
if (reducer.allReplaced) reduced
526
508
else HKApply (self, args)
527
509
}
510
+ case self : PolyType =>
511
+ self.instantiate(args)
528
512
case self : AndOrType =>
529
513
self.derivedAndOrType(self.tp1.appliedTo(args), self.tp2.appliedTo(args))
530
514
case self : TypeAlias =>
531
515
self.derivedTypeAlias(self.alias.appliedTo(args))
532
516
case self : TypeBounds =>
533
517
self.derivedTypeBounds(self.lo, self.hi.appliedTo(args))
534
518
case self : LazyRef =>
535
- LazyRef (() => self.ref.appliedTo(args, typParams))
519
+ LazyRef (() => self.ref.appliedTo(args))
520
+ case self : WildcardType =>
521
+ self
536
522
case self : TypeRef if self.symbol == defn.NothingClass =>
537
523
self
538
524
case _ if typParams.isEmpty || typParams.head.isInstanceOf [LambdaParam ] =>
@@ -557,7 +543,7 @@ class TypeApplications(val self: Type) extends AnyVal {
557
543
case self : TypeRef if ! self.symbol.isClass && self.symbol.isCompleting =>
558
544
HKApply (self, args)
559
545
case _ =>
560
- appliedTo(args, typeParams )
546
+ appliedTo(args)
561
547
}
562
548
563
549
/** Turn this type, which is used as an argument for
0 commit comments