Skip to content

Commit 022c6ac

Browse files
authored
Merge pull request #27802 from CodaFi/a-statics-to-match-your-dynamics
Break Another Overload Resolution Cycle
2 parents 1914417 + a537e04 commit 022c6ac

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4970,8 +4970,13 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
49704970
if (auto *PBI = dyn_cast<PatternBindingInitializer>(DC)) {
49714971
if (auto *VD = dyn_cast<VarDecl>(decl)) {
49724972
if (PBI->getBinding() == VD->getParentPatternBinding()) {
4973-
result.addUnviable(candidate,
4974-
MemberLookupResult::UR_InstanceMemberOnType);
4973+
// If this is a recursive reference to an instance variable,
4974+
// try to see if we can give a good diagnostic by adding it as
4975+
// an unviable candidate.
4976+
if (!VD->isStatic()) {
4977+
result.addUnviable(candidate,
4978+
MemberLookupResult::UR_InstanceMemberOnType);
4979+
}
49754980
return;
49764981
}
49774982
}

test/decl/circularity.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,15 @@ class Sub: Base {
4343
return foo(1) // expected-error {{variable used within its own initial value}}
4444
}()
4545
}
46+
47+
extension Float {
48+
static let pickMe: Float = 1
49+
}
50+
51+
extension SIMD3 {
52+
init(_ scalar: Scalar) { self.init(repeating: scalar) }
53+
}
54+
55+
extension SIMD3 where SIMD3.Scalar == Float {
56+
static let pickMe = SIMD3(.pickMe)
57+
}

0 commit comments

Comments
 (0)