Skip to content

Commit f611549

Browse files
committed
MethodChecker: Move out an isClass guard
1 parent 8778a79 commit f611549

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

core/src/main/scala/com/typesafe/tools/mima/lib/analyze/method/MethodChecker.scala

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private[analyze] object MethodChecker {
1313

1414
/** Analyze incompatibilities that may derive from new methods in `newclazz`. */
1515
private def checkNew(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = {
16-
checkEmulatedConcreteMethodsProblems(oldclazz, newclazz) :::
16+
(if (newclazz.isClass) Nil else checkEmulatedConcreteMethodsProblems(oldclazz, newclazz)) :::
1717
checkDeferredMethodsProblems(oldclazz, newclazz) :::
1818
checkInheritedNewAbstractMethodProblems(oldclazz, newclazz)
1919
}
@@ -108,30 +108,28 @@ private[analyze] object MethodChecker {
108108
methods.groupBy(_.parametersDesc).values.collect { case method :: _ => method }.toList
109109

110110
private def checkEmulatedConcreteMethodsProblems(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = {
111-
if (oldclazz.isClass && newclazz.isClass) Nil else {
112-
for {
113-
newmeth <- newclazz.emulatedConcreteMethods.iterator
114-
if !oldclazz.hasStaticImpl(newmeth)
115-
problem <- {
116-
if (oldclazz.lookupMethods(newmeth).exists(_.descriptor == newmeth.descriptor)) {
117-
// a static implementation for the same method existed already, therefore
118-
// class that mixed-in the trait already have a forwarder to the implementation
119-
// class. Mind that, despite no binary incompatibility arises, program's
120-
// semantic may be severely affected.
121-
None
122-
} else {
123-
// this means that the method is brand new and therefore the implementation
124-
// has to be injected
125-
Some(ReversedMissingMethodProblem(newmeth))
126-
}
111+
for {
112+
newmeth <- newclazz.emulatedConcreteMethods.iterator
113+
if !oldclazz.hasStaticImpl(newmeth)
114+
problem <- {
115+
if (oldclazz.lookupMethods(newmeth).exists(_.descriptor == newmeth.descriptor)) {
116+
// a static implementation for the same method existed already, therefore
117+
// classes that mixed-in the trait already have a forwarder to the implementation
118+
// class. Mind that, despite no binary incompatibility arises, program's
119+
// semantic may be severely affected.
120+
None
121+
} else {
122+
// this means that the method is brand new
123+
// and therefore the implementation has to be injected
124+
Some(ReversedMissingMethodProblem(newmeth))
127125
}
128-
} yield problem
129-
}.toList
130-
}
126+
}
127+
} yield problem
128+
}.toList
131129

132130
private def checkDeferredMethodsProblems(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = {
133131
for {
134-
newmeth <- newclazz.deferredMethods
132+
newmeth <- newclazz.deferredMethods.iterator
135133
problem <- oldclazz.lookupMethods(newmeth).find(_.descriptor == newmeth.descriptor) match {
136134
case None => Some(ReversedMissingMethodProblem(newmeth))
137135
case Some(oldmeth) =>
@@ -140,7 +138,7 @@ private[analyze] object MethodChecker {
140138
else None
141139
}
142140
} yield problem
143-
}
141+
}.toList
144142

145143
private def checkInheritedNewAbstractMethodProblems(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = {
146144
def allInheritedTypes(clazz: ClassInfo) = clazz.superClasses ++ clazz.allInterfaces

0 commit comments

Comments
 (0)