-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add error message for only functional erased or implicit types #7848
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
Add error message for only functional erased or implicit types #7848
Conversation
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.
Otherwise LGTM, the CI failure doesn't seem to be related.
@@ -1423,9 +1423,9 @@ object Parsers { | |||
case FORSOME => syntaxError(ExistentialTypesNoLongerSupported()); t | |||
case _ => | |||
if (imods.isOneOf(GivenOrImplicit) && !t.isInstanceOf[FunctionWithMods]) | |||
syntaxError("Types with implicit keyword can only be function types `implicit (...) => ...`", implicitKwPos(start)) | |||
syntaxError(ImplicitTypesCanOnlyBeFunctionTypes()) |
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's nicer when the error message highlights the keyword in question rather than just points to the location after the erroneous type.
syntaxError(ImplicitTypesCanOnlyBeFunctionTypes()) | |
syntaxError(ImplicitTypesCanOnlyBeFunctionTypes(), implicitKwPos(start)) |
if (imods.is(Erased) && !t.isInstanceOf[FunctionWithMods]) | ||
syntaxError("Types with erased keyword can only be function types `erased (...) => ...`", implicitKwPos(start)) | ||
syntaxError(ErasedTypesCanOnlyBeFunctionTypes()) |
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.
syntaxError(ErasedTypesCanOnlyBeFunctionTypes()) | |
syntaxError(ErasedTypesCanOnlyBeFunctionTypes(), implicitKwPos(start)) |
case class ImplicitTypesCanOnlyBeFunctionTypes()(implicit val ctx: Context) | ||
extends Message(ImplicitTypesCanOnlyBeFunctionTypesID) { | ||
val kind: String = "Syntax" | ||
val msg: String = "Types with implicit keyword can only be function types `given (...) => ...`" |
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.
val msg: String = "Types with implicit keyword can only be function types `given (...) => ...`" | |
val msg: String = "Types with given keyword can only be function types `given (...) => ...`" |
implicit val ctx: Context = ictx | ||
assertMessageCount(1, messages) | ||
val ImplicitTypesCanOnlyBeFunctionTypes() :: Nil = messages | ||
assertEquals("Types with implicit keyword can only be function types `given (...) => ...`", messages.head.msg) |
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.
assertEquals("Types with implicit keyword can only be function types `given (...) => ...`", messages.head.msg) | |
assertEquals("Types with given keyword can only be function types `given (...) => ...`", messages.head.msg) |
f6345da
to
37dcf9b
Compare
@anatoliykmetyuk I've signed the CLA, but still see here "CLA Expected - Waiting for status to be reported " is it okay? or something more needed from my side? |
That's because we've recently made the To run that test with that flag, locate the And add the following to it: fc.setSetting(fc.settings.YerasedTerms, true) To see if your tests pass before submitting them to CI, use from SBT: testOnly dotty.tools.dotc.reporting.ErrorMessagesTests -- *TypesCanOnlyBeFunctionTypes*
The status won't update on this PR page. You can check your status here. However, it says |
37dcf9b
to
c3a72f7
Compare
no idea what problem was with my first attempt, but now sign status is true |
LGTM, thanks @hope-doe! |
No description provided.