Skip to content

Commit 8037761

Browse files
committed
Tastydoc: update remaining tasty.reflect usages
1 parent 73adbcc commit 8037761

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

tastydoc/src/dotty/tastydoc/TastyTypeConverter.scala

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,33 @@ trait TastyTypeConverter {
7070
}
7171
case _ => throw Exception("Match error in AppliedType. This should not happen, please open an issue. " + tp)
7272
}
73-
case TypeRef(qual, typeName) =>
73+
case tp @ 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)
77-
case _ => throw Exception("Match error in TypeRef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual))
77+
case _ if tp.typeSymbol.exists =>
78+
tp.typeSymbol match {
79+
// NOTE: Only TypeRefs can reference ClassDefSymbols
80+
case sym if sym.isClassDef => //Need to be split because these types have their own file
81+
convertTypeOrBoundsToReference(reflect)(qual) match {
82+
case TypeReference(label, link, xs, _) => TypeReference(sym.name, link + "/" + label, xs, true)
83+
case EmptyReference if sym.name == "<root>" | sym.name == "_root_" => EmptyReference
84+
case EmptyReference => TypeReference(sym.name, "", Nil, true)
85+
case _ => throw Exception("Match error in SymRef/TypeOrBounds/ClassDef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual))
86+
}
87+
88+
// NOTE: This branch handles packages, which are now TypeRefs
89+
case sym if sym.isTerm || sym.isTypeDef =>
90+
convertTypeOrBoundsToReference(reflect)(qual) match {
91+
case TypeReference(label, link, xs, _) => TypeReference(sym.name, link + "/" + label, xs)
92+
case EmptyReference if sym.name == "<root>" | sym.name == "_root_" => EmptyReference
93+
case EmptyReference => TypeReference(sym.name, "", Nil)
94+
case _ => throw Exception("Match error in SymRef/TypeOrBounds/Other. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual))
95+
}
96+
case sym => throw Exception("Match error in SymRef. This should not happen, please open an issue. " + sym)
97+
}
98+
case _ =>
99+
throw Exception("Match error in TypeRef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual))
78100
}
79101
case TermRef(qual, typeName) =>
80102
convertTypeOrBoundsToReference(reflect)(qual) match {
@@ -85,27 +107,9 @@ trait TastyTypeConverter {
85107

86108
// NOTE: old SymRefs are now either TypeRefs or TermRefs - the logic here needs to be moved into above branches
87109
// NOTE: _.symbol on *Ref returns its symbol
88-
case SymRef(symbol, typeOrBounds) => symbol match {
89-
// NOTE: Only TypeRefs can reference ClassDefSymbols
90-
case reflect.IsClassDefSymbol(_) => //Need to be split because these types have their own file
91-
convertTypeOrBoundsToReference(reflect)(typeOrBounds) match {
92-
case TypeReference(label, link, xs, _) => TypeReference(symbol.name, link + "/" + label, xs, true)
93-
case EmptyReference if symbol.name == "<root>" | symbol.name == "_root_" => EmptyReference
94-
case EmptyReference => TypeReference(symbol.name, "", Nil, true)
95-
case _ => throw Exception("Match error in SymRef/TypeOrBounds/ClassDef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(typeOrBounds))
96-
}
97-
98-
// NOTE: This branch handles packages, which are now TypeRefs
99-
case reflect.IsTermSymbol(_) | reflect.IsTypeDefSymbol(_) =>
100-
convertTypeOrBoundsToReference(reflect)(typeOrBounds) match {
101-
case TypeReference(label, link, xs, _) => TypeReference(symbol.name, link + "/" + label, xs)
102-
case EmptyReference if symbol.name == "<root>" | symbol.name == "_root_" => EmptyReference
103-
case EmptyReference => TypeReference(symbol.name, "", Nil)
104-
case _ => throw Exception("Match error in SymRef/TypeOrBounds/Other. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(typeOrBounds))
105-
}
106-
case _ => throw Exception("Match error in SymRef. This should not happen, please open an issue. " + symbol)
107-
}
108-
case _ => throw Exception("No match for type in conversion to Reference. This should not happen, please open an issue. " + tp)
110+
// case SymRef(symbol, typeOrBounds) => symbol match {
111+
// }
112+
// case _ => throw Exception("No match for type in conversion to Reference. This should not happen, please open an issue. " + tp)
109113
}
110114

111115
inner(tp)

0 commit comments

Comments
 (0)