-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics] Don't attempt member lookup if base type has unresolved type parameters #6910
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
Conversation
// If base type has unresolved generic parameters, such might mean | ||
// that it's initializer with erroneous argument, otherwise this would | ||
// be a simple ambigious archetype case, neither can be diagnosed here. | ||
if (baseTy->hasTypeParameter()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a bug that a type parameter shows up here in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so because while type-checking anchor of the expression, it's allowed to produce unresolved types, so in case of Array(.n).init()
it produced Array<<<unresolved>>.Iterator.Element>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you want hasUnresolved() then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kind of weird to me, but this <<unresolved>>.Iterator.Element
is actually considered a type parameter so maybe I should just check for both - if (baseTy->hasTypeParameter() && baseTy->hasUnresolved())
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's actually going to be better, that way we make sure that base is "complete" before doing anything with it, I'll make the change a bit later.
@swift-ci Please smoke test |
… type parameters If there are unresolved generic parameters present and we are trying to diagnose problems related to initializer call, it makes sense to check argument expression first, which might be erroneous and then move on to the ambiguity checking instead of trying to lookup possible constructors directly.
@swift-ci Please smoke test |
1 similar comment
@swift-ci Please smoke test |
@xedin FYI There's a bug where if you force-push to your branch, you have to try a couple of times to trigger CI. |
Cool, thanks for letting me know, @slavapestov! I think @jrose-apple told me once that if CI fails on checksum it's going to retry but it might not be the case anymore... Please let me knoe if the changes look good so I can press the button myself for the first time :) |
This is true. I don't think it's harmful to retry but it should do it automatically. @shahmishal? |
Yes, it will automatically try again. |
If there are unresolved generic parameters present and we are trying
to diagnose problems related to initializer call, it makes sense to
check argument expression first, which might be erroneous and then move
on to the ambiguity checking instead of trying to lookup possible
constructors directly.