@@ -18,7 +18,7 @@ trait InkuireSupport:
18
18
private given qctx .type = qctx
19
19
20
20
private def paramsForClass (classDef : ClassDef , vars : Set [String ]): Seq [Inkuire .Variance ] =
21
- classDef.getTypeParams.map(mkTypeArgumentInkuire(_, vars) )
21
+ classDef.getTypeParams.map(mkTypeArgumentInkuire)
22
22
23
23
given TreeSyntaxInkuire : AnyRef with
24
24
extension (tpeTree : Tree )
@@ -58,19 +58,28 @@ trait InkuireSupport:
58
58
extension (tpe : TypeRepr )
59
59
def asInkuire (vars : Set [String ]): Inkuire .Type = inner(tpe, vars)
60
60
61
- def mkTypeArgumentInkuire (argument : TypeDef , vars : Set [String ] = Set .empty): Inkuire .Variance =
61
+ def mkTypeArgumentInkuire (argument : TypeDef ): Inkuire .Variance =
62
+ // TODO [Inkuire] Type bounds (other than just HKTs)
62
63
val name = argument.symbol.normalizedName
63
64
val normalizedName = if name.matches(" _\\ $\\ d*" ) then " _" else name
65
+ val params = 1 .to(typeVariableDeclarationParamsNo(argument)).map(_ => Inkuire .Type .StarProjection )
64
66
val t = Inkuire .Type (
65
67
name = Inkuire .TypeName (normalizedName),
66
68
itid = argument.symbol.itid,
67
69
isVariable = true ,
68
- params = Seq .empty // TODO [ Inkuire] Type Lambdas
70
+ params = params.map( Inkuire . Invariance (_))
69
71
)
70
72
if argument.symbol.flags.is(Flags .Covariant ) then Inkuire .Covariance (t)
71
73
else if argument.symbol.flags.is(Flags .Contravariant ) then Inkuire .Contravariance (t)
72
74
else Inkuire .Invariance (t)
73
75
76
+ def typeVariableDeclarationParamsNo (argument : TypeDef ): Int =
77
+ argument.rhs match
78
+ case t : TypeTree => t.tpe match
79
+ case TypeBounds (_, TypeLambda (names, _, _)) => names.size
80
+ case _ => 0
81
+ case _ => 0
82
+
74
83
private def isRepeatedAnnotation (term : Term ) =
75
84
term.tpe match
76
85
case t : TypeRef => t.name == " Repeated" && t.qualifier.match
0 commit comments