Skip to content

Commit

Permalink
Merge pull request #46 from sjrd/details-for-missing-term-members
Browse files Browse the repository at this point in the history
Add the expected signature for missing term member problems.
  • Loading branch information
bishabosha authored Jul 19, 2023
2 parents 034e2f4 + e7507c0 commit 6fb5628
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tasty-mima/src/main/scala/tastymima/Analyzer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private[tastymima] final class Analyzer(val config: Config, val oldCtx: Context,
case oldDecl: TermSymbol =>
lookupCorrespondingTermMember(oldCtx, oldDecl, newCtx, newClass) match
case None =>
reportProblem(ProblemKind.MissingTermMember, oldDecl)
reportProblem(ProblemKind.MissingTermMember, oldDecl, oldDecl.signature(using oldCtx))
case Some(newDecl) =>
analyzeTermMember(oldDecl, oldIsOverridable, newThisType, newDecl)
end analyzeMemberOfClass
Expand Down Expand Up @@ -351,7 +351,7 @@ private[tastymima] final class Analyzer(val config: Config, val oldCtx: Context,
}
if !oldIsAbstractEverywhere then
// Then it is a problem
reportProblem(ProblemKind.NewAbstractMember, newDecl)
reportProblem(ProblemKind.NewAbstractMember, newDecl, newDecl.signature(using newCtx))
end checkNewMaybeAbstractTermMember

private def translateType(oldType: Type): Type =
Expand Down
17 changes: 14 additions & 3 deletions tasty-mima/src/main/scala/tastymima/Problem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tastymima

import tastyquery.Modifiers.*
import tastyquery.Names.*
import tastyquery.Signatures.*
import tastyquery.Types.*

import tastymima.intf.{ProblemKind, Problem as IProblem}
Expand All @@ -21,10 +22,20 @@ final class Problem(val kind: ProblemKind, val path: List[Name], val details: Ma
def getPathString(): String = pathString

override def getDescription(): String | Null =
val superDesc = super.getDescription()
(kind, details) match
// Better sentence structure than putting `details` at the end for some combinations

if details == () then superDesc
else s"$superDesc: ${detailsString(details)}"
case (ProblemKind.MissingTermMember, details: Signature) =>
s"The member ${getPathString()} with signature $details does not have a correspondant in current version"
case (ProblemKind.NewAbstractMember, details: Signature) =>
s"The member ${getPathString()} with signature $details "
+ "was concrete or did not exist but is abstract in current version"

case _ =>
val superDesc = super.getDescription()

if details == () then superDesc
else s"$superDesc: ${detailsString(details)}"
end getDescription

private def detailsString(details: Matchable): String = details match
Expand Down

0 comments on commit 6fb5628

Please sign in to comment.