Skip to content

Commit cf26521

Browse files
committed
---
yaml --- r: 349460 b: refs/heads/master-next c: 67fca07 h: refs/heads/master
1 parent 23ca2a1 commit cf26521

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: 712b24f69a564d92b5abe944503132b2475c78ed
3+
refs/heads/master-next: 67fca07d8772305a3d8bef80014daf6ed7c2f853
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/Sema/TypeCheckType.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -937,19 +937,18 @@ static void maybeDiagnoseBadConformanceRef(DeclContext *dc,
937937
SourceLoc loc,
938938
TypeDecl *typeDecl) {
939939
auto protocol = dyn_cast<ProtocolDecl>(typeDecl->getDeclContext());
940-
if (!protocol)
941-
return;
942940

943941
// If we weren't given a conformance, go look it up.
944942
ProtocolConformance *conformance = nullptr;
945-
if (auto conformanceRef = TypeChecker::conformsToProtocol(
946-
parentTy, protocol, dc,
947-
(ConformanceCheckFlags::InExpression |
948-
ConformanceCheckFlags::SuppressDependencyTracking |
949-
ConformanceCheckFlags::SkipConditionalRequirements))) {
950-
if (conformanceRef->isConcrete())
951-
conformance = conformanceRef->getConcrete();
952-
}
943+
if (protocol)
944+
if (auto conformanceRef = TypeChecker::conformsToProtocol(
945+
parentTy, protocol, dc,
946+
(ConformanceCheckFlags::InExpression |
947+
ConformanceCheckFlags::SuppressDependencyTracking |
948+
ConformanceCheckFlags::SkipConditionalRequirements))) {
949+
if (conformanceRef->isConcrete())
950+
conformance = conformanceRef->getConcrete();
951+
}
953952

954953
// If any errors have occurred, don't bother diagnosing this cross-file
955954
// issue.
@@ -958,7 +957,7 @@ static void maybeDiagnoseBadConformanceRef(DeclContext *dc,
958957
return;
959958

960959
auto diagCode =
961-
(conformance && !conformance->getConditionalRequirementsIfAvailable())
960+
(!protocol || (conformance && !conformance->getConditionalRequirementsIfAvailable()))
962961
? diag::unsupported_recursion_in_associated_type_reference
963962
: diag::broken_associated_type_witness;
964963

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
protocol ProtoA {
4+
associatedtype AType1
5+
}
6+
7+
protocol ProtoB {
8+
associatedtype AType2: ProtoA
9+
func protoFunc() -> AType2.AType1
10+
}
11+
12+
extension ProtoB {
13+
typealias Alias = AType2.AType1
14+
}
15+
16+
struct Concrete<AType2: ProtoA>: ProtoB {
17+
18+
func concreteFunc() -> Alias {
19+
fatalError()
20+
}
21+
22+
func protoFunc() -> Alias { // expected-error{{unsupported recursion for reference to type alias 'Alias' of type 'Concrete<AType2>'}}
23+
fatalError()
24+
}
25+
}

0 commit comments

Comments
 (0)