-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Sema: Eliminate typeCheckExpression() calls from convertLiteralInPlace() #16278
Conversation
27a3f35
to
08d22a1
Compare
@swift-ci Please test |
@swift-ci Please test source compatibility |
@swift-ci Please test Linux |
Build failed |
08d22a1
to
72a6676
Compare
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.
72a6676
to
e24fbbb
Compare
@swift-ci Please test source compatibility |
1 similar comment
@swift-ci Please test source compatibility |
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please test source compatibility |
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? |
@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. |
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.