@@ -15,8 +15,35 @@ import StdNames.tpnme
15
15
import util .Positions .Position
16
16
import config .Printers ._
17
17
import collection .mutable
18
+ import dotty .tools .dotc .config .Config
18
19
import java .util .NoSuchElementException
19
20
21
+ object TypeApplicationsNewHK {
22
+ import TypeApplications ._
23
+
24
+ object TypeLambda {
25
+ def apply (argBindingFns : List [RefinedType => TypeBounds ],
26
+ bodyFn : RefinedType => Type )(implicit ctx : Context ): Type = {
27
+ val argNames = argBindingFns.indices.toList.map(tpnme.hkArg)
28
+ RefinedType .recursive(bodyFn, argNames, argBindingFns)
29
+ }
30
+
31
+ def unapply (tp : Type )(implicit ctx : Context ): Option [(List [TypeBounds ], Type )] = {
32
+ def decompose (t : Type , acc : List [TypeBounds ]): (List [TypeBounds ], Type ) = t match {
33
+ case t @ RefinedType (p, rname, rinfo : TypeBounds )
34
+ if rname.isHkArgName && rinfo.isBinding =>
35
+ decompose(p, rinfo.bounds :: acc)
36
+ case _ =>
37
+ (acc, t)
38
+ }
39
+ decompose(tp, Nil ) match {
40
+ case (Nil , _) => None
41
+ case x => Some (x)
42
+ }
43
+ }
44
+ }
45
+ }
46
+
20
47
object TypeApplications {
21
48
22
49
/** Assert type is not a TypeBounds instance and return it unchanged */
@@ -51,6 +78,14 @@ object TypeApplications {
51
78
* [v1 X1: B1, ..., vn Xn: Bn] -> T
52
79
* ==>
53
80
* ([X_i := this.$hk_i] T) { type v_i $hk_i: (new)B_i }
81
+ *
82
+ * [X] -> List[X]
83
+ *
84
+ * List { type List$A = this.$hk_0 } { type $hk_0 }
85
+ *
86
+ * [X] -> X
87
+ *
88
+ * mu(this) this.$hk_0 & { type $hk_0 }
54
89
*/
55
90
object TypeLambda {
56
91
def apply (variances : List [Int ],
0 commit comments