Skip to content

Commit 2bb8bd1

Browse files
committed
Support default methods in interfaces
This removes some false positives on Scala 2.12.0-RC1. Concrete methods can be added safely (for backwards compatibility) to traits and moved up in the inheritance hierarchy if they get compiled to default interface methods.
1 parent 3e28b62 commit 2bb8bd1

File tree

10 files changed

+3
-12
lines changed

10 files changed

+3
-12
lines changed

core/src/main/scala/com/typesafe/tools/mima/core/ClassInfo.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ abstract class ClassInfo(val owner: PackageInfo) extends HasDeclarationName with
155155

156156
/** The concrete methods of this trait */
157157
lazy val concreteMethods: List[MemberInfo] = {
158-
if(isTrait) methods.iterator.filter(hasStaticImpl(_)).toList
159-
else if(isClass) methods.iterator.filter(!_.isDeferred).toList
158+
if(isTrait) methods.iterator.filter(m => hasStaticImpl(m) || !m.isDeferred).toList
159+
else if(isClass || isInterface) methods.iterator.filter(!_.isDeferred).toList
160160
else Nil
161161
}
162162

Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
abstract method foo()Unit in interface B is inherited by class A in new version.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
method foo()Int in interface A1 is present only in new version
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
method bar()Int in interface A is present only in new version
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
abstract method toList(java.lang.Object)scala.collection.immutable.List in interface FoldableToList is inherited by class Foldable in new version.
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
abstract method foo()Int in interface AA is inherited by class A in new version.
2-
abstract method foo()Int in interface AA is inherited by class B in new version.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
method foo(java.lang.Object)Int in interface A is present only in new version
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
method foo()Int in interface A does not have a correspondent in new version
2-
method foo()Int in interface B is present only in new version
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
method foo()Int in interface A is present only in new version

reporter/src/main/scala/com/typesafe/tools/mima/lib/analyze/Analyzer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private[analyze] class TraitAnalyzer extends Analyzer {
130130
override def analyzeNewClassMethods(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = {
131131
val res = collection.mutable.ListBuffer.empty[Problem]
132132

133-
for (newmeth <- newclazz.concreteMethods if !oldclazz.hasStaticImpl(newmeth)) {
133+
for (newmeth <- newclazz.concreteMethods if newmeth.isDeferred && !oldclazz.hasStaticImpl(newmeth)) {
134134
if (!oldclazz.lookupMethods(newmeth.bytecodeName).exists(_.sig == newmeth.sig)) {
135135
// this means that the method is brand new and therefore the implementation
136136
// has to be injected

0 commit comments

Comments
 (0)