Skip to content

Commit

Permalink
Merge pull request #107 from cunei/fix-back-forw
Browse files Browse the repository at this point in the history
Fix for AbstractMethodProblem and MissingMethodProblem matching
  • Loading branch information
2m committed Feb 29, 2016
2 parents 027979e + e0730e6 commit 4f1cd43
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions core/src/main/scala/com/typesafe/tools/mima/core/Problems.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ case class MissingFieldProblem(oldfld: MemberInfo) extends MemberProblem(oldfld)
def description = affectedVersion => oldfld.fieldString + " does not have a correspondent in " + affectedVersion + " version"
}

case class MissingMethodProblem(meth: MemberInfo) extends MemberProblem(meth) {
abstract class MissingMethodProblem(meth: MemberInfo) extends MemberProblem(meth)

case class DirectMissingMethodProblem(meth: MemberInfo) extends MissingMethodProblem(meth) {
def description = affectedVersion => (if (meth.isDeferred && !meth.owner.isTrait) "abstract " else "") + meth.methodString + " does not have a correspondent in " + affectedVersion + " version"
}

case class ReversedMissingMethodProblem(meth: MemberInfo) extends MemberProblem(meth) {
case class ReversedMissingMethodProblem(meth: MemberInfo) extends MissingMethodProblem(meth) {
def description = affectedVersion => (if (meth.isDeferred && !meth.owner.isTrait) "abstract " else "") + meth.methodString + " is present only in " + affectedVersion + " version"
}

Expand Down Expand Up @@ -102,7 +104,9 @@ case class IncompatibleResultTypeProblem(oldmeth: MemberInfo, newmeth: MemberInf

// In some older code within Mima, the affectedVersion could be reversed. We split AbstractMethodProblem and MissingMethodProblem
// into two, in case the affected version is the other one, rather than the current one. (reversed if forward check).
case class AbstractMethodProblem(newmeth: MemberInfo) extends MemberProblem(newmeth) {
abstract class AbstractMethodProblem(newmeth: MemberInfo) extends MemberProblem(newmeth)

case class DirectAbstractMethodProblem(newmeth: MemberInfo) extends AbstractMethodProblem(newmeth) {
def description = affectedVersion => "abstract " + newmeth.methodString + " does not have a correspondent in " + affectedVersion + " version"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private[analyze] abstract class BaseMethodChecker extends Checker[MemberInfo, Cl
protected def check(method: MemberInfo, in: TraversableOnce[MemberInfo]): Option[Problem] = {
val meths = (in filter (method.params.size == _.params.size)).toList
if (meths.isEmpty)
Some(MissingMethodProblem(method))
Some(DirectMissingMethodProblem(method))
else {
meths find (_.sig == method.sig) match {
case None =>
Expand Down Expand Up @@ -77,4 +77,4 @@ private[analyze] class TraitMethodChecker extends BaseMethodChecker {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ private[method] object MethodRules {
def apply(thisMember: MemberInfo, thatMember: MemberInfo): Option[Problem] = {
// A concrete member that is made abstract entail a binary incompatibilities because client
// code may be calling it when no concrete implementation exists
if (thisMember.isConcrete && thatMember.isDeferred) Some(AbstractMethodProblem(thatMember))
if (thisMember.isConcrete && thatMember.isDeferred) Some(DirectAbstractMethodProblem(thatMember))
// note: Conversely, an abstract member that is made concrete does not entail incompatibilities
// because no client code relied on it.
else None
}
}

}
}

0 comments on commit 4f1cd43

Please sign in to comment.