From 6e017db6ad02303d053f69493a5135319dac5364 Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Wed, 13 Apr 2022 18:06:10 +0200 Subject: [PATCH] Consider missing signature equivalent to non-generic one Since for those it should be sufficient to check the descriptor anyway, and the Scala compiler started emitting more signatures between 3.1.1 and 3.1.2 (from the functional tests it seems there were already a couple of cases where Scala3 produced more signatures than expected, we now ignore those as well) References #693 --- .../com/typesafe/tools/mima/core/Signature.scala | 15 ++++++++++++--- .../problems-3.txt | 3 --- .../problems-3.txt | 1 - 3 files changed, 12 insertions(+), 7 deletions(-) delete mode 100644 functional-tests/src/test/java-class-static-varargs-to-scala-object-annotated-varargs-ok/problems-3.txt delete mode 100644 functional-tests/src/test/trait-abstract-var-becomes-concrete-ok/problems-3.txt diff --git a/core/src/main/scala/com/typesafe/tools/mima/core/Signature.scala b/core/src/main/scala/com/typesafe/tools/mima/core/Signature.scala index b8cef5932..f88950548 100644 --- a/core/src/main/scala/com/typesafe/tools/mima/core/Signature.scala +++ b/core/src/main/scala/com/typesafe/tools/mima/core/Signature.scala @@ -20,9 +20,18 @@ class Signature(private val signature: String) { } def matches(newer: Signature, isConstructor: Boolean): Boolean = { - return (signature == newer.signature) || - (isConstructor && hasMatchingCtorSig(newer.signature)) || - canonicalized == newer.canonicalized + // If the signature is identical obviously it matches + (signature == newer.signature) || + // Consider missing signatures identical to non-generic ones. + // This is particularly helpful because between Scala 3.1.1 and 3.1.2 the compiler + // started emitting signatures for non-generic methods. Incompatibilities for those + // will be caught through mismatching descriptors anyway. + (signature == "" && newer.signature.indexOf('<') == -1) || + (newer.signature == "" && signature.indexOf('<') == -1) || + // Special rules for constructors + (isConstructor && hasMatchingCtorSig(newer.signature)) || + // Also match when the signature only differs in the name of a type parameter + canonicalized == newer.canonicalized } // Special case for scala#7975 diff --git a/functional-tests/src/test/java-class-static-varargs-to-scala-object-annotated-varargs-ok/problems-3.txt b/functional-tests/src/test/java-class-static-varargs-to-scala-object-annotated-varargs-ok/problems-3.txt deleted file mode 100644 index 9dbf144e7..000000000 --- a/functional-tests/src/test/java-class-static-varargs-to-scala-object-annotated-varargs-ok/problems-3.txt +++ /dev/null @@ -1,3 +0,0 @@ -static method create(Array[java.lang.String])java.lang.String in class A has a different generic signature in new version, where it is ([Ljava/lang/String;)Ljava/lang/String; rather than . See https://github.com/lightbend/mima#incompatiblesignatureproblem -# Scala 3 adds a method signature when it isn't required -# https://github.com/lampepfl/dotty/issues/10837 diff --git a/functional-tests/src/test/trait-abstract-var-becomes-concrete-ok/problems-3.txt b/functional-tests/src/test/trait-abstract-var-becomes-concrete-ok/problems-3.txt deleted file mode 100644 index fc6b53f34..000000000 --- a/functional-tests/src/test/trait-abstract-var-becomes-concrete-ok/problems-3.txt +++ /dev/null @@ -1 +0,0 @@ -method foo()Int in class B has a different generic signature in new version, where it is rather than ()I. See https://github.com/lightbend/mima#incompatiblesignatureproblem