@@ -5,16 +5,19 @@ package transform
5
5
import core .Annotations ._
6
6
import core .Contexts ._
7
7
import core .Phases ._
8
+ import core .Decorators .*
8
9
import core .Definitions
9
10
import core .Flags ._
10
11
import core .Names .Name
11
12
import core .Symbols ._
12
13
import core .TypeApplications .{EtaExpansion , TypeParamInfo }
13
- import core .TypeErasure .{erasedGlb , erasure , isGenericArrayElement }
14
+ import core .TypeErasure .{erasedGlb , erasure , fullErasure , isGenericArrayElement }
14
15
import core .Types ._
15
16
import core .classfile .ClassfileConstants
16
17
import SymUtils ._
17
18
import TypeUtils ._
19
+ import config .Printers .transforms
20
+ import reporting .trace
18
21
import java .lang .StringBuilder
19
22
20
23
import scala .collection .mutable .ListBuffer
@@ -130,15 +133,17 @@ object GenericSignatures {
130
133
else
131
134
Right (parent))
132
135
133
- def paramSig (param : LambdaParam ): Unit = {
134
- builder.append(sanitizeName(param.paramName))
136
+ def paramSig (param : TypeParamInfo ): Unit = {
137
+ builder.append(sanitizeName(param.paramName.lastPart ))
135
138
boundsSig(hiBounds(param.paramInfo.bounds))
136
139
}
137
140
138
- def polyParamSig (tparams : List [LambdaParam ]): Unit =
139
- if (tparams.nonEmpty) {
141
+ def polyParamSig (tparams : List [TypeParamInfo ]): Unit =
142
+ // remove type parameters that are upper-bounded by primitive types (including via a value class)
143
+ val tparams1 = tparams.filter(p => ! fullErasure(p.paramInfo.bounds.hi).isPrimitiveValueType)
144
+ if (tparams1.nonEmpty) {
140
145
builder.append('<' )
141
- tparams .foreach(paramSig)
146
+ tparams1 .foreach(paramSig)
142
147
builder.append('>' )
143
148
}
144
149
@@ -236,7 +241,11 @@ object GenericSignatures {
236
241
tp match {
237
242
238
243
case ref @ TypeParamRef (_ : PolyType , _) =>
239
- typeParamSig(ref.paramName.lastPart)
244
+ val erasedUnderlying = fullErasure(ref.underlying.bounds.hi)
245
+ // don't emit type param name if the param is upper-bounded by a primitive type (including via a value class)
246
+ if erasedUnderlying.isPrimitiveValueType then
247
+ jsig(erasedUnderlying, toplevel, primitiveOK)
248
+ else typeParamSig(ref.paramName.lastPart)
240
249
241
250
case defn.ArrayOf (elemtp) =>
242
251
if (isGenericArrayElement(elemtp, isScala2 = false ))
@@ -263,11 +272,11 @@ object GenericSignatures {
263
272
else if (sym == defn.NullClass )
264
273
builder.append(" Lscala/runtime/Null$;" )
265
274
else if (sym.isPrimitiveValueClass)
266
- if (! primitiveOK) jsig(defn. ObjectType )
275
+ if (! primitiveOK) ( )
267
276
else if (sym == defn.UnitClass ) jsig(defn.BoxedUnitClass .typeRef)
268
277
else builder.append(defn.typeTag(sym.info))
269
278
else if (ValueClasses .isDerivedValueClass(sym)) {
270
- val erasedUnderlying = core. TypeErasure . fullErasure(tp)
279
+ val erasedUnderlying = fullErasure(tp)
271
280
if (erasedUnderlying.isPrimitiveValueType && ! primitiveOK)
272
281
classSig(sym, pre, args)
273
282
else
@@ -334,15 +343,6 @@ object GenericSignatures {
334
343
jsig(repr, primitiveOK = primitiveOK)
335
344
336
345
case ci : ClassInfo =>
337
- def polyParamSig (tparams : List [TypeParamInfo ]): Unit =
338
- if (tparams.nonEmpty) {
339
- builder.append('<' )
340
- tparams.foreach { tp =>
341
- builder.append(sanitizeName(tp.paramName.lastPart))
342
- boundsSig(hiBounds(tp.paramInfo.bounds))
343
- }
344
- builder.append('>' )
345
- }
346
346
val tParams = tp.typeParams
347
347
if (toplevel) polyParamSig(tParams)
348
348
superSig(ci.typeSymbol, ci.parents)
0 commit comments