Skip to content

Update SK_LastScoreKind to SK_KeyPathSubscript. #9996

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
May 31, 2017
Merged

Update SK_LastScoreKind to SK_KeyPathSubscript. #9996

merged 1 commit into from
May 31, 2017

Conversation

rudkx
Copy link
Contributor

@rudkx rudkx commented May 31, 2017

When this score kind was added, the marker for the last score kind was
not updated. As a result, increasing the score for SK_KeyPathSubscript
was not actually having an effect.

Add tests that include a type with subscripts that also take the key
paths as their argument with an identical argument label ("keyPath").

These tests show that we're actually falling back on the keypath
application in many cases despite the score kind specific to keypath
application. I'll open a couple new JIRAs to investigate this
behavior.

The update to SK_LastScoreKind results in fixing a crash in these tests
that happens as a result of an assumption in CSRanking.cpp that if we're
comparing two solutions we end up with decls for overloads to compare,
which isn't the case here due to the keypath application.

When this score kind was added, the marker for the last score kind was
not updated. As a result, increasing the score for SK_KeyPathSubscript
was not actually having an effect.

Add tests that include a type with subscripts that also take the key
paths as their argument with an identical argument label ("keyPath").

These tests show that we're actually falling back on the keypath
application in many cases despite the score kind specific to keypath
application. I'll open a couple new JIRAs to investigate this
behavior.

The update to SK_LastScoreKind results in fixing a crash in these tests
that happens as a result of an assumption in CSRanking.cpp that if we're
comparing two solutions we end up with decls for overloads to compare,
which isn't the case here due to the keypath application.
@rudkx rudkx requested a review from jckarter May 31, 2017 04:09
@rudkx
Copy link
Contributor Author

rudkx commented May 31, 2017

@swift-ci Please smoke test

@rudkx
Copy link
Contributor Author

rudkx commented May 31, 2017

@jckarter FYI: I opened https://bugs.swift.org/browse/SR-5052 and https://bugs.swift.org/browse/SR-5053 for the issues I noticed here.

If my assumptions about what should be happening here as noted in the test is wrong, let me know!

@rudkx rudkx merged commit 784ccb2 into swiftlang:master May 31, 2017
@rudkx rudkx deleted the fix-keypath-subscript-score-kind branch May 31, 2017 07:02
subscript(keyPath: KeyPath<ZwithSubscript, Int>) -> Int { return 0 }
subscript(keyPath: WritableKeyPath<ZwithSubscript, Int>) -> Int { return 0 }
subscript(keyPath: ReferenceWritableKeyPath<ZwithSubscript, Int>) -> Int { return 0 }
subscript(keyPath: PartialKeyPath<ZwithSubscript>) -> Any { return 0 }
Copy link
Contributor

Choose a reason for hiding this comment

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

Subscripts don't have significant labeled arguments unless you explicitly ask for them, so all of these declarations really declare subscript(_:). You'd have to declare subscript(keyPath kp: ...) to test overloading.

@rudkx
Copy link
Contributor Author

rudkx commented May 31, 2017

Oh yes, thanks for pointing that out. I updated the tests to add the labeled argument and updated the output accordingly. #10001

It's still unfortunate that for subscripts with only getters we fall back on the key path application when attempting to do an assignment.

@jckarter
Copy link
Contributor

Yeah, I suspect that's fallout from us modeling @lvalue T as a first-class type within the type checker, so overload resolution just sees it as a return type overloading situation.

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.

2 participants