Skip to content
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

Missing parameter list in JavaGeneric signature #3411

Closed
nicolasstucki opened this issue Oct 31, 2017 · 2 comments · Fixed by #3414
Closed

Missing parameter list in JavaGeneric signature #3411

nicolasstucki opened this issue Oct 31, 2017 · 2 comments · Fixed by #3414

Comments

@nicolasstucki
Copy link
Contributor

object Foo {
  def foo[U](a: Int, b: Double)(c: Boolean, d: String)(e: Object): Int = 1
}

will generate the signature public <U> int Foo$.foo(int,double) which misses all parameters not in the first parameter list.

@nicolasstucki
Copy link
Contributor Author

Test case to add
tests/generic-java-signatures/i3411.scala

object Foo {
  def foo[U](a: Int, b: Double)(c: Boolean, d: String)(e: Object): Int = a
}

object Test {
  def main(args: Array[String]): Unit = {
    val f1 = Foo.getClass.getMethods.find(_.getName.endsWith("foo")).get
    val tParams = f1.getTypeParameters
    println(f1.toGenericString)
    tParams.foreach { tp =>
      println(tp.getName + " <: " + tp.getBounds.map(_.getTypeName).mkString(", "))
    }
  }
}

@nicolasstucki
Copy link
Contributor Author

// GenericSignatures.scala

        case mtpe: MethodType =>
          // phantom method parameters do not make it to the bytecode.
          val params = mtpe.paramInfos.filterNot(_.isPhantom)
          val restpe = mtpe.resultType
          builder.append('(')
          // TODO: Update once we support varargs
          params.foreach { tp =>
            jsig(tp)
          }
          builder.append(')')
          methodResultSig(restpe)

does not handle the case where restpe is another method type.

Duhemm added a commit to Duhemm/dotty that referenced this issue Oct 31, 2017
We ignored the case where a `MethodType` had another `MethodType` as
result type. This commit fixes the issue by collecting the parameters of
the result type if it is a `MethodType`, recursively.

Fixes scala#3411
Duhemm added a commit to Duhemm/dotty that referenced this issue Oct 31, 2017
We ignored the case where a `MethodType` had another `MethodType` as
result type. This commit fixes the issue by collecting the parameters of
the result type if it is a `MethodType`, recursively.

Fixes scala#3411
Duhemm added a commit to Duhemm/dotty that referenced this issue Oct 31, 2017
We ignored the case where a `MethodType` had another `MethodType` as
result type. This commit fixes the issue by collecting the parameters of
the result type if it is a `MethodType`, recursively.

Fixes scala#3411
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants