@@ -11,24 +11,27 @@ trait JavadocAnchorCreator:
11
11
import self .q .reflect ._
12
12
13
13
private val javadocPrimitivesMap = Map (
14
- " scala.Int " -> " int" ,
15
- " scala.Float " -> " float" ,
16
- " scala.Double " -> " double" ,
17
- " scala.Long " -> " long" ,
18
- " scala.Byte " -> " byte" ,
19
- " scala.Boolean " -> " boolean" ,
20
- " scala.Char " -> " char" ,
21
- " scala.Short " -> " short" ,
22
- " <special-ops>.<FromJavaObject> " -> " java.lang.Object"
14
+ defn. IntClass -> " int" ,
15
+ defn. FloatClass -> " float" ,
16
+ defn. DoubleClass -> " double" ,
17
+ defn. LongClass -> " long" ,
18
+ defn. ByteClass -> " byte" ,
19
+ defn. BooleanClass -> " boolean" ,
20
+ defn. CharClass -> " char" ,
21
+ defn. ShortClass -> " short" ,
22
+ defn. ObjectClass -> " java.lang.Object"
23
23
)
24
24
25
- private def transformPrimitiveType (s : String ): String = javadocPrimitivesMap.getOrElse(s, s)
25
+ private def transformPrimitiveType (tpe : TypeRepr ): String = tpe.classSymbol
26
+ .flatMap(javadocPrimitivesMap.get)
27
+ .filter(_ => ! tpe.typeSymbol.isTypeParam)
28
+ .getOrElse(tpe.show)
26
29
27
30
private def transformType (tpe : TypeRepr ): String = tpe.simplified match {
28
- case AppliedType (tpe, typeList) if tpe.show == " scala.Array " => transformType(typeList.head) + " :A"
29
- case AppliedType (tpe, typeList) if tpe.show == " scala.<repeated> " => transformType(typeList.head) + " ..."
30
- case AppliedType (tpe, typeList) => transformPrimitiveType(tpe.show )
31
- case other => transformPrimitiveType(other.show )
31
+ case AppliedType (tpe, typeList) if tpe.classSymbol.fold( false )(_ == defn. ArrayClass ) => transformType(typeList.head) + " :A"
32
+ case AppliedType (tpe, typeList) if tpe.classSymbol.fold( false )(_ == defn. RepeatedParamClass ) => transformType(typeList.head) + " ..."
33
+ case AppliedType (tpe, typeList) => transformPrimitiveType(tpe)
34
+ case other => transformPrimitiveType(other)
32
35
}
33
36
34
37
def getJavadocType (s : TypeRepr ) = transformType(s)
0 commit comments