diff --git a/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/problems.txt b/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/problems.txt new file mode 100644 index 00000000..e69de29b diff --git a/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v1/A.java b/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v1/A.java new file mode 100644 index 00000000..c6562ca2 --- /dev/null +++ b/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v1/A.java @@ -0,0 +1 @@ +public abstract class A {} \ No newline at end of file diff --git a/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v1/B.java b/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v1/B.java new file mode 100644 index 00000000..1bcde51b --- /dev/null +++ b/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v1/B.java @@ -0,0 +1 @@ +public class B extends A {} \ No newline at end of file diff --git a/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v2/A.java b/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v2/A.java new file mode 100644 index 00000000..afd29a0e --- /dev/null +++ b/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v2/A.java @@ -0,0 +1,3 @@ +public abstract class A { + public abstract String foo(); +} \ No newline at end of file diff --git a/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v2/B.java b/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v2/B.java new file mode 100644 index 00000000..bd4c70d0 --- /dev/null +++ b/reporter/functional-tests/src/test/java-adding-abstract-method-to-class-ok/v2/B.java @@ -0,0 +1,5 @@ +public class B extends A { + public String foo() { + return null; + } +} diff --git a/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/problems.txt b/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/problems.txt new file mode 100644 index 00000000..e69de29b diff --git a/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v1/A.java b/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v1/A.java new file mode 100644 index 00000000..861bd8ba --- /dev/null +++ b/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v1/A.java @@ -0,0 +1 @@ +public interface A {} \ No newline at end of file diff --git a/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v1/B.java b/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v1/B.java new file mode 100644 index 00000000..80d86473 --- /dev/null +++ b/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v1/B.java @@ -0,0 +1 @@ +public class B implements A {} \ No newline at end of file diff --git a/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v2/A.java b/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v2/A.java new file mode 100644 index 00000000..86ed82f6 --- /dev/null +++ b/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v2/A.java @@ -0,0 +1,3 @@ +public interface A { + public String foo(); +} \ No newline at end of file diff --git a/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v2/B.java b/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v2/B.java new file mode 100644 index 00000000..5193e888 --- /dev/null +++ b/reporter/functional-tests/src/test/java-adding-method-to-interface-implemented-by-a-class-ok/v2/B.java @@ -0,0 +1,5 @@ +public class B implements A { + public String foo() { + return null; + } +} diff --git a/reporter/functional-tests/src/test/java8-add-default-method/problems.txt b/reporter/functional-tests/src/test/java8-add-default-method/problems.txt new file mode 100644 index 00000000..e69de29b diff --git a/reporter/functional-tests/src/test/java8-add-default-method/v1/A.java b/reporter/functional-tests/src/test/java8-add-default-method/v1/A.java new file mode 100644 index 00000000..861bd8ba --- /dev/null +++ b/reporter/functional-tests/src/test/java8-add-default-method/v1/A.java @@ -0,0 +1 @@ +public interface A {} \ No newline at end of file diff --git a/reporter/functional-tests/src/test/java8-add-default-method/v2/A.java b/reporter/functional-tests/src/test/java8-add-default-method/v2/A.java new file mode 100644 index 00000000..c3559a6b --- /dev/null +++ b/reporter/functional-tests/src/test/java8-add-default-method/v2/A.java @@ -0,0 +1,5 @@ +public interface A { + public default String foo() { + return null; + } +} \ No newline at end of file diff --git a/reporter/functional-tests/src/test/trait-abstract-val-become-concrete-ok/problems.txt b/reporter/functional-tests/src/test/trait-abstract-val-become-concrete-ok/problems.txt index e5b271aa..e69de29b 100644 --- a/reporter/functional-tests/src/test/trait-abstract-val-become-concrete-ok/problems.txt +++ b/reporter/functional-tests/src/test/trait-abstract-val-become-concrete-ok/problems.txt @@ -1 +0,0 @@ -synthetic method A$_setter_$foo_=(Int)Unit in trait A does not have a correspondent in old version \ No newline at end of file diff --git a/reporter/functional-tests/src/test/trait-added-val-in-new-version-nok/problems.txt b/reporter/functional-tests/src/test/trait-added-val-in-new-version-nok/problems.txt deleted file mode 100644 index b9f26f53..00000000 --- a/reporter/functional-tests/src/test/trait-added-val-in-new-version-nok/problems.txt +++ /dev/null @@ -1,2 +0,0 @@ -synthetic method A$_setter_|_=(Int)Unit in trait A does not have a correspondent in old version -method bar()Int in trait A does not have a correspondent in old version \ No newline at end of file diff --git a/reporter/functional-tests/src/test/trait-added-val-in-new-version-ok/problems.txt b/reporter/functional-tests/src/test/trait-added-val-in-new-version-ok/problems.txt new file mode 100644 index 00000000..e69de29b diff --git a/reporter/functional-tests/src/test/trait-added-val-in-new-version-nok/v1/A.scala b/reporter/functional-tests/src/test/trait-added-val-in-new-version-ok/v1/A.scala similarity index 100% rename from reporter/functional-tests/src/test/trait-added-val-in-new-version-nok/v1/A.scala rename to reporter/functional-tests/src/test/trait-added-val-in-new-version-ok/v1/A.scala diff --git a/reporter/functional-tests/src/test/trait-added-val-in-new-version-nok/v2/A.scala b/reporter/functional-tests/src/test/trait-added-val-in-new-version-ok/v2/A.scala similarity index 100% rename from reporter/functional-tests/src/test/trait-added-val-in-new-version-nok/v2/A.scala rename to reporter/functional-tests/src/test/trait-added-val-in-new-version-ok/v2/A.scala diff --git a/reporter/functional-tests/src/test/trait-added-var-in-new-version-nok/problems.txt b/reporter/functional-tests/src/test/trait-added-var-in-new-version-nok/problems.txt deleted file mode 100644 index e816bf06..00000000 --- a/reporter/functional-tests/src/test/trait-added-var-in-new-version-nok/problems.txt +++ /dev/null @@ -1,2 +0,0 @@ -method bar_=(Int)Unit in trait A does not have a correspondent in old version -method bar()Int in trait A does not have a correspondent in old version \ No newline at end of file diff --git a/reporter/functional-tests/src/test/trait-added-var-in-new-version-ok/problems.txt b/reporter/functional-tests/src/test/trait-added-var-in-new-version-ok/problems.txt new file mode 100644 index 00000000..e69de29b diff --git a/reporter/functional-tests/src/test/trait-added-var-in-new-version-nok/v1/A.scala b/reporter/functional-tests/src/test/trait-added-var-in-new-version-ok/v1/A.scala similarity index 100% rename from reporter/functional-tests/src/test/trait-added-var-in-new-version-nok/v1/A.scala rename to reporter/functional-tests/src/test/trait-added-var-in-new-version-ok/v1/A.scala diff --git a/reporter/functional-tests/src/test/trait-added-var-in-new-version-nok/v2/A.scala b/reporter/functional-tests/src/test/trait-added-var-in-new-version-ok/v2/A.scala similarity index 100% rename from reporter/functional-tests/src/test/trait-added-var-in-new-version-nok/v2/A.scala rename to reporter/functional-tests/src/test/trait-added-var-in-new-version-ok/v2/A.scala diff --git a/reporter/functional-tests/src/test/trait-moving-methods-nok/problems.txt b/reporter/functional-tests/src/test/trait-moving-methods-nok/problems.txt index af463915..51749477 100644 --- a/reporter/functional-tests/src/test/trait-moving-methods-nok/problems.txt +++ b/reporter/functional-tests/src/test/trait-moving-methods-nok/problems.txt @@ -1,2 +1 @@ -method foo()Int in trait A does not have a correspondent in new version -method foo()Int in trait B does not have a correspondent in old version \ No newline at end of file +method foo()Int in trait A does not have a correspondent in new version \ No newline at end of file diff --git a/reporter/functional-tests/src/test/trait-moving-methods-nok/v1/A.scala b/reporter/functional-tests/src/test/trait-moving-methods-nok/v1/A.scala index 27323fa2..d808bb5a 100644 --- a/reporter/functional-tests/src/test/trait-moving-methods-nok/v1/A.scala +++ b/reporter/functional-tests/src/test/trait-moving-methods-nok/v1/A.scala @@ -2,7 +2,3 @@ trait A { def bar = 2 def foo = 2 } - -trait B - -class C extends A with B diff --git a/reporter/functional-tests/src/test/trait-moving-methods-nok/v2/A.scala b/reporter/functional-tests/src/test/trait-moving-methods-nok/v2/A.scala index b69e3557..a998f806 100644 --- a/reporter/functional-tests/src/test/trait-moving-methods-nok/v2/A.scala +++ b/reporter/functional-tests/src/test/trait-moving-methods-nok/v2/A.scala @@ -1,9 +1,3 @@ trait A { def bar = 2 -} - -trait B { - def foo = 2 -} - -class C extends A with B +} \ No newline at end of file diff --git a/reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-nok/problems.txt b/reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-nok/problems.txt deleted file mode 100644 index 3db647a0..00000000 --- a/reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-nok/problems.txt +++ /dev/null @@ -1 +0,0 @@ -abstract method foo()Int in interface A does not have a correspondent in old version \ No newline at end of file diff --git a/reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-ok/problems.txt b/reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-ok/problems.txt new file mode 100644 index 00000000..e69de29b diff --git a/reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-nok/v1/A.scala b/reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-ok/v1/A.scala similarity index 100% rename from reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-nok/v1/A.scala rename to reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-ok/v1/A.scala diff --git a/reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-nok/v2/A.scala b/reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-ok/v2/A.scala similarity index 100% rename from reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-nok/v2/A.scala rename to reporter/functional-tests/src/test/trait-pushing-up-abstract-methods-is-ok/v2/A.scala diff --git a/reporter/src/main/scala/com/typesafe/tools/mima/lib/analyze/Analyzer.scala b/reporter/src/main/scala/com/typesafe/tools/mima/lib/analyze/Analyzer.scala index 7b71e522..452dcfbd 100644 --- a/reporter/src/main/scala/com/typesafe/tools/mima/lib/analyze/Analyzer.scala +++ b/reporter/src/main/scala/com/typesafe/tools/mima/lib/analyze/Analyzer.scala @@ -78,18 +78,14 @@ private[analyze] class ClassAnalyzer extends Analyzer { override def analyzeNewClassMethods(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = { for (newAbstrMeth <- newclazz.deferredMethods) yield { oldclazz.lookupMethods(newAbstrMeth.bytecodeName).find(_.sig == newAbstrMeth.sig) match { - case None => - val p = MissingMethodProblem(newAbstrMeth) - p.affectedVersion = Problem.ClassVersion.Old - Some(p) case Some(found) => - if(found.isConcrete) { - val p = AbstractMethodProblem(newAbstrMeth) - p.affectedVersion = Problem.ClassVersion.Old - Some(p) - } - else - None + if (found.isConcrete) { + val p = AbstractMethodProblem(newAbstrMeth) + p.affectedVersion = Problem.ClassVersion.Old + Some(p) + } else + None + case _ => None } } } @@ -103,33 +99,19 @@ private[analyze] class TraitAnalyzer extends Analyzer { protected val methodChecker = new TraitMethodChecker override def analyzeNewClassMethods(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = { - val res = collection.mutable.ListBuffer.empty[Problem] - - for (newmeth <- newclazz.concreteMethods if !oldclazz.hasStaticImpl(newmeth)) { - if (!oldclazz.lookupMethods(newmeth.bytecodeName).exists(_.sig == newmeth.sig)) { - // this means that the method is brand new and therefore the implementation - // has to be injected - val problem = MissingMethodProblem(newmeth) - problem.affectedVersion = Problem.ClassVersion.Old - res += problem - } + for { + newmeth <- newclazz.concreteMethods if !oldclazz.hasStaticImpl(newmeth) + if !oldclazz.lookupMethods(newmeth.bytecodeName).exists(_.sig == newmeth.sig) // else a static implementation for the same method existed already, therefore // class that mixed-in the trait already have a forwarder to the implementation // class. Mind that, despite no binary incompatibility arises, program's // semantic may be severely affected. + } yield { + // this means that the method is brand new and therefore the implementation + // has to be injected + val problem = MissingMethodProblem(newmeth) + problem.affectedVersion = Problem.ClassVersion.Old + problem } - - for (newmeth <- newclazz.deferredMethods) { - val oldmeths = oldclazz.lookupMethods(newmeth.bytecodeName) - oldmeths find (_.sig == newmeth.sig) match { - case Some(oldmeth) => () - case _ => - val problem = MissingMethodProblem(newmeth) - problem.affectedVersion = Problem.ClassVersion.Old - res += problem - } - } - - res.toList } } \ No newline at end of file