From e7507c0ead7ecfdb9097164738fa8e8a4a2a0445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Tue, 18 Jul 2023 13:16:20 +0200 Subject: [PATCH] Add the expected signature for missing term member problems. This is for `MissingTermMember` and `NewAbstractMember`. It can help identify problems in the presence of overloads. --- .../src/main/scala/tastymima/Analyzer.scala | 4 ++-- .../src/main/scala/tastymima/Problem.scala | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tasty-mima/src/main/scala/tastymima/Analyzer.scala b/tasty-mima/src/main/scala/tastymima/Analyzer.scala index 14b1107..5c284cc 100644 --- a/tasty-mima/src/main/scala/tastymima/Analyzer.scala +++ b/tasty-mima/src/main/scala/tastymima/Analyzer.scala @@ -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 @@ -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 = diff --git a/tasty-mima/src/main/scala/tastymima/Problem.scala b/tasty-mima/src/main/scala/tastymima/Problem.scala index 8a2d933..a486f2f 100644 --- a/tasty-mima/src/main/scala/tastymima/Problem.scala +++ b/tasty-mima/src/main/scala/tastymima/Problem.scala @@ -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} @@ -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