Skip to content

Commit ea541a6

Browse files
committed
Addapt GenericSignatures to handle unused parameters
1 parent e0bbca6 commit ea541a6

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ object GenericSignatures {
239239
methodResultSig(restpe)
240240

241241
case mtpe: MethodType =>
242-
// phantom method parameters do not make it to the bytecode.
243-
val params = mtpe.paramInfos.filterNot(_.isPhantom)
242+
// unused method parameters do not make it to the bytecode.
243+
val params = if (mtpe.isUnusedMethod) Nil else mtpe.paramInfos
244244
val restpe = mtpe.resultType
245245
builder.append('(')
246246
// TODO: Update once we support varargs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
public <U> int MyUnused$.f1()
2+
U <: java.lang.Object
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
object MyUnused {
2+
def f1[U](unused a: Int): Int = 0
3+
}
4+
5+
object Test {
6+
def main(args: Array[String]): Unit = {
7+
val f1 = MyUnused.getClass.getMethods.find(_.getName.endsWith("f1")).get
8+
val tParams = f1.getTypeParameters
9+
println(f1.toGenericString)
10+
tParams.foreach { tp =>
11+
println(tp.getName + " <: " + tp.getBounds.map(_.getTypeName).mkString(", "))
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)