From b12900912db1b935422419d7d48b6ed73684ebf6 Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Tue, 10 Apr 2018 14:19:22 +0200 Subject: [PATCH 1/2] Fix #3653: generic Java signature of FunctionXXL We were encoding the generic Java signature of `FunctionN`s' with more than P parameters as `FunctionP<..params..>` (which doesn't exist), but in the bytecode, FunctionXXL is used instead. This commit fixes that, so that the generic signature matches `FunctionXXL`. --- .../tools/dotc/transform/GenericSignatures.scala | 3 +++ tests/generic-java-signatures/i3653.check | 1 + tests/generic-java-signatures/i3653.scala | 13 +++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 tests/generic-java-signatures/i3653.check create mode 100644 tests/generic-java-signatures/i3653.scala diff --git a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala index e71460b806e3..4f92c2fb48a1 100644 --- a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala +++ b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala @@ -127,6 +127,9 @@ object GenericSignatures { case ref @ TypeParamRef(_: PolyType, _) => typeParamSig(ref.paramName.lastPart) + case RefOrAppliedType(sym, _, _) if defn.isXXLFunctionClass(sym) => + jsig(defn.FunctionXXLType, toplevel, primitiveOK) + case RefOrAppliedType(sym, pre, args) => def argSig(tp: Type): Unit = tp match { diff --git a/tests/generic-java-signatures/i3653.check b/tests/generic-java-signatures/i3653.check new file mode 100644 index 000000000000..4824f908da06 --- /dev/null +++ b/tests/generic-java-signatures/i3653.check @@ -0,0 +1 @@ +public scala.FunctionXXL Foo.bar() diff --git a/tests/generic-java-signatures/i3653.scala b/tests/generic-java-signatures/i3653.scala new file mode 100644 index 000000000000..4251aeb2f23b --- /dev/null +++ b/tests/generic-java-signatures/i3653.scala @@ -0,0 +1,13 @@ +class Foo { + def bar[T] = + (a0: T, a1: T, a2: T, a3: T, a4: T, a5: T, a6: T, a7: T, a8: T, a9: T, + b0: T, b1: T, b2: T, b3: T, b4: T, b5: T, b6: T, b7: T, b8: T, b9: T, + c0: T, c1: T, c2: T, c3: T, c4: T, c5: T, c6: T, c7: T, c8: T, c9: T) => 0 +} + +object Test { + def main(args: Array[String]): Unit = { + val meth = classOf[Foo].getDeclaredMethod("bar") + println(meth.toGenericString) + } +} From 82add933e3c6a80165013829ca828a550334045a Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Tue, 10 Apr 2018 15:17:50 +0200 Subject: [PATCH 2/2] Address review comment --- .../src/dotty/tools/dotc/transform/GenericSignatures.scala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala index 4f92c2fb48a1..486325b20cf2 100644 --- a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala +++ b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala @@ -127,9 +127,6 @@ object GenericSignatures { case ref @ TypeParamRef(_: PolyType, _) => typeParamSig(ref.paramName.lastPart) - case RefOrAppliedType(sym, _, _) if defn.isXXLFunctionClass(sym) => - jsig(defn.FunctionXXLType, toplevel, primitiveOK) - case RefOrAppliedType(sym, pre, args) => def argSig(tp: Type): Unit = tp match { @@ -215,6 +212,8 @@ object GenericSignatures { else jsig(unboxedSeen, toplevel, primitiveOK) } + else if (defn.isXXLFunctionClass(sym)) + jsig(defn.FunctionXXLType, toplevel, primitiveOK) else if (sym.isClass) classSig else