Skip to content

Conversation

@rjmccall
Copy link
Contributor

@rjmccall rjmccall commented Nov 16, 2018

Most of the foundation for this was laid in earlier patches.

This PR should not be merged because it arguably requires Evolution approval.

I was considered adding an -enable-error-self-conformance flag and merging this so that people could test it. Unfortunately, testing it would require the stdlib to be built under that flag, and doing that by default would change the ABI of the stdlib — and avoiding that ABI change is exactly why I can't merge this patch yet. So no dice.

PRs this depends on that aren't in the 5.0 branch: #20658, #20662

@rjmccall rjmccall requested a review from DougGregor November 16, 2018 06:49
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@rjmccall rjmccall changed the title Allow Error to conform to itself [DNM] Allow Error to conform to itself Nov 16, 2018
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Huh. This is a not nearly as complicated as I would have thought

Copy link
Member

Choose a reason for hiding this comment

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

You can use protocol->getProtocolSelfType() here, FWIW

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Member

Choose a reason for hiding this comment

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

You'll need to update swift::_conformsToProtocol in the runtime, because it has a path that will need to know that an error existential conforms to the Error protocol. (Right now it only considers @objc existentials to conform to their protocols). You can exercise the code by evaluating a conditional conformance at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually Just Works, probably because I'm generating an ordinary conformance with a conformance descriptor whose conforming type is linked correctly back to the protocol (by a cavalcade of different PRs). But as discussed privately, I'll flesh out the tests for various cases of this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this is a JIT test and not a build a binary and run it test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I'll fix that.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c86f9579b3fc7779f02aa2ef7b824815b86d4f98

@rjmccall rjmccall force-pushed the error-self-conformance branch from c86f957 to f33dfff Compare November 16, 2018 08:05
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

1 similar comment
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f33dfffe77e69f0ec064fec9420472b624e71ca6

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f33dfffe77e69f0ec064fec9420472b624e71ca6

@rjmccall rjmccall force-pushed the error-self-conformance branch from f33dfff to 976e5be Compare November 16, 2018 21:51
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f33dfffe77e69f0ec064fec9420472b624e71ca6

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f33dfffe77e69f0ec064fec9420472b624e71ca6

@rjmccall rjmccall force-pushed the error-self-conformance branch from 976e5be to e6072f5 Compare November 16, 2018 22:57
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 976e5be00628ee7d9f3a16bf03bd6fa98ad195e5

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 976e5be00628ee7d9f3a16bf03bd6fa98ad195e5

@rjmccall rjmccall force-pushed the error-self-conformance branch from e6072f5 to c66ad97 Compare November 17, 2018 04:10
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@rjmccall
Copy link
Contributor Author

@swift-ci Please test source compatibility.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e6072f563ac79a64bf838045a3d4f5b41d72f9f4

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e6072f563ac79a64bf838045a3d4f5b41d72f9f4

@rjmccall
Copy link
Contributor Author

rjmccall commented Nov 17, 2018

That's a real bug caught by the compatibility suite, not just a source compatibility problem.

@rjmccall
Copy link
Contributor Author

...oh, but I think it's actually caused by the change I made to ProtocolConformanceRef::subst.

@rjmccall rjmccall force-pushed the error-self-conformance branch from c66ad97 to 3f6bdc2 Compare November 17, 2018 07:20
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c66ad971d0f63f7c4e225586230a61dec681969b

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c66ad971d0f63f7c4e225586230a61dec681969b

Most of the foundation for this was laid in earlier patches.
@rjmccall rjmccall force-pushed the error-self-conformance branch from 3f6bdc2 to 49ba9c5 Compare November 17, 2018 07:52
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3f6bdc2a8e82fe7c9dfafeee11f37212d1c86fec

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3f6bdc2a8e82fe7c9dfafeee11f37212d1c86fec

@rjmccall
Copy link
Contributor Author

@swift-ci Please test OS X

@rjmccall
Copy link
Contributor Author

rjmccall commented Dec 5, 2018

@swift-ci Please test.

@rjmccall rjmccall changed the title [DNM] Allow Error to conform to itself Allow Error to conform to itself Dec 5, 2018
@rjmccall rjmccall merged commit 8112f68 into swiftlang:master Dec 6, 2018
rjmccall added a commit to rjmccall/swift that referenced this pull request Dec 6, 2018
@rjmccall rjmccall deleted the error-self-conformance branch December 6, 2018 03:12
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