Skip to content

[Runtime] SE-0143: Evaluate conditional conformances at runtime. #14368

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

Conversation

DougGregor
Copy link
Member

When evaluating whether a given type conforms to a protocol, evaluate the
conditional requirements and pass the results to the witness table
accessor function. This provides the ability to query conditional
conformances at runtime, and is the last major part of implementing
SE-0143.

The newly-added unlock/lock dance in the conformance lookup code is a
temporary stub. We have some ideas to do this better.

Fixes rdar://problem/34944655.

@DougGregor
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Feb 2, 2018

Build failed
Swift Test OS X Platform
Git Sha - e72051a7a441e1a0a3ba7bb4a42886b1f2d5a303

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

Copy link
Contributor

@gparker42 gparker42 left a comment

Choose a reason for hiding this comment

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

TwoWordPair is going away in #14373. This should wait until that merges.

@DougGregor
Copy link
Member Author

Bah, it's going to conflict with #14373 even once I've reverted the first commit. I'll rebase once that goes in.

@DougGregor DougGregor force-pushed the se-0143-runtime-conditional-conformances branch from 997ca4b to 1e2ddc3 Compare February 3, 2018 00:38
@DougGregor DougGregor dismissed gparker42’s stale review February 3, 2018 00:40

Okay, it's in; rebased

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

…ances.

Extend protocol conformance descriptors with two more bits of information:

* For retroactive conformances, add the module in which the conformance
  occurs. This will eventually be used for error reporting/ambiguity
  resolution when retroactive conformances collide.
* For conditional conformances, add the conditional requirements. We need
  these for runtime evaluation of conditional conformances.
When evaluating whether a given type conforms to a protocol, evaluate the
conditional requirements and pass the results to the witness table
accessor function. This provides the ability to query conditional
conformances at runtime, and is the last major part of implementing
SE-0143.

The newly-added unlock/lock dance in the conformance lookup code is a
temporary stub. We have some ideas to do this better.

Fixes rdar://problem/34944655.
@DougGregor DougGregor force-pushed the se-0143-runtime-conditional-conformances branch from 1e2ddc3 to 81f1574 Compare February 3, 2018 00:41
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 87f7b4e into swiftlang:master Feb 3, 2018
@DougGregor DougGregor deleted the se-0143-runtime-conditional-conformances branch February 3, 2018 02:21

Runtime query of conditional conformances is now implemented. Therefore,
a dynamic cast such as `value as? P`, where the dynamic type of `value`
conditional conforms to `P`, will succeed when the conditional
Copy link
Contributor

@jckarter jckarter Feb 3, 2018

Choose a reason for hiding this comment

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

*conditionally conforms

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, thanks. I'll fix that in a follow-up commit.

@pitiphong-p
Copy link
Contributor

Will this Evaluate conditional conformances at runtime get into Swift 4.1?

@jckarter
Copy link
Contributor

jckarter commented Feb 8, 2018

No.

@DougGregor
Copy link
Member Author

@pitiphong-p : No, this will not go into Swift 4.1. It's dependent on a large number of changes in the Swift compiler and runtime that would not be safe to back port to Swift 4.1.

@pitiphong-p
Copy link
Contributor

I see. Thank you.

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.

5 participants