-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema] Fix crash on bad inheritance clause #17662
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
[Sema] Fix crash on bad inheritance clause #17662
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.
Nice catch!
@@ -956,7 +956,8 @@ void AccessControlChecker::check(Decl *D) { | |||
return false; | |||
Type ty = inherited.getType(); | |||
if (ty->is<ProtocolCompositionType>()) | |||
ty = ty->getExistentialLayout().superclass; | |||
if (auto superclass = ty->getExistentialLayout().superclass) | |||
ty = superclass; |
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.
There’s another copy of this check in the UsableFromInlineChecker too. I know that’s bad and I need to clean it up, but can you fix it and add a test?
@@ -0,0 +1,9 @@ | |||
// RUN: not %target-typecheck-verify-swift |
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.
I’d prefer it if you incorporated this test case into an existing file in test/decl/class/ somewhere.
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.
@slavapestov Thanks, I wasn't sure which to favour in this case. I've gone ahead and put the test case in test/inherit/inherit.swift, as that's where the existing "superclass '%0' must appear first in the inheritance clause" diagnostic is currently being tested – I trust this is okay?
565d00c
to
44703c8
Compare
|
||
// SR-8160 | ||
@usableFromInline | ||
class D3 : Any, A { } // expected-error{{superclass 'A' must appear first in the inheritance clause}}{{15-18=}}{{12-12=A, }} |
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.
Can you just change test/decl/inherit/inherit.swift to pass -swift-version 5?
…n checking access
44703c8
to
40fada7
Compare
@swift-ci please smoke test |
Thanks! |
When checking for the superclass type, ensure we don't use a protocol composition's superclass type if it doesn't have one.
Resolves SR-8160.