-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Error message for enum case in non-enum class companion object #3197
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
Changes from 7 commits
7c9bd2b
430c3d0
746efc3
e548606
8eac58d
f429f3a
fe21e42
f4e6b59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1777,5 +1777,15 @@ object messages { | |
val explanation = | ||
hl"""A class marked with the ${"final"} keyword cannot be extended""" | ||
} | ||
|
||
case class EnumCaseDefinitionInNonEnumOwner(owner: Symbol)(implicit ctx: Context) | ||
extends Message(EnumCaseDefinitionInNonEnumOwnerID) { | ||
val kind = "Syntax" | ||
val msg = em"case not allowed here, since owner `${owner}` is not an `${"enum"}` object" | ||
val explanation = | ||
hl""" | ||
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. Start your message here and remove the whitespaces after |
||
| `${"case"}` is only allowed at this place if the surrounding object is the companion object of an `${"enum"} ${"class"}`. | ||
| If you wanted to create an enumeration make sure that the corresponding class has the `${"enum"}` keyword. | ||
| Otherwise you might have forgotten `${"class"}` or `${"object"}` after this `${"case"}` here. | ||
""" | ||
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. I would prefer something like: val explanation =
hl"""${"enum"} cases are only allowed within the companion ${"object"} of an ${"enum class"}.
|If you want to create an ${"enum"} case, make sure the corresponding ${"enum class"} exists
|and has the ${"enum"} keyword.""" 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. Let's take that. |
||
} | ||
} |
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.
You shouldn't backtick
owner
andenum
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.
should be fixed