Skip to content

Commit ea75cf9

Browse files
committed
---
yaml --- r: 345571 b: refs/heads/master c: 053c085 h: refs/heads/master i: 345569: 34aee8c 345567: 3b2cd33
1 parent cf929d6 commit ea75cf9

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: dbdfb5e1d9a6277b69015772d5bb61d0f99ceac5
2+
refs/heads/master: 053c08540804da2fbf3512ae91b59372739fb964
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,10 +689,11 @@ ERROR(use_nonmatching_operator,none,
689689
"%0 is not a %select{binary|prefix unary|postfix unary}1 operator",
690690
(DeclName, unsigned))
691691
ERROR(unsupported_recursion_in_associated_type_reference,none,
692-
"unsupported recursion for reference to associated type %0 of type %1",
693-
(DeclName, Type))
692+
"unsupported recursion for reference to %select{associated type|type alias}0 %1 of type %2",
693+
(bool, DeclName, Type))
694694
ERROR(broken_associated_type_witness,none,
695-
"reference to invalid associated type %0 of type %1", (DeclName, Type))
695+
"reference to invalid %select{associated type|type alias}0 %1 of type %2",
696+
(bool, DeclName, Type))
696697

697698
ERROR(unspaced_binary_operator_fixit,none,
698699
"missing whitespace between %0 and %1 operators",

trunk/lib/Sema/TypeCheckType.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,11 +841,15 @@ static void diagnoseUnboundGenericType(Type ty, SourceLoc loc) {
841841
static void maybeDiagnoseBadConformanceRef(DeclContext *dc,
842842
Type parentTy,
843843
SourceLoc loc,
844-
AssociatedTypeDecl *assocType) {
844+
TypeDecl *typeDecl) {
845+
auto protocol = dyn_cast<ProtocolDecl>(typeDecl->getDeclContext());
846+
if (!protocol)
847+
return;
848+
845849
// If we weren't given a conformance, go look it up.
846850
ProtocolConformance *conformance = nullptr;
847851
if (auto conformanceRef = TypeChecker::conformsToProtocol(
848-
parentTy, assocType->getProtocol(), dc,
852+
parentTy, protocol, dc,
849853
(ConformanceCheckFlags::InExpression |
850854
ConformanceCheckFlags::SuppressDependencyTracking |
851855
ConformanceCheckFlags::AllowUnavailableConditionalRequirements))) {
@@ -864,7 +868,7 @@ static void maybeDiagnoseBadConformanceRef(DeclContext *dc,
864868
? diag::unsupported_recursion_in_associated_type_reference
865869
: diag::broken_associated_type_witness;
866870

867-
ctx.Diags.diagnose(loc, diagCode, assocType->getFullName(), parentTy);
871+
ctx.Diags.diagnose(loc, diagCode, isa<TypeAliasDecl>(typeDecl), typeDecl->getFullName(), parentTy);
868872
}
869873

870874
/// \brief Returns a valid type or ErrorType in case of an error.
@@ -910,10 +914,11 @@ static Type resolveTypeDecl(TypeDecl *typeDecl, SourceLoc loc,
910914
return ErrorType::get(ctx);
911915
}
912916

913-
if (type->hasError() && isa<AssociatedTypeDecl>(typeDecl)) {
917+
if (type->hasError() && foundDC &&
918+
(isa<AssociatedTypeDecl>(typeDecl) || isa<TypeAliasDecl>(typeDecl))) {
914919
maybeDiagnoseBadConformanceRef(fromDC,
915920
foundDC->getDeclaredInterfaceType(),
916-
loc, cast<AssociatedTypeDecl>(typeDecl));
921+
loc, typeDecl);
917922
}
918923

919924
if (generic) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// SR-8813
4+
// By itself in this file because this particular expected error is omitted if there have been any other diagnostics.
5+
protocol BaseProtocol {
6+
associatedtype Value
7+
typealias Closure = () -> Value
8+
9+
init(closure: Closure)
10+
}
11+
12+
struct Base<Value>: BaseProtocol {
13+
private let closure: Closure
14+
15+
init(closure: Closure) { //expected-error {{reference to invalid type alias 'Closure' of type 'Base<Value>'}}
16+
self.closure = closure
17+
}
18+
}

trunk/validation-test/compiler_crashers_2/0127-sr5546.swift renamed to trunk/validation-test/compiler_crashers_2_fixed/0127-sr5546.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -typecheck
1+
// RUN: not %target-swift-frontend %s -typecheck
22
// REQUIRES: asserts
33

44
public struct Foo<A, B, C> {}

0 commit comments

Comments
 (0)