Skip to content

Commit 6ecd7b0

Browse files
committed
Exclude phantom parameters from methods signatures
1 parent 6d22269 commit 6ecd7b0

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,8 @@ object Erasure {
980980
methodResultSig(restpe)
981981

982982
case mtpe: MethodType =>
983-
val params = mtpe.paramInfos
983+
// phantom method parameters do not make it to the bytecode.
984+
val params = mtpe.paramInfos.filterNot(_.isPhantom)
984985
val restpe = mtpe.resultType
985986
builder.append('(')
986987
// TODO: Update once we support varargs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public <U,T> T MyOtherPhantom$.f1(int,int)
2+
U <: java.lang.Object
3+
T <: dotty.runtime.ErasedPhantom
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
object MyOtherPhantom extends Phantom {
2+
type MyPhantom[V] <: this.Any
3+
def myPhantom[X]: MyPhantom[X] = assume
4+
5+
def f1[U, T <: MyPhantom[U]](a: Int, b: T, c: Int): T = b
6+
7+
def f2 = {
8+
f1(3, myPhantom[Int], 2)
9+
}
10+
}
11+
12+
object Test {
13+
def main(args: Array[String]): Unit = {
14+
val f1 = MyOtherPhantom.getClass.getMethods.find(_.getName.endsWith("f1")).get
15+
val tParams = f1.getTypeParameters
16+
println(f1.toGenericString)
17+
tParams.foreach { tp =>
18+
println(tp.getName + " <: " + tp.getBounds.map(_.getTypeName).mkString(", "))
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)