@@ -7,7 +7,7 @@ import dotty.tastydoc.references._
77trait TastyTypeConverter {
88
99 def convertTypeOrBoundsToReference (reflect : Reflection )(typeOrBounds : reflect.TypeOrBounds ): Reference = {
10- import reflect ._
10+ import reflect .{ given , _ }
1111
1212 def anyOrNothing (reference : Reference ): Boolean = reference match {
1313 case TypeReference (" Any" , " /scala" , _, _) => true
@@ -30,18 +30,18 @@ trait TastyTypeConverter {
3030 }
3131
3232 def convertTypeToReference (reflect : Reflection )(tp : reflect.Type ): Reference = {
33- import reflect ._
33+ import reflect .{ given , _ }
3434
3535 // Inner method to avoid passing the reflection each time
3636 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) =>
4545 val tuple = convertTypeOrBoundsToReference(reflect)(info) match {
4646 case r if (info match {case reflect.IsTypeBounds (info) => true case _ => false }) => (" type" , name, r)
4747 case r@ TypeReference (_, _, _, _) => (" val" , name, r)
@@ -53,7 +53,7 @@ trait TastyTypeConverter {
5353 RefinedReference (p, ls:+ tuple)
5454 case t => RefinedReference (t, List (tuple))
5555 }
56- case reflect. Type . IsAppliedType (reflect. Type . AppliedType (tpe, typeOrBoundsList) ) =>
56+ case AppliedType (tpe, typeOrBoundsList) =>
5757 inner(tpe) match {
5858 case TypeReference (label, link, _, hasOwnFile) =>
5959 if (link == " /scala" ){
@@ -70,26 +70,32 @@ trait TastyTypeConverter {
7070 }
7171 case _ => throw Exception (" Match error in AppliedType. This should not happen, please open an issue. " + tp)
7272 }
73- case reflect. Type . IsTypeRef (reflect. Type . TypeRef (typeName, qual) ) =>
73+ case TypeRef (qual, typeName ) =>
7474 convertTypeOrBoundsToReference(reflect)(qual) match {
7575 case TypeReference (label, link, xs, _) => TypeReference (typeName, link + " /" + label, xs, true )
7676 case EmptyReference => TypeReference (typeName, " " , Nil , true )
7777 case _ => throw Exception (" Match error in TypeRef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual))
7878 }
79- case reflect. Type . IsTermRef (reflect. Type . TermRef (typeName, qual) ) =>
79+ case TermRef (qual, typeName ) =>
8080 convertTypeOrBoundsToReference(reflect)(qual) match {
8181 case TypeReference (label, link, xs, _) => TypeReference (typeName + " $" , link + " /" + label, xs)
8282 case EmptyReference => TypeReference (typeName, " " , Nil )
8383 case _ => throw Exception (" Match error in TermRef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual))
8484 }
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
8690 case reflect.IsClassDefSymbol (_) => // Need to be split because these types have their own file
8791 convertTypeOrBoundsToReference(reflect)(typeOrBounds) match {
8892 case TypeReference (label, link, xs, _) => TypeReference (symbol.name, link + " /" + label, xs, true )
8993 case EmptyReference if symbol.name == " <root>" | symbol.name == " _root_" => EmptyReference
9094 case EmptyReference => TypeReference (symbol.name, " " , Nil , true )
9195 case _ => throw Exception (" Match error in SymRef/TypeOrBounds/ClassDef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(typeOrBounds))
9296 }
97+
98+ // NOTE: This branch handles packages, which are now TypeRefs
9399 case reflect.IsTermSymbol (_) | reflect.IsTypeDefSymbol (_) =>
94100 convertTypeOrBoundsToReference(reflect)(typeOrBounds) match {
95101 case TypeReference (label, link, xs, _) => TypeReference (symbol.name, link + " /" + label, xs)
0 commit comments