Skip to content

[5.1] [ConstraintSystem] Fix crash on function conversion reliant on conditional conformance #25739

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 4 commits into from
Jun 27, 2019
Merged

Conversation

theblixguy
Copy link
Collaborator

This PR fixes a compiler crasher related to a function conversion reliant on conditional conformance. Example:

protocol P {}
struct S<T> {}
extension S : P where T : P {}

func foo(_ fn: (S<String>) -> Void) {}
func bar(_ fn: (P) -> Void) {
  foo(fn)
}

Resolves SR-10992.


Cherry pick of #25721.

@theblixguy
Copy link
Collaborator Author

cc @xedin

@xedin
Copy link
Contributor

xedin commented Jun 25, 2019

@theblixguy Could you please squash everything into a single commit?

@theblixguy
Copy link
Collaborator Author

@xedin Done!

@xedin
Copy link
Contributor

xedin commented Jun 25, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f71921c295a585ef26c93ad0ce5b7d31d84343d7

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f71921c295a585ef26c93ad0ce5b7d31d84343d7

@xedin
Copy link
Contributor

xedin commented Jun 25, 2019

@theblixguy Looks like there are 2 tests which trigger exactly the same assert now this is trying to fix, bad squash? :)

@theblixguy
Copy link
Collaborator Author

theblixguy commented Jun 25, 2019

Oh no! I’ll fix this in a moment.

@theblixguy
Copy link
Collaborator Author

Wait this has the same changes as the other PR 🤔

@xedin
Copy link
Contributor

xedin commented Jun 25, 2019

Maybe the difference is that 5.1 doesn't have all of the changes that master has.

@xedin
Copy link
Contributor

xedin commented Jun 25, 2019

But it kind of seems unlikely in this case, because assert in old getConstraintLocator should effectively be noop now for the case when summary flags is pre-computed, maybe something else is going on here.

@theblixguy
Copy link
Collaborator Author

theblixguy commented Jun 25, 2019

It seems like there are still some uses of summaryFlags=0 left on this branch.

@theblixguy
Copy link
Collaborator Author

theblixguy commented Jun 25, 2019

@xedin should be fixed now.

@xedin
Copy link
Contributor

xedin commented Jun 25, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f76db4b

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f76db4b

@theblixguy
Copy link
Collaborator Author

Hmm getting an unrelated assertion now:

18:57:41 swift: /home/buildnode/jenkins/workspace/swift-PR-Linux/branch-swift-5.1-branch/swift/lib/Sema/CSDiagnostics.cpp:220: swift::ValueDecl *swift::constraints::RequirementFailure::getDeclRef() const: Assertion `isa(AE->getFn()) || isa(AE->getFn())' failed.

@theblixguy
Copy link
Collaborator Author

theblixguy commented Jun 25, 2019

@hamishknight seems like you were the last person who touched getDeclRef in commit 894a1e5 (PR #24826) and got rid of that assertion. I think we need your PR changes in the 5.1 branch as well.

I can either cherry-pick your commit into this branch or you can open a new PR and once your changes have been merged, we can re-run the CI to verify if this issue is fixed.

@xedin
Copy link
Contributor

xedin commented Jun 25, 2019

@theblixguy We need to figure out how to reduce the scope of the changes required, otherwise it wouldn't be able to land in 5.1

@theblixguy
Copy link
Collaborator Author

Hmm Hamish’s PR is pretty small and fixes two bugs in the process. Let me try adjusting getDeclRef only and see if the tests pass locally on my machine.

@xedin
Copy link
Contributor

xedin commented Jun 25, 2019

Alright, I'll try to look at his PR again tonight and get it in to 5.1

@theblixguy
Copy link
Collaborator Author

Sounds good!

@xedin
Copy link
Contributor

xedin commented Jun 26, 2019

@theblixguy looks like you'd have to resolve merge conflict because I can re-run CI.

@xedin
Copy link
Contributor

xedin commented Jun 26, 2019

@swift-ci please test

@theblixguy
Copy link
Collaborator Author

Sorry I messed up when fixing the merge conflict! Could you re run the CI? Thank you!

@xedin
Copy link
Contributor

xedin commented Jun 26, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e45732fd66ea65e2dedebae9213e97c88f8716e1

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e45732fd66ea65e2dedebae9213e97c88f8716e1

@theblixguy
Copy link
Collaborator Author

Nice it seems like @hamishknight’s PR solved the problem 🎉

@xedin xedin merged commit bf09fca into swiftlang:swift-5.1-branch Jun 27, 2019
@theblixguy theblixguy deleted the fix/SR-10992-5.1 branch June 27, 2019 01:48
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