Skip to content

Commit

Permalink
Addapt GenericSignatures to handle unused parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Oct 31, 2017
1 parent e0bbca6 commit ea541a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ object GenericSignatures {
methodResultSig(restpe)

case mtpe: MethodType =>
// phantom method parameters do not make it to the bytecode.
val params = mtpe.paramInfos.filterNot(_.isPhantom)
// unused method parameters do not make it to the bytecode.
val params = if (mtpe.isUnusedMethod) Nil else mtpe.paramInfos
val restpe = mtpe.resultType
builder.append('(')
// TODO: Update once we support varargs
Expand Down
2 changes: 2 additions & 0 deletions tests/generic-java-signatures/unused.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public <U> int MyUnused$.f1()
U <: java.lang.Object
14 changes: 14 additions & 0 deletions tests/generic-java-signatures/unused.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
object MyUnused {
def f1[U](unused a: Int): Int = 0
}

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

0 comments on commit ea541a6

Please sign in to comment.