Skip to content

Commit cef8284

Browse files
authored
Merge pull request #18335 from gregomni/8337
2 parents 8f9fcaa + 3eed876 commit cef8284

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ AssociatedTypeInference::inferTypeWitnessesViaValueWitnesses(
176176
InferredAssociatedTypesByWitnesses result;
177177

178178
auto isExtensionUsableForInference = [&](ExtensionDecl *extension) -> bool {
179+
180+
// The extension where the conformance being checked is declared.
181+
auto conformanceExtension = checker.Conformance->
182+
getDeclContext()->getAsDeclOrDeclExtensionContext();
183+
if (extension == conformanceExtension)
184+
return true;
185+
179186
// Assume unconstrained concrete extensions we found witnesses in are
180187
// always viable.
181188
if (!extension->getExtendedType()->isAnyExistentialType()) {

test/Generics/conditional_conformances.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,3 +413,15 @@ extension Array: NestedArrayProtocol where Element: ElementProtocol, Element: Ar
413413
// with the typealias uncommented you do not get a crash.
414414
// typealias BaseElement = Element.BaseElement
415415
}
416+
417+
// SR-8337
418+
struct Foo<Bar> {}
419+
420+
protocol P {
421+
associatedtype A
422+
var foo: Foo<A> { get }
423+
}
424+
425+
extension Foo: P where Bar: P {
426+
var foo: Foo { return self }
427+
}

0 commit comments

Comments
 (0)