Skip to content

[CSApply] Fix a KeyPath crash in SIL when base type is AnyObject #23497

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

Merged
merged 1 commit into from
Mar 25, 2019
Merged

[CSApply] Fix a KeyPath crash in SIL when base type is AnyObject #23497

merged 1 commit into from
Mar 25, 2019

Conversation

theblixguy
Copy link
Collaborator

This PR fixes a SIL crash when the base type of a Swift KeyPath is AnyObject. For example:

import UIKit

class Foo: NSObject {
  func crash() {
    let kp = \AnyObject.accessibilityFrame
  }
}

Resolves SR-10146.

@theblixguy
Copy link
Collaborator Author

cc @jckarter @slavapestov

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jckarter
Copy link
Contributor

@swift-ci Please test

@theblixguy
Copy link
Collaborator Author

Seems like the tests never ran

@jckarter
Copy link
Contributor

@swift-ci Please test

@jckarter jckarter merged commit 797839f into swiftlang:master Mar 25, 2019
@jckarter
Copy link
Contributor

@slavapestov raised the point that it's not a good idea to diagnose in CSApply, because we may apply multiple solutions in the face of overloading or diagnostic recovery. If we could either reject this solution in the constraint solver or in CSDiag that would be more robust.

@theblixguy
Copy link
Collaborator Author

theblixguy commented Mar 26, 2019

@jckarter Hmm we could also probably reject it in CSGen in visitKeyPathExpr as well.

I’ll create a new PR shortly to move this to the solver.

@slavapestov
Copy link
Contributor

@theblixguy I think your best bet is to reject it in the solver because you won't necessarily know the base type of the key path in CSGen. For example if I use \.dynamicMember in a context that's expecting a KeyPath<T> and T is later inferred as AnyObject. Maybe I'm missing something though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants