Skip to content

Commit

Permalink
Merge pull request #13047 from xuwei-k/fix-10834
Browse files Browse the repository at this point in the history
fix constructors Java generic signatures
  • Loading branch information
bishabosha authored Jul 12, 2021
2 parents 6631730 + d3aa042 commit f581090
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ object GenericSignatures {

case PolyType(tparams, mtpe: MethodType) =>
assert(tparams.nonEmpty)
if (toplevel) polyParamSig(tparams)
if (toplevel && !sym0.isConstructor) polyParamSig(tparams)
jsig(mtpe)

// Nullary polymorphic method
Expand Down
6 changes: 6 additions & 0 deletions tests/generic-java-signatures/i10834.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
0

public A1(X)
0

public A2(java.lang.Object)
16 changes: 16 additions & 0 deletions tests/generic-java-signatures/i10834.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class A1[X](val x: X)
class A2[F[_]](val x: F[String])

object Test {
def test(clazz: Class[?]): Unit = {
val List(constructor) = clazz.getConstructors().toList
println(constructor.getTypeParameters().length)
println(constructor.getTypeParameters().mkString(", "))
println(constructor.toGenericString())
}

def main(args: Array[String]): Unit = {
test(classOf[A1[?]])
test(classOf[A2[?]])
}
}

0 comments on commit f581090

Please sign in to comment.