diff --git a/compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala b/compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala index a92da7821fab..6c8e9430e815 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala @@ -9,7 +9,7 @@ import dotty.tools.dotc.core.Contexts._ import dotty.tools.dotc.interfaces.Diagnostic.{ERROR, INFO, WARNING} import dotty.tools.dotc.util.SourcePosition -import java.util.Optional +import java.util.{Collections, Optional, List => JList} import scala.util.chaining._ import core.Decorators.toMessage @@ -100,6 +100,8 @@ class Diagnostic( if (pos.exists && pos.source.exists) Optional.of(pos) else Optional.empty() override def message: String = msg.message.replaceAll("\u001B\\[[;\\d]*m", "") + override def diagnosticRelatedInformation: JList[interfaces.DiagnosticRelatedInformation] = + Collections.emptyList() override def toString: String = s"$getClass at $pos: $message" override def getMessage(): String = message diff --git a/interfaces/src/dotty/tools/dotc/interfaces/Diagnostic.java b/interfaces/src/dotty/tools/dotc/interfaces/Diagnostic.java index c46360afaa3d..19878a2fa105 100644 --- a/interfaces/src/dotty/tools/dotc/interfaces/Diagnostic.java +++ b/interfaces/src/dotty/tools/dotc/interfaces/Diagnostic.java @@ -1,6 +1,7 @@ package dotty.tools.dotc.interfaces; import java.util.Optional; +import java.util.List; /** A diagnostic is a message emitted during the compilation process. * @@ -23,4 +24,7 @@ public interface Diagnostic { /** @return The position in a source file of the code that caused this diagnostic * to be emitted. */ Optional position(); + + /** @return A list of additional messages together with their code positions */ + List diagnosticRelatedInformation(); } diff --git a/interfaces/src/dotty/tools/dotc/interfaces/DiagnosticRelatedInformation.java b/interfaces/src/dotty/tools/dotc/interfaces/DiagnosticRelatedInformation.java new file mode 100644 index 000000000000..3ebea03f4362 --- /dev/null +++ b/interfaces/src/dotty/tools/dotc/interfaces/DiagnosticRelatedInformation.java @@ -0,0 +1,6 @@ +package dotty.tools.dotc.interfaces; + +public interface DiagnosticRelatedInformation { + SourcePosition position(); + String message(); +} diff --git a/project/Build.scala b/project/Build.scala index bda19f4fd4b0..9babd3c9c679 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -489,7 +489,8 @@ object Build { settings(commonJavaSettings). settings(commonMiMaSettings). settings( - versionScheme := Some("semver-spec") + versionScheme := Some("semver-spec"), + mimaBinaryIssueFilters ++= MiMaFilters.Interfaces ) /** Find an artifact with the given `name` in `classpath` */ diff --git a/project/MiMaFilters.scala b/project/MiMaFilters.scala index cb715cb15808..689a4b8f1614 100644 --- a/project/MiMaFilters.scala +++ b/project/MiMaFilters.scala @@ -7,4 +7,8 @@ object MiMaFilters { ProblemFilters.exclude[DirectMissingMethodProblem]("scala.caps.unsafeUnbox"), ) val TastyCore: Seq[ProblemFilter] = Seq() + val Interfaces: Seq[ProblemFilter] = Seq( + ProblemFilters.exclude[MissingClassProblem]("dotty.tools.dotc.interfaces.DiagnosticRelatedInformation"), + ProblemFilters.exclude[ReversedMissingMethodProblem]("dotty.tools.dotc.interfaces.Diagnostic.diagnosticRelatedInformation") + ) } diff --git a/tests/pos-with-compiler-cc/dotc/reporting/Diagnostic.scala b/tests/pos-with-compiler-cc/dotc/reporting/Diagnostic.scala index b792aed4264e..630607581fcc 100644 --- a/tests/pos-with-compiler-cc/dotc/reporting/Diagnostic.scala +++ b/tests/pos-with-compiler-cc/dotc/reporting/Diagnostic.scala @@ -9,7 +9,7 @@ import dotty.tools.dotc.core.Contexts._ import dotty.tools.dotc.interfaces.Diagnostic.{ERROR, INFO, WARNING} import dotty.tools.dotc.util.SourcePosition -import java.util.Optional +import java.util.{Collections, Optional, List => JList} import scala.util.chaining._ import core.Decorators.toMessage import language.experimental.pureFunctions @@ -101,6 +101,8 @@ class Diagnostic( if (pos.exists && pos.source.exists) Optional.of(pos) else Optional.empty() override def message: String = msg.message.replaceAll("\u001B\\[[;\\d]*m", "") + override def diagnosticRelatedInformation: JList[interfaces.DiagnosticRelatedInformation] = + Collections.emptyList() override def toString: String = s"$getClass at $pos: $message" override def getMessage(): String = message