Skip to content

SILGen: Properly calculate substitutions to invoke _bridgeToObjectiveC. #4990

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
Sep 26, 2016

Conversation

jckarter
Copy link
Contributor

The existing code assumed that the _bridgeToObjectiveC witness would never come from a protocol extension. Generating the correct set of substitutions is a bit harder than it ought to be, due to inconsistencies in how Sema represents generic witnesses. The right thing to do is probably to emit a witness_method invocation and let the specializer work out the underlying witness, but for now, get a minimal fix in place for 3.x. Fixes rdar://problem/28279269.

@jckarter
Copy link
Contributor Author

@swift-ci Please smoke test

@jckarter
Copy link
Contributor Author

@slavapestov Mind reviewing for 3.x?

@jckarter
Copy link
Contributor Author

@adrian-prantl Any idea where this assertion failure would come from?

Assertion failed: (!MainSourceFileName.empty() && "main source file name is empty"), function IRGenDebugInfo, file /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/lib/IRGen/IRGenDebugInfo.cpp, line 127.

@atrick
Copy link
Contributor

atrick commented Sep 24, 2016

Adrian reverted here... it should merge soon
#4986

@adrian-prantl
Copy link
Contributor

@jckarter: It definitely came from my #4963 but I haven't figured out how it went through PR testing only to then fail in PR testing.

@jckarter
Copy link
Contributor Author

@swift-ci Please smoke test OS X

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

Looks good for 3.0. Let's spend some time thinking about the right abstractions so we can clean this up later -- along with witness thunk emission, and the stuff in the devirtualizer for building substitutions...

ArrayRef<Substitution> substitutions =
swiftValueType->gatherAllSubstitutions(
gen.SGM.SwiftModule, nullptr);
ArrayRef<Substitution> witnessSubstitutions = witness.getSubstitutions();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pretty epic -- I wanted to clean up witness substitutions at some point since I've got a few changes that are blocked on representation issues, and this provides even more motivation.

GenericEnvironment *witnessEnv;
GenericSignature *witnessSig;

if (witness.getDecl()->getDeclContext()->getDeclaredTypeOfContext()
Copy link
Contributor

Choose a reason for hiding this comment

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

getMemberSubstitutions() does the right thing for a member of a protocol vs member of a concrete type (it takes a base and a DC for the member), but this is fine for now.

The existing code assumed that the _bridgeToObjectiveC witness would never come from a protocol extension. Generating the correct set of substitutions is a bit harder than it ought to be, due to inconsistencies in how Sema represents generic witnesses. Fixes rdar://problem/28279269.
@jckarter
Copy link
Contributor Author

@swift-ci Please smoke test

1 similar comment
@jckarter
Copy link
Contributor Author

@swift-ci Please smoke test

@jckarter
Copy link
Contributor Author

Linux failure looks unrelated. @ddunbar or @parkera, you know what's going on here?

/home/buildnode/jenkins/workspace/swift-PR-Linux-smoke-test/branch-master/buildbot_linux/swiftpm-linux-x86_64/debug/swift-build-stage1: error while loading shared libraries: libFoundation.so: cannot open shared object file: No such file or directory
--- bootstrap: error: build failed with exit status 127

@jckarter
Copy link
Contributor Author

@swift-ci Please smoke test Linux

@jckarter jckarter merged commit a162c6b into swiftlang:master Sep 26, 2016
@jckarter jckarter deleted the rdar28279269 branch September 26, 2016 17:47
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.

4 participants