Skip to content

Commit 10c3e6c

Browse files
committed
[GSB] Error types end up as unresolved equivalence classes.
We need to make sure they don't end up as "concrete" equivalence classes, because they behave more like unresolved ones. Fixes rdar://problem/40009245.
1 parent ba9cc17 commit 10c3e6c

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3944,6 +3944,12 @@ ResolvedType GenericSignatureBuilder::maybeResolveEquivalenceClass(
39443944
Type type,
39453945
ArchetypeResolutionKind resolutionKind,
39463946
bool wantExactPotentialArchetype) {
3947+
// An error type is best modeled as an unresolved potential archetype, since
3948+
// there's no way to be sure what it is actually meant to be.
3949+
if (type->is<ErrorType>()) {
3950+
return ResolvedType::forUnresolved(nullptr);
3951+
}
3952+
39473953
// The equivalence class of a generic type is known directly.
39483954
if (auto genericParam = type->getAs<GenericTypeParamType>()) {
39493955
unsigned index = GenericParamKey(genericParam).findIndexIn(

test/IDE/print_ast_tc_decls_errors.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ protocol AssociatedType1 {
194194
// TYREPR: {{^}} associatedtype AssociatedTypeDecl4 : FooNonExistentProtocol, BarNonExistentProtocol{{$}}
195195

196196
associatedtype AssociatedTypeDecl5 : FooClass
197-
// CHECK: {{^}} associatedtype AssociatedTypeDecl5{{$}}
197+
// CHECK: {{^}} associatedtype AssociatedTypeDecl5 : FooClass{{$}}
198198
}
199199

200200
//===---
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
protocol P {
4+
associatedtype A : P where A.X == Self
5+
associatedtype X : P where P.A == Self
6+
// expected-error@-1{{associated type 'A' can only be used with a concrete type or generic parameter base}}
7+
}

0 commit comments

Comments
 (0)