-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[.]Type
completion for (any P).
shows it will produce an existential metatype
#65843
Comments
@Rajveer100 This one is somewhat less involved if you’re interested. |
So do you suggest working on this, before #65699? |
Yeah, I think that’s a good idea if this is your first time working on code completion. |
error: |
@AnthonyLatsis What could be the cause for this? |
Stale build artifacts, for example. Rule no. 1 (assuming your checkout revisions are in sync): try a clean build. |
Nope, still doesn't work, my local repo is in-fact synced and I also tried doing a clean rebuild, same error. |
I can't tell much about what went wrong without more context. Can you share the steps you took originally and after my suggestion? |
I mean the only thing I did is change my target scheme to swift-ide-test, as you said to test for code completion. |
Ah, so you're getting this error in Xcode, not as a result of invoking |
Oh yeah, I used the existing one! |
So I need to create a new scheme with the target as swift-ide-test? Any other configurations that's needed like it was in swift-frontend? |
You need to follow the exact same steps, but for the |
Now it builds successfully and does run with the following output:
|
@AnthonyLatsis I added the following as
|
Good job puzzling out how to output completions for a single token! As in the Swift frontend, this tool requires a path to an input source file to read from: |
Got this:
|
I am aware of |
The singleton metatype is simply the metatype of a given type The places to debug should be correct. |
Yeah that gave me a good idea! Let me try to debug! |
@AnthonyLatsis
Is my intuition right? |
Do we want an extra bracket |
@AnthonyLatsis |
Yes, this very much looks like the cause. You have to understand that
Hence |
In this function: inline bool CanType::isExistentialTypeImpl(CanType type) {
return isa<ProtocolType>(type) ||
isa<ProtocolCompositionType>(type) ||
isa<ExistentialType>(type) ||
isa<ParameterizedProtocolType>(type);
} Why are Protocols considered as |
For no good reason. That this has not been known to cause problems is a slightly worrying fluke. Before a separate representation for existential types was adopted in the model, this function worked with what is now known as a constraint type — protocol and protocol composition types. Then (apparently during the transition) someone added the |
At the moment I feel there could be the following possibilities:
|
The current logic assumes that a postfix This is true for |
If the canonical type remains the same shouldn't this check succeed: !instanceTy->getCanonicalType()->is<MetatypeType>() |
I’m not catching on to the causal relationship, but yes, the instance type is not a metatype in either of the above cases. |
…n metatype instead of existential metatype. Resolves swiftlang#65843
Let me give the explanation another shot.
If you feel unconfident around |
Also from the SE-0335 .md: Spell the existential metatype as Reiterating part of the above: |
…n metatype instead of existential metatype. Resolves swiftlang#65843
…n metatype instead of existential metatype. Resolves swiftlang#65843
Test case:
This test will fail, because the current completion is
Type[#any P.Type#]; name=Type
. Notice how it thinks the completion will produce an existential metatypeany P.Type
, whereas the actual result is the singleton metatype(any P).Type
.Environment
The text was updated successfully, but these errors were encountered: