Skip to content

Sema: Eliminate typeCheckExpression() calls from convertLiteralInPlace() #16278

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
May 2, 2018

Conversation

slavapestov
Copy link
Contributor

Currently this is only used for string literals, but soon I'd like to look into using it for other literal kinds too, eliminating some usages of callWitness() in the process.

@slavapestov slavapestov force-pushed the simpler-string-literals branch from 27a3f35 to 08d22a1 Compare May 1, 2018 06:47
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please test Linux

@swift-ci
Copy link
Contributor

swift-ci commented May 1, 2018

Build failed
Swift Test Linux Platform
Git Sha - 08d22a14261a821a4d7f58cf138eb1769f3c8769

@slavapestov slavapestov force-pushed the simpler-string-literals branch from 08d22a1 to 72a6676 Compare May 1, 2018 22:56
The condition we want to test for emitting a downcast is isRequired(),
not isInheritable(). The latter is only true for convenience
initializers.

The other fix is that we actually have to emit a class_method
dispatch here to support class hierarchies conforming to literal
protocols.
This code dates back to the dark ages when forming substitutions
was something only the constraint solver could do.

Now that findNamedWitnessImpl() returns a ConcreteDeclRef instead
of a ValueDecl, we don't have to build a whole constraint system
and type check it just to form substitutions for the call.
@slavapestov slavapestov force-pushed the simpler-string-literals branch from 72a6676 to e24fbbb Compare May 1, 2018 23:42
@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented May 1, 2018

Build failed
Swift Test Linux Platform
Git Sha - 08d22a14261a821a4d7f58cf138eb1769f3c8769

@swift-ci
Copy link
Contributor

swift-ci commented May 1, 2018

Build failed
Swift Test OS X Platform
Git Sha - 08d22a14261a821a4d7f58cf138eb1769f3c8769

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit a8d831f into swiftlang:master May 2, 2018
@jrose-apple
Copy link
Contributor

A bunch of stuff snuck into this PR that doesn't have anything to do with Sema. Can you try to avoid doing that in the future?

@slavapestov
Copy link
Contributor Author

slavapestov commented May 2, 2018

@jrose-apple The SIL.rst change was unrelated, but the SILGen changes were required because Sema now produces slightly different expressions in the case of a string literal modeled by a subclass of a class adopting ExpressibleByStringLiteral. I also consolidated some SILGen tests and added a test for a generic function producing a string literal, since an earlier version of this PR broke that and the problem was only exposed by building corelibs-foundation. I should’ve made the commit message clearer but those were related changes required to get everything working with the Sema change.

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