Skip to content

refactor: don't forward -1 as the diagnosticCode #16495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions sbt-bridge/src/dotty/tools/xsbt/Problem.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@ public Optional<String> rendered() {
}

public Optional<xsbti.DiagnosticCode> diagnosticCode() {
// NOTE: It's important for compatibility that we only construct a
// DiagnosticCode here to maintain compatibility with older versions of
// zinc while using this newer version of the compiler. If we would
// contstruct it earlier, you'd end up with ClassNotFoundExceptions for
// DiagnosticCode.
return Optional.of(new DiagnosticCode(_diagnosticCode, Optional.empty()));
// We don't forward the code if it's -1 since some tools will assume that this is actually
// the diagnostic code and show it or attempt to use it. This will ensure tools consuming
// this don't all have to be adding checks for -1.
if (_diagnosticCode == "-1") {
return Optional.empty();
} else {
// NOTE: It's important for compatibility that we only construct a
// DiagnosticCode here to maintain compatibility with older versions of
// zinc while using this newer version of the compiler. If we would
// contstruct it earlier, you'd end up with ClassNotFoundExceptions for
// DiagnosticCode.
return Optional.of(new DiagnosticCode(_diagnosticCode, Optional.empty()));
}
}

@Override
Expand Down