Skip to content

Break Another Overload Resolution Cycle #27802

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 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4970,8 +4970,13 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
if (auto *PBI = dyn_cast<PatternBindingInitializer>(DC)) {
if (auto *VD = dyn_cast<VarDecl>(decl)) {
if (PBI->getBinding() == VD->getParentPatternBinding()) {
result.addUnviable(candidate,
MemberLookupResult::UR_InstanceMemberOnType);
// If this is a recursive reference to an instance variable,
// try to see if we can give a good diagnostic by adding it as
// an unviable candidate.
if (!VD->isStatic()) {
result.addUnviable(candidate,
MemberLookupResult::UR_InstanceMemberOnType);
}
return;
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/decl/circularity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,15 @@ class Sub: Base {
return foo(1) // expected-error {{variable used within its own initial value}}
}()
}

extension Float {
static let pickMe: Float = 1
}

extension SIMD3 {
init(_ scalar: Scalar) { self.init(repeating: scalar) }
}

extension SIMD3 where SIMD3.Scalar == Float {
static let pickMe = SIMD3(.pickMe)
}