Skip to content

Move to error case classes (Friday) #2484

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 3 commits into from
May 19, 2017

Conversation

ennru
Copy link
Contributor

@ennru ennru commented May 19, 2017

Main effort was to move to error case classes in Checking.scala, some more explanations could be beneficial.
All changed scenarios are covered in ErrorMessagesTests.

DoesNotConformToSelfTypeCantBeInstantiated used to be without source position, don't know why.

@felixmulder I warned you ;-)

ennru added 2 commits May 19, 2017 22:38
Main effort was to move to error case classes, some more explanations could be needed.All error changed scenarios are covered in ErrorMessagesTests.
@felixmulder
Copy link
Contributor

😆

Alright!

case class AbstractMemberMayNotHaveModifier(sym: Symbol, flag: FlagSet)(
implicit ctx: Context)
extends Message(AbstractMemberMayNotHaveModifierID) {
val msg = hl"""abstract $sym may not have `$flag' modifier"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could've been hl"""${"abstract"} $sym..."""

extends Message(TraitsMayNotBeFinalID) {
val msg = hl"""$sym may not be ${"final"}"""
val kind = "Syntax"
val explanation = "A trait can never be final."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~"...because you cant instantiate it since it is abstract by nature" or something?

extends Message(CannotExtendAnyValID) {
val msg = hl"""$sym cannot extend ${"AnyVal"}"""
val kind = "Syntax"
val explanation = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something we can say here in explanation? I know you wanted to just get everything over to the new format first - but can't help myself 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Traits do not support extending AnyVal" ?
"AnyVal instances must be representable in a single value, which excludes usage of traits"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave it up to your discretion :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone tries to make a trait extending AnyVal, they should be told about universal traits (traits extending Any): http://docs.scala-lang.org/overviews/core/value-classes.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leads to the question how we'd support adding relevant links to Messages. Links to the lang specs will be helpful in many cases, Stackoverflow might be good, too.
But links do not always age well.

@felixmulder felixmulder merged commit d204179 into scala:master May 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants