-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Improve diagnostics for generics in enum case #69055
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 3 commits
1a5359b
7453af9
601e11d
109e138
266fa16
67694b7
49026e6
1be158a
e2c26c9
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 |
|---|---|---|
|
|
@@ -636,3 +636,15 @@ if case nil = foo1 {} // Okay | |
| if case .none? = foo1 {} // Okay | ||
| if case nil = foo2 {} // Okay | ||
| if case .none?? = foo2 {} // Okay | ||
|
|
||
| enum EnumCaseWithGenericDeclaration { | ||
| case foo<T>(T) // expected-error {{generic signature cannot be declared in enum 'case'. did you mean to attach it to enum declaration?}} | ||
|
||
| case bar<T>(param: T) // expected-error {{generic signature cannot be declared in enum 'case'. did you mean to attach it to enum declaration?}} | ||
| case baz<T> // expected-error {{generic signature cannot be declared in enum 'case'. did you mean to attach it to enum declaration?}} | ||
| case one, two<T> // expected-error {{generic signature cannot be declared in enum 'case'. did you mean to attach it to enum declaration?}} | ||
| case three<T>, four // expected-error {{generic signature cannot be declared in enum 'case'. did you mean to attach it to enum declaration?}} | ||
| case five<T>(param: T), six // expected-error {{generic signature cannot be declared in enum 'case'. did you mean to attach it to enum declaration?}} | ||
| // expected-error@+2 {{generic signature cannot be declared in enum 'case'. did you mean to attach it to enum declaration?}} | ||
| // expected-error@+1 {{generic signature cannot be declared in enum 'case'. did you mean to attach it to enum declaration?}} | ||
| case seven<T>, eight<U> | ||
| } | ||
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.
Because this diagnosis falls through without returning, you can move this generic result check to be done prior to the previous if statement (which parses the argument type)
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.
good suggestion. done.