diff --git a/core/src/main/scala/com/typesafe/tools/mima/core/ClassInfo.scala b/core/src/main/scala/com/typesafe/tools/mima/core/ClassInfo.scala index b50d3cee..58922ffc 100644 --- a/core/src/main/scala/com/typesafe/tools/mima/core/ClassInfo.scala +++ b/core/src/main/scala/com/typesafe/tools/mima/core/ClassInfo.scala @@ -99,14 +99,15 @@ sealed abstract class ClassInfo(val owner: PackageInfo) extends InfoLike with Eq thisAndSuperClasses.flatMap(_.fields.get(field.bytecodeName)) final def lookupClassMethods(method: MethodInfo): Iterator[MethodInfo] = { - method.bytecodeName match { - case MemberInfo.ConstructorName => methods.get(MemberInfo.ConstructorName) // constructors are not inherited - case name => thisAndSuperClasses.flatMap(_.methods.get(name)) - } + val name = method.bytecodeName + if (name == MemberInfo.ConstructorName) methods.get(name) // constructors are not inherited + else if (method.isStatic) methods.get(name) // static methods are not inherited + else thisAndSuperClasses.flatMap(_.methods.get(name)) } private def lookupInterfaceMethods(method: MethodInfo): Iterator[MethodInfo] = - allInterfaces.iterator.flatMap(_.methods.get(method.bytecodeName)) + if (method.isStatic) Iterator.empty // static methods are not inherited + else allInterfaces.iterator.flatMap(_.methods.get(method.bytecodeName)) final def lookupMethods(method: MethodInfo): Iterator[MethodInfo] = lookupClassMethods(method) ++ lookupInterfaceMethods(method) diff --git a/core/src/main/scala/com/typesafe/tools/mima/core/MemberInfo.scala b/core/src/main/scala/com/typesafe/tools/mima/core/MemberInfo.scala index d678b2bb..ffb836ec 100644 --- a/core/src/main/scala/com/typesafe/tools/mima/core/MemberInfo.scala +++ b/core/src/main/scala/com/typesafe/tools/mima/core/MemberInfo.scala @@ -54,13 +54,17 @@ private[mima] final class MethodInfo(owner: ClassInfo, bytecodeName: String, fla def matchesType(other: MethodInfo): Boolean = parametersDesc == other.parametersDesc private def isDefaultGetter: Boolean = decodedName.contains("$default$") + private def isTraitInit: Boolean = decodedName == "$init$" private def isExtensionMethod: Boolean = { var i = decodedName.length - 1 while (i >= 0 && Character.isDigit(decodedName.charAt(i))) i -= 1 decodedName.substring(0, i + 1).endsWith("$extension") } - def nonAccessible: Boolean = !isPublic || isSynthetic || (hasSyntheticName && !isExtensionMethod && !isDefaultGetter) + def nonAccessible: Boolean = { + !isPublic || isSynthetic || + (hasSyntheticName && !(isExtensionMethod || isDefaultGetter || isTraitInit)) + } override def toString = s"def $bytecodeName: $descriptor" } diff --git a/functional-tests/src/test/class-narrowing-method-type-in-new-version-ok/problems.txt b/functional-tests/src/test/class-narrowing-method-type-in-new-version-nok/problems.txt similarity index 100% rename from functional-tests/src/test/class-narrowing-method-type-in-new-version-ok/problems.txt rename to functional-tests/src/test/class-narrowing-method-type-in-new-version-nok/problems.txt diff --git a/functional-tests/src/test/class-narrowing-method-type-in-new-version-ok/v1/A.scala b/functional-tests/src/test/class-narrowing-method-type-in-new-version-nok/v1/A.scala similarity index 100% rename from functional-tests/src/test/class-narrowing-method-type-in-new-version-ok/v1/A.scala rename to functional-tests/src/test/class-narrowing-method-type-in-new-version-nok/v1/A.scala diff --git a/functional-tests/src/test/class-narrowing-method-type-in-new-version-ok/v2/A.scala b/functional-tests/src/test/class-narrowing-method-type-in-new-version-nok/v2/A.scala similarity index 100% rename from functional-tests/src/test/class-narrowing-method-type-in-new-version-ok/v2/A.scala rename to functional-tests/src/test/class-narrowing-method-type-in-new-version-nok/v2/A.scala diff --git a/functional-tests/src/test/moving-method-upward-from-trait-to-class-nok/problems.txt b/functional-tests/src/test/moving-method-upward-from-trait-to-class-nok/problems.txt index eb680da0..2764108a 100644 --- a/functional-tests/src/test/moving-method-upward-from-trait-to-class-nok/problems.txt +++ b/functional-tests/src/test/moving-method-upward-from-trait-to-class-nok/problems.txt @@ -1 +1,2 @@ method foo()Int in interface B does not have a correspondent in new version +synthetic static method $init$(B)Unit in interface B does not have a correspondent in new version diff --git a/functional-tests/src/test/trait-deleting-concrete-methods-is-ok/problems-2.11.txt b/functional-tests/src/test/trait-deleting-concrete-methods-is-nok/problems-2.11.txt similarity index 100% rename from functional-tests/src/test/trait-deleting-concrete-methods-is-ok/problems-2.11.txt rename to functional-tests/src/test/trait-deleting-concrete-methods-is-nok/problems-2.11.txt diff --git a/functional-tests/src/test/trait-deleting-concrete-methods-is-ok/problems.txt b/functional-tests/src/test/trait-deleting-concrete-methods-is-nok/problems.txt similarity index 100% rename from functional-tests/src/test/trait-deleting-concrete-methods-is-ok/problems.txt rename to functional-tests/src/test/trait-deleting-concrete-methods-is-nok/problems.txt diff --git a/functional-tests/src/test/trait-deleting-concrete-methods-is-ok/v1/A.scala b/functional-tests/src/test/trait-deleting-concrete-methods-is-nok/v1/A.scala similarity index 100% rename from functional-tests/src/test/trait-deleting-concrete-methods-is-ok/v1/A.scala rename to functional-tests/src/test/trait-deleting-concrete-methods-is-nok/v1/A.scala diff --git a/functional-tests/src/test/trait-deleting-concrete-methods-is-nok/v2/A.scala b/functional-tests/src/test/trait-deleting-concrete-methods-is-nok/v2/A.scala new file mode 100644 index 00000000..18c7fee7 --- /dev/null +++ b/functional-tests/src/test/trait-deleting-concrete-methods-is-nok/v2/A.scala @@ -0,0 +1,11 @@ +trait A { + def foo: Int = 2 +} + + + +trait B extends A { + private def _B_init = () +} + +class C extends B diff --git a/functional-tests/src/test/trait-pushing-up-concrete-methods-is-ok/problems-2.11.txt b/functional-tests/src/test/trait-pushing-up-concrete-methods-is-nok/problems-2.11.txt similarity index 100% rename from functional-tests/src/test/trait-pushing-up-concrete-methods-is-ok/problems-2.11.txt rename to functional-tests/src/test/trait-pushing-up-concrete-methods-is-nok/problems-2.11.txt diff --git a/functional-tests/src/test/trait-pushing-up-concrete-methods-is-nok/problems.txt b/functional-tests/src/test/trait-pushing-up-concrete-methods-is-nok/problems.txt new file mode 100644 index 00000000..22ed1402 --- /dev/null +++ b/functional-tests/src/test/trait-pushing-up-concrete-methods-is-nok/problems.txt @@ -0,0 +1 @@ +synthetic static method $init$(B)Unit in interface B does not have a correspondent in new version \ No newline at end of file diff --git a/functional-tests/src/test/trait-pushing-up-concrete-methods-is-ok/v1/A.scala b/functional-tests/src/test/trait-pushing-up-concrete-methods-is-nok/v1/A.scala similarity index 100% rename from functional-tests/src/test/trait-pushing-up-concrete-methods-is-ok/v1/A.scala rename to functional-tests/src/test/trait-pushing-up-concrete-methods-is-nok/v1/A.scala diff --git a/functional-tests/src/test/trait-deleting-concrete-methods-is-ok/v2/A.scala b/functional-tests/src/test/trait-pushing-up-concrete-methods-is-nok/v2/A.scala similarity index 74% rename from functional-tests/src/test/trait-deleting-concrete-methods-is-ok/v2/A.scala rename to functional-tests/src/test/trait-pushing-up-concrete-methods-is-nok/v2/A.scala index 70a33c91..a8ae8dca 100644 --- a/functional-tests/src/test/trait-deleting-concrete-methods-is-ok/v2/A.scala +++ b/functional-tests/src/test/trait-pushing-up-concrete-methods-is-nok/v2/A.scala @@ -5,5 +5,3 @@ trait A { trait B extends A - -class C extends B \ No newline at end of file diff --git a/functional-tests/src/test/trait-pushing-up-concrete-methods-is-ok/problems.txt b/functional-tests/src/test/trait-pushing-up-concrete-methods-is-ok/problems.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/functional-tests/src/test/trait-pushing-up-concrete-methods-is-ok/v2/A.scala b/functional-tests/src/test/trait-pushing-up-concrete-methods-is-ok/v2/A.scala deleted file mode 100644 index 0380fa56..00000000 --- a/functional-tests/src/test/trait-pushing-up-concrete-methods-is-ok/v2/A.scala +++ /dev/null @@ -1,7 +0,0 @@ -trait A { - def foo: Int = 2 -} - - - -trait B extends A \ No newline at end of file