Skip to content

Commit 3b55aa9

Browse files
authored
Merge pull request #6948 from dotty-staging/fix-#6946
Fix #6946: Fix generic signature for synthetic function types
2 parents 18a5789 + 0569cd4 commit 3b55aa9

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ object GenericSignatures {
222222
else
223223
jsig(unboxedSeen, toplevel, primitiveOK)
224224
}
225-
else if (defn.isXXLFunctionClass(sym))
226-
classSig(defn.FunctionXXLClass)
225+
else if (defn.isSyntheticFunctionClass(sym)) {
226+
val erasedSym = defn.erasedFunctionClass(sym)
227+
classSig(erasedSym, pre, if (erasedSym.typeParams.isEmpty) Nil else args)
228+
}
227229
else if (sym.isClass)
228230
classSig(sym, pre, args)
229231
else
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
public <T> scala.FunctionXXL Foo.bar()
2+
public scala.Function1<scala.Function1<java.lang.String, scala.runtime.BoxedUnit>, scala.runtime.BoxedUnit> Foo.baz()

tests/generic-java-signatures/i3653.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ class Foo {
33
(a0: T, a1: T, a2: T, a3: T, a4: T, a5: T, a6: T, a7: T, a8: T, a9: T,
44
b0: T, b1: T, b2: T, b3: T, b4: T, b5: T, b6: T, b7: T, b8: T, b9: T,
55
c0: T, c1: T, c2: T, c3: T, c4: T, c5: T, c6: T, c7: T, c8: T, c9: T) => 0
6+
7+
// #6946
8+
def baz = (x: given String => Unit) => x given ""
69
}
710

811
object Test {
912
def main(args: Array[String]): Unit = {
10-
val meth = classOf[Foo].getDeclaredMethod("bar")
11-
println(meth.toGenericString)
13+
val meth1 = classOf[Foo].getDeclaredMethod("bar")
14+
println(meth1.toGenericString)
15+
val meth2 = classOf[Foo].getDeclaredMethod("baz")
16+
println(meth2.toGenericString)
1217
}
1318
}

0 commit comments

Comments
 (0)