@@ -20,8 +20,6 @@ trait TypeOps extends TastyKernel { self: TastyUniverse =>
20
20
import FlagSets ._
21
21
import SymbolOps ._
22
22
23
- def isTastyLazyType (rawInfo : Type ): Boolean = rawInfo.isInstanceOf [TastyLazyType ]
24
-
25
23
def mergeableParams (t : Type , u : Type ): Boolean =
26
24
t.typeParams.size == u.typeParams.size
27
25
@@ -52,7 +50,7 @@ trait TypeOps extends TastyKernel { self: TastyUniverse =>
52
50
mkPolyType(hi.typeParams, TypeBounds .bounded(nuLo, hi.resultType.upperBound))
53
51
}
54
52
else bounds match {
55
- case TypeBounds (LambdaEncoding (lo), LambdaEncoding (hi)) => TypeBounds .bounded(lo,hi)
53
+ case TypeBounds (lo : LambdaEncoding , hi : LambdaEncoding ) => TypeBounds .bounded(lo.toNested ,hi.toNested )
56
54
case _ => bounds
57
55
}
58
56
}
@@ -66,23 +64,21 @@ trait TypeOps extends TastyKernel { self: TastyUniverse =>
66
64
67
65
def boundedAppliedType (tycon : Type , args : List [Type ])(implicit ctx : Context ): Type = {
68
66
69
- def typeRefUncurried (tycon : Type , args : List [Type ]): Type = {
70
- if ( tycon. isInstanceOf [ TypeRef ] && tycon.typeArgs.nonEmpty) {
67
+ def typeRefUncurried (tycon : Type , args : List [Type ]): Type = tycon match {
68
+ case tycon : TypeRef if tycon.typeArgs.nonEmpty =>
71
69
attachCompiletimeOnly(owner =>
72
70
s " Unsupported Scala 3 curried type application $tycon[ ${args.mkString(" ," )}] in signature of $owner" )
73
71
errorType
74
- }
75
- else {
72
+ case _ =>
76
73
mkAppliedType(tycon, args)
77
- }
78
74
}
79
75
80
- if (args.exists(tpe => tpe.isInstanceOf [TypeBounds ] | tpe.isInstanceOf [PolyType ])) {
76
+ if (args.exists(tpe => tpe.isInstanceOf [TypeBounds ] | tpe.isInstanceOf [LambdaEncoding ])) {
81
77
val syms = mutable.ListBuffer .empty[Symbol ]
82
78
def bindWildcards (tpe : Type ) = tpe match {
83
- case tpe : TypeBounds => ctx.newWildcardSym(tpe).tap(syms += _).pipe(_.ref)
84
- case LambdaEncoding (lambda) => lambda
85
- case tpe => tpe
79
+ case tpe : TypeBounds => ctx.newWildcardSym(tpe).tap(syms += _).pipe(_.ref)
80
+ case tpe : LambdaEncoding => tpe.toNested
81
+ case tpe => tpe
86
82
}
87
83
val args1 = args.map(bindWildcards)
88
84
if (syms.isEmpty) typeRefUncurried(tycon, args1)
@@ -229,6 +225,15 @@ trait TypeOps extends TastyKernel { self: TastyUniverse =>
229
225
def apply (paramNames : List [N ], paramVariances : List [Variance ])(paramInfosExp : LT => List [PInfo ], resultTypeExp : LT => Type )(implicit ctx : Context ): LT
230
226
}
231
227
228
+ final class LambdaEncoding (override val typeParams : List [Symbol ], val resTpe : Type ) extends PolyType (typeParams, TypeBounds .addLower(resTpe)) {
229
+ def toNested : PolyType = resTpe match {
230
+ case _ : TypeBounds => this
231
+ case _ => mkPolyType(typeParams, resTpe)
232
+ }
233
+ }
234
+
235
+ def mkLambdaEncoding (typeParams : List [Symbol ], resTpe : Type ) = new LambdaEncoding (typeParams, resTpe)
236
+
232
237
object TypeParamLambda {
233
238
def apply (typeParams : List [Symbol ], ret : Type ): LambdaType = new TypeParamLambda (typeParams, ret)
234
239
}
@@ -275,11 +280,11 @@ trait TypeOps extends TastyKernel { self: TastyUniverse =>
275
280
*/
276
281
final def canonicalForm (implicit ctx : Context ): Type = {
277
282
val res = resType match {
278
- case LambdaEncoding (lambda) => lambda
279
- case res => res
283
+ case res : LambdaEncoding => res.toNested
284
+ case res => res
280
285
}
281
286
lambdaTpe match {
282
- case _ : HKTypeLambda => mkPolyType (typeParams, TypeBounds .addLower( res) )
287
+ case _ : HKTypeLambda => mkLambdaEncoding (typeParams, res)
283
288
case _ : TypeParamLambda => mkPolyType(typeParams, res)
284
289
}
285
290
}.tap(res => ctx.log(s """ |canonical form of ${lambdaTpe.productPrefix}:
0 commit comments