Skip to content

Commit 1c9bb72

Browse files
authored
Merge pull request #21034 from DougGregor/nested-extension-generic-params
2 parents fc7830a + 58e855e commit 1c9bb72

File tree

4 files changed

+16
-36
lines changed

4 files changed

+16
-36
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4159,30 +4159,6 @@ Optional<ProtocolConformanceRef> TypeChecker::conformsToProtocol(
41594159
}
41604160
}
41614161

4162-
// When requested, print the conformance access path used to find this
4163-
// conformance.
4164-
ASTContext &ctx = Proto->getASTContext();
4165-
if (ctx.LangOpts.DebugGenericSignatures &&
4166-
InExpression && T->is<ArchetypeType>() && lookupResult->isAbstract() &&
4167-
!T->castTo<ArchetypeType>()->isOpenedExistential() &&
4168-
!T->castTo<ArchetypeType>()->requiresClass() &&
4169-
T->castTo<ArchetypeType>()->getGenericEnvironment()
4170-
== DC->getGenericEnvironmentOfContext()) {
4171-
auto interfaceType = T->mapTypeOutOfContext();
4172-
if (interfaceType->isTypeParameter()) {
4173-
auto genericSig = DC->getGenericSignatureOfContext();
4174-
auto path = genericSig->getConformanceAccessPath(interfaceType, Proto);
4175-
4176-
// Debugging aid: display the conformance access path for archetype
4177-
// conformances.
4178-
llvm::errs() << "Conformance access path for ";
4179-
T.print(llvm::errs());
4180-
llvm::errs() << ": " << Proto->getName() << " is ";
4181-
path.print(llvm::errs());
4182-
llvm::errs() << "\n";
4183-
}
4184-
}
4185-
41864162
return lookupResult;
41874163
}
41884164

lib/Sema/TypeChecker.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,18 @@ static void prepareGenericParamList(GenericParamList *genericParams) {
304304
/// context have been configured.
305305
static void configureOuterGenericParams(const GenericContext *dc) {
306306
auto genericParams = dc->getGenericParams();
307-
if (!genericParams) return;
308307

309-
if (genericParams->getOuterParameters()) return;
308+
// If we already configured the outer parameters, we're done.
309+
if (genericParams && genericParams->getOuterParameters())
310+
return;
310311

311312
DeclContext *outerDC = dc->getParent();
312313
while (!outerDC->isModuleScopeContext()) {
313314
if (auto outerDecl = outerDC->getAsDecl()) {
314315
if (auto outerGenericDC = outerDecl->getAsGenericContext()) {
315-
genericParams->setOuterParameters(outerGenericDC->getGenericParams());
316+
if (genericParams)
317+
genericParams->setOuterParameters(outerGenericDC->getGenericParams());
318+
316319
configureOuterGenericParams(outerGenericDC);
317320
return;
318321
}

test/Generics/conformance_access_path.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// RUN: %target-typecheck-verify-swift -typecheck -swift-version 4 %s -verify
2-
// RUN: %target-typecheck-verify-swift -typecheck -swift-version 4 -debug-generic-signatures %s > %t.dump 2>&1
3-
// RUN: %FileCheck %s < %t.dump
42

53
protocol P0 { }
64
protocol Q0: P0 { }
@@ -37,22 +35,16 @@ func acceptP3<T: P3>(_: T) { }
3735

3836

3937
func testPaths1<T: P2 & P4>(_ t: T) {
40-
// CHECK: Conformance access path for T.AssocP2.AssocP1: P0 is τ_0_0: P2 -> τ_0_0.AssocP2: P1 -> τ_0_0.AssocP1: Q0 -> τ_0_0: P0
4138
acceptP0(t.getAssocP2().getAssocP1())
42-
// CHECK: Conformance access path for T.AssocP3: P0 is τ_0_0: P4 -> τ_0_0: P3 -> τ_0_0.AssocP3: P0
4339
acceptP0(t.getAssocP3())
4440
}
4541

4642
func testPaths2<U: P2 & P4>(_ t: U) where U.AssocP3 == U.AssocP2.AssocP1 {
47-
// CHECK: Conformance access path for U.AssocP3: P0 is τ_0_0: P4 -> τ_0_0: P3 -> τ_0_0.AssocP3: P0
4843
acceptP0(t.getAssocP2().getAssocP1())
4944
}
5045

5146
func testPaths3<V: P5>(_ v: V) {
52-
// CHECK: Conformance access path for V.AssocP3: P0 is τ_0_0: P5 -> τ_0_0.AssocP3: Q0 -> τ_0_0: P0
5347
acceptP0(v.getAssocP3())
54-
55-
// CHECK: Conformance access path for V.AssocP3: Q0 is τ_0_0: P5 -> τ_0_0.AssocP3: Q0
5648
acceptQ0(v.getAssocP3())
5749
}
5850

@@ -68,6 +60,5 @@ protocol P5Unordered {
6860
}
6961

7062
func testUnorderedP5_P6<W: P6Unordered>(_ w: W) {
71-
// CHECK: Conformance access path for W.A: P0 is τ_0_0: P6Unordered -> τ_0_0: P5Unordered -> τ_0_0.A: P0
7263
acceptP0(w.getA())
7364
}

test/decl/ext/generic.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,13 @@ struct A<T, U, V> {
192192
extension A.B.C where T == V, X == Z.Assoc2 {
193193
func f() { }
194194
}
195+
196+
// Extensions of nested non-generics within generics.
197+
extension A.B {
198+
struct D { }
199+
}
200+
201+
extension A.B.D {
202+
func g() { }
203+
}
204+

0 commit comments

Comments
 (0)