Skip to content

[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

Merged
merged 1 commit into from
Jan 19, 2017

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jan 19, 2017

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.

// 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())
Copy link
Contributor

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?

Copy link
Contributor Author

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>

Copy link
Contributor

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?

Copy link
Contributor Author

@xedin xedin Jan 19, 2017

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()) ?

Copy link
Contributor Author

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.

@slavapestov
Copy link
Contributor

@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.
@xedin
Copy link
Contributor Author

xedin commented Jan 19, 2017

@swift-ci Please smoke test

1 similar comment
@slavapestov
Copy link
Contributor

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor

@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.

@xedin
Copy link
Contributor Author

xedin commented Jan 19, 2017

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 :)

@jrose-apple
Copy link
Contributor

This is true. I don't think it's harmful to retry but it should do it automatically. @shahmishal?

@slavapestov slavapestov merged commit 7370523 into swiftlang:master Jan 19, 2017
@shahmishal
Copy link
Member

Yes, it will automatically try again.

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