-
Notifications
You must be signed in to change notification settings - Fork 10.5k
IRGen: Don't assert on keypaths that use a subclass as root #21592
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 1 commit
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 |
---|---|---|
|
@@ -837,6 +837,21 @@ emitKeyPathComponent(IRGenModule &IGM, | |
// ObjC-ness and resilience of the class hierarchy, there might be a few | ||
// different ways we need to go about this. | ||
if (loweredBaseTy.getClassOrBoundGenericClass()) { | ||
|
||
// Walk up the class hierarchy to find the class decl that matches the | ||
// property's class decl and use this type to determin the field access. | ||
auto propertyBaseDecl = property->getDeclContext()->getSelfClassDecl(); | ||
auto currentBaseTy = loweredBaseTy.getASTType(); | ||
while (currentBaseTy->getClassOrBoundGenericClass() != propertyBaseDecl && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This loop is already encapsulated in |
||
currentBaseTy->getClassOrBoundGenericClass()->hasSuperclass()) { | ||
currentBaseTy = currentBaseTy->getClassOrBoundGenericClass() | ||
->getSuperclass() | ||
->getCanonicalType(); | ||
} | ||
assert(currentBaseTy->getClassOrBoundGenericClass() == propertyBaseDecl); | ||
loweredBaseTy = IGM.getLoweredType(AbstractionPattern::getOpaque(), | ||
currentBaseTy->getWithoutSpecifierType()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it ever have a specifier type? (inout or lvalue here)? Might be better to assert. |
||
|
||
switch (getClassFieldAccess(IGM, loweredBaseTy, property)) { | ||
case FieldAccess::ConstantDirect: { | ||
// Known constant fixed offset. | ||
|
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 feels like something SILGen should have already done? CC @jckarter
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.
That might be cleaner, yeah. Then we can assert the condition in the SILVerifier too.