Skip to content

Commit f581090

Browse files
authored
Merge pull request #13047 from xuwei-k/fix-10834
fix constructors Java generic signatures
2 parents 6631730 + d3aa042 commit f581090

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ object GenericSignatures {
291291

292292
case PolyType(tparams, mtpe: MethodType) =>
293293
assert(tparams.nonEmpty)
294-
if (toplevel) polyParamSig(tparams)
294+
if (toplevel && !sym0.isConstructor) polyParamSig(tparams)
295295
jsig(mtpe)
296296

297297
// Nullary polymorphic method
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
0
2+
3+
public A1(X)
4+
0
5+
6+
public A2(java.lang.Object)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class A1[X](val x: X)
2+
class A2[F[_]](val x: F[String])
3+
4+
object Test {
5+
def test(clazz: Class[?]): Unit = {
6+
val List(constructor) = clazz.getConstructors().toList
7+
println(constructor.getTypeParameters().length)
8+
println(constructor.getTypeParameters().mkString(", "))
9+
println(constructor.toGenericString())
10+
}
11+
12+
def main(args: Array[String]): Unit = {
13+
test(classOf[A1[?]])
14+
test(classOf[A2[?]])
15+
}
16+
}

0 commit comments

Comments
 (0)