@@ -7,7 +7,7 @@ import dotty.tastydoc.references._
7
7
trait TastyTypeConverter {
8
8
9
9
def convertTypeOrBoundsToReference (reflect : Reflection )(typeOrBounds : reflect.TypeOrBounds ): Reference = {
10
- import reflect ._
10
+ import reflect .{ given , _ }
11
11
12
12
def anyOrNothing (reference : Reference ): Boolean = reference match {
13
13
case TypeReference (" Any" , " /scala" , _, _) => true
@@ -30,18 +30,18 @@ trait TastyTypeConverter {
30
30
}
31
31
32
32
def convertTypeToReference (reflect : Reflection )(tp : reflect.Type ): Reference = {
33
- import reflect ._
33
+ import reflect .{ given , _ }
34
34
35
35
// Inner method to avoid passing the reflection each time
36
36
def inner (tp : reflect.Type ): Reference = tp match {
37
- case reflect. Type . IsOrType (reflect. Type . OrType (left, right) ) => OrTypeReference (inner(left), inner(right))
38
- case reflect. Type . IsAndType (reflect. Type . AndType (left, right) ) => AndTypeReference (inner(left), inner(right))
39
- case reflect. Type . IsByNameType (reflect. Type . ByNameType (tpe) ) => ByNameReference (inner(tpe))
40
- case reflect. Type . IsConstantType (reflect. Type . ConstantType (constant) ) => ConstantReference (constant.value.toString)
41
- case reflect. Type . IsThisType (reflect. Type . ThisType (tpe) ) => inner(tpe)
42
- case reflect. Type . IsAnnotatedType (reflect. Type . AnnotatedType (tpe, _) ) => inner(tpe)
43
- case reflect. Type . IsTypeLambda (reflect. Type . TypeLambda (paramNames, paramTypes, resType)) => ConstantReference (tp.show(implicitly[reflect. Context ].withoutColors) ) // TOFIX
44
- case reflect. Type . IsRefinement (reflect. Type . Refinement (parent, name, info) ) =>
37
+ case OrType (left, right) => OrTypeReference (inner(left), inner(right))
38
+ case AndType (left, right) => AndTypeReference (inner(left), inner(right))
39
+ case ByNameType (tpe) => ByNameReference (inner(tpe))
40
+ case ConstantType (constant) => ConstantReference (constant.value.toString)
41
+ case ThisType (tpe) => inner(tpe)
42
+ case AnnotatedType (tpe, _) => inner(tpe)
43
+ case TypeLambda (paramNames, paramTypes, resType) => ConstantReference (tp.show) // TOFIX
44
+ case Refinement (parent, name, info) =>
45
45
val tuple = convertTypeOrBoundsToReference(reflect)(info) match {
46
46
case r if (info match {case reflect.IsTypeBounds (info) => true case _ => false }) => (" type" , name, r)
47
47
case r@ TypeReference (_, _, _, _) => (" val" , name, r)
@@ -53,7 +53,7 @@ trait TastyTypeConverter {
53
53
RefinedReference (p, ls:+ tuple)
54
54
case t => RefinedReference (t, List (tuple))
55
55
}
56
- case reflect. Type . IsAppliedType (reflect. Type . AppliedType (tpe, typeOrBoundsList) ) =>
56
+ case AppliedType (tpe, typeOrBoundsList) =>
57
57
inner(tpe) match {
58
58
case TypeReference (label, link, _, hasOwnFile) =>
59
59
if (link == " /scala" ){
@@ -70,26 +70,32 @@ trait TastyTypeConverter {
70
70
}
71
71
case _ => throw Exception (" Match error in AppliedType. This should not happen, please open an issue. " + tp)
72
72
}
73
- case reflect. Type . IsTypeRef (reflect. Type . TypeRef (typeName, qual) ) =>
73
+ case TypeRef (qual, typeName ) =>
74
74
convertTypeOrBoundsToReference(reflect)(qual) match {
75
75
case TypeReference (label, link, xs, _) => TypeReference (typeName, link + " /" + label, xs, true )
76
76
case EmptyReference => TypeReference (typeName, " " , Nil , true )
77
77
case _ => throw Exception (" Match error in TypeRef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual))
78
78
}
79
- case reflect. Type . IsTermRef (reflect. Type . TermRef (typeName, qual) ) =>
79
+ case TermRef (qual, typeName ) =>
80
80
convertTypeOrBoundsToReference(reflect)(qual) match {
81
81
case TypeReference (label, link, xs, _) => TypeReference (typeName + " $" , link + " /" + label, xs)
82
82
case EmptyReference => TypeReference (typeName, " " , Nil )
83
83
case _ => throw Exception (" Match error in TermRef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual))
84
84
}
85
- case reflect.Type .IsSymRef (reflect.Type .SymRef (symbol, typeOrBounds)) => symbol match {
85
+
86
+ // NOTE: old SymRefs are now either TypeRefs or TermRefs - the logic here needs to be moved into above branches
87
+ // NOTE: _.symbol on *Ref returns its symbol
88
+ case SymRef (symbol, typeOrBounds) => symbol match {
89
+ // NOTE: Only TypeRefs can reference ClassDefSymbols
86
90
case reflect.IsClassDefSymbol (_) => // Need to be split because these types have their own file
87
91
convertTypeOrBoundsToReference(reflect)(typeOrBounds) match {
88
92
case TypeReference (label, link, xs, _) => TypeReference (symbol.name, link + " /" + label, xs, true )
89
93
case EmptyReference if symbol.name == " <root>" | symbol.name == " _root_" => EmptyReference
90
94
case EmptyReference => TypeReference (symbol.name, " " , Nil , true )
91
95
case _ => throw Exception (" Match error in SymRef/TypeOrBounds/ClassDef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(typeOrBounds))
92
96
}
97
+
98
+ // NOTE: This branch handles packages, which are now TypeRefs
93
99
case reflect.IsTermSymbol (_) | reflect.IsTypeDefSymbol (_) =>
94
100
convertTypeOrBoundsToReference(reflect)(typeOrBounds) match {
95
101
case TypeReference (label, link, xs, _) => TypeReference (symbol.name, link + " /" + label, xs)
0 commit comments