Skip to content

fix constructors Java generic signatures #13047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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[?]])
}
}