-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Tiny bit more progress on IRGen support for subclass existentials #8788
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
Tiny bit more progress on IRGen support for subclass existentials #8788
Conversation
@swift-ci Please smoke test |
// -- ObjC-refcounted archetype | ||
// CHECK: store i8** getelementptr inbounds (i8*, i8** @_T0BOXoWV, i32 17) | ||
unowned(safe) var os: ObjC | ||
// CHECK: store i8** getelementptr inbounds (i8*, i8** @_T0BomWV, i32 17) |
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 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 catch. It would need to be more conservative.
reprTy = IGM.RefCountedPtrTy; | ||
} else { | ||
reprTy = IGM.UnknownRefCountedPtrTy; | ||
} | ||
} | ||
|
||
// As a hack, assume class archetypes never have spare bits. There's 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.
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.
Yeah, that would work and be a bit more optimal. If we don't already, we should also check the @_unsafe_no_tagged_pointer
attribute and whether ObjC interop is enabled at all.
7831185
to
f30ee81
Compare
inheritedType.getType()->getExistentialTypeProtocols(protocols); | ||
auto layout = type->getExistentialLayout(); | ||
assert(!layout.superclass && "Should not have a subclass existential " | ||
"in the inheritance clause of an extension"); |
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.
This assertion isn't valid; this code runs even when type-checking fails.
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.
Do you have a test case in mind I can try? I'll address this in an upcoming patch along with the other stuff above about spare bits.
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 think even just the obvious thing would crash:
// compile with -emit-reference-dependencies and check the resulting swiftdeps file
class MyClass {}
extension Int: (MyClass & Equatable) {}
Tested by an upcoming patch that adds IRGen SIL tests.
f30ee81
to
03373a1
Compare
@swift-ci Please smoke test |
The next step after #8770. Make sure we use the right reference counting style for subclass existentials and class-constrained archetypes. Also, finally remove the
getExistentialTypeProtocols()
utility method.