-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #3784 : add an enum for Error kind #3785
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4c372e7
fix #3784
3a16862
put back old error msg
cf24c76
rename kind as category, and use a Scala case class instead of a Java…
f624ef9
respect scala convention
7b933f6
Merge remote-tracking branch 'upstream/master' into enum-for-error-kinds
aesteve File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorKind.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dotty.tools.dotc.reporting.diagnostic; | ||
|
||
public enum ErrorKind { | ||
|
||
COMPATIBILITY("Compatibility"), | ||
DEFINITION_NOT_FOUND("Definition Not Found"), | ||
DUPLICATE_SYMBOL("Duplicate Symbol"), | ||
MATCH_CASE_UNREACHABLE("Match case Unreachable"), | ||
MEMBER_NOT_FOUND("Member Not Found"), | ||
NAMING("Naming"), | ||
NO_KIND(""), | ||
PATTERN_MATCH_EXHAUSTIVITY("Pattern Match Exhaustivity"), | ||
REFERENCE("Reference"), | ||
SYNTAX("Syntax"), | ||
TYPE_MISMATCH("Type Mismatch"), | ||
UNBOUND_IDENTIFIER("Unbound Identifier"), | ||
USAGE("Usage"); | ||
|
||
private String repr; | ||
ErrorKind(String repr) { | ||
this.repr = repr; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return repr; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ abstract class Message(val errorId: ErrorMessageID) { self => | |
/** The kind of the error message is something like "Syntax" or "Type | ||
* Mismatch" | ||
*/ | ||
def kind: String | ||
def kind: ErrorKind | ||
|
||
/** The explanation should provide a detailed description of why the error | ||
* occurred and use examples from the user's own code to illustrate how to | ||
|
@@ -117,7 +117,7 @@ class ExtendMessage(_msg: () => Message)(f: String => String) { self => | |
/** The fallback `Message` containing no explanation and having no `kind` */ | ||
class NoExplanation(val msg: String) extends Message(ErrorMessageID.NoExplanationID) { | ||
val explanation = "" | ||
val kind = "" | ||
val kind = ErrorKind.NO_KIND | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the change I proposed, this should become |
||
|
||
override def toString(): String = s"NoExplanation($msg)" | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to have this in Scala.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are already using java enums for ErrorMessageID. I think it is fine to stick to java enum until we migrate everything to Dotty enum.
I would however use Scala naming convention:
NoKind
instead ofNO_KIND
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
But move
NoKind
to the first position.