Skip to content

[DiagnosticsQoI] Strike VarDecls in Pattern Binding Initializers From Overloads #27668

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
Oct 14, 2019

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Oct 14, 2019

We would previously consider the VarDecls bound by a particular pattern
binding initializer context when performing overload resolution. This
would lead to circular validation. Validation was tacitly breaking the
cycle by returning an error type (but, crucially, not setting that
interface type). Instead, pre-reject circular candidates.

This greatly improves the diagnostic we emit here in truly circular
cases since we can ride on UR_InstanceMemberOnType to yield

struct PatternBindingWithTwoVars2 { var x = y, y = x }
// cannot use instance member 'y' within property initializer; property initializers run before 'self' is available

We would previously consider the VarDecls bound by a particular pattern
binding initializer context when performing overload resolution.  This
would lead to circular validation.  Validation was tacitly breaking the
cycle by returning an error type (but, crucially, not setting that
interface type).  Instead, pre-reject circular candidates.

This greatly improves the diagnostic we emit here in truly circular
cases since we can ride on `UR_InstanceMemberOnType` to yield

struct PatternBindingWithTwoVars2 { var x = y, y = 3 }
// cannot use instance member 'y' within property initializer; property initializers run before 'self' is available
@CodaFi CodaFi requested a review from xedin October 14, 2019 18:55
@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 14, 2019

@swift-ci please smoke test

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 14, 2019

@swift-ci please test source compatibility

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 14, 2019

There's that old UPASS...

⛵️

@CodaFi CodaFi merged commit ca19a9d into swiftlang:master Oct 14, 2019
@CodaFi CodaFi deleted the disqualified-lookup branch October 14, 2019 23:15
CodaFi added a commit to CodaFi/swift that referenced this pull request Oct 16, 2019
Extend swiftlang#27668 by declining to validate the type of variables
bound by a pattern binding initializer when computing an effective
overload type while rooted at that initializer.
CodaFi added a commit to CodaFi/swift that referenced this pull request Oct 21, 2019
Resolve a cycle caused by overload resolution considering recursive
static candidates where before it would silently reject them.  In
a world before the InterfaceTypeRequest, the overload resolution
machinery would attempt to validate the declaration and would recieve
a bad answer.  This caused circular candidates to be ignored as a side
effect.  This behavior was partially restored by the fixes in swiftlang#27725 and swiftlang#27668
but that isn't enough for recursive static variables.  Even if it were,
the constraint fix kind doesn't make sense.

Luckily, the right answer is to just reject recursive static VarDecl
candidates entirely.

Addresses rdar://56410015
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.

2 participants