Skip to content

Commit f33eb17

Browse files
committed
GSB: Remove unsound cycle-breaking hack
1 parent 3165ea5 commit f33eb17

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5209,12 +5209,6 @@ class GenericSignatureBuilder::InferRequirementsWalker : public TypeWalker {
52095209
// Infer from generic nominal types.
52105210
auto decl = ty->getAnyNominal();
52115211
if (!decl) return Action::Continue;
5212-
5213-
// FIXME: The GSB and the request evaluator both detect a cycle here if we
5214-
// force a recursive generic signature. We should look into moving cycle
5215-
// detection into the generic signature request(s) - see rdar://55263708
5216-
if (!decl->hasComputedGenericSignature())
5217-
return Action::Continue;
52185212

52195213
auto genericSig = decl->getGenericSignature();
52205214
if (!genericSig)

test/Generics/generic_types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class Top {}
230230
class Bottom<T : Bottom<Top>> {}
231231
// expected-error@-1 {{'Bottom' requires that 'Top' inherit from 'Bottom<Top>'}}
232232
// expected-note@-2 {{requirement specified as 'T' : 'Bottom<Top>' [with T = Top]}}
233-
// expected-error@-3 {{generic class 'Bottom' has self-referential generic requirements}}
233+
// expected-error@-3 4{{generic class 'Bottom' has self-referential generic requirements}}
234234
// expected-note@-4 {{while resolving type 'Bottom<Top>'}}
235235
// expected-note@-5 {{through reference here}}
236236

test/decl/protocol/req/recursion.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ extension SomeProtocol where T == Optional<T> { } // expected-error{{same-type c
1010

1111
class X<T> where T == X { // expected-error{{same-type constraint 'T' == 'X<T>' is recursive}}
1212
// expected-error@-1{{same-type requirement makes generic parameter 'T' non-generic}}
13+
// expected-error@-2 3{{generic class 'X' has self-referential generic requirements}}
1314
var type: T { return Swift.type(of: self) } // expected-error{{cannot convert return expression of type 'X<T>.Type' to return type 'T'}}
1415
}
1516

@@ -44,7 +45,7 @@ public protocol P {
4445
}
4546

4647
public struct S<A: P> where A.T == S<A> {
47-
// expected-error@-1 {{generic struct 'S' has self-referential generic requirements}}
48+
// expected-error@-1 4{{generic struct 'S' has self-referential generic requirements}}
4849
// expected-note@-2 {{while resolving type 'S<A>'}}
4950
func f(a: A.T) {
5051
g(a: id(t: a)) // `a` has error type which is diagnosed as circular reference
@@ -70,7 +71,7 @@ protocol PI {
7071
}
7172

7273
struct SI<A: PI> : I where A : I, A.T == SI<A> {
73-
// expected-error@-1 {{generic struct 'SI' has self-referential generic requirements}}
74+
// expected-error@-1 4{{generic struct 'SI' has self-referential generic requirements}}
7475
// expected-note@-2 {{while resolving type 'SI<A>'}}
7576
func ggg<T : I>(t: T.Type) -> T {
7677
return T()
@@ -98,7 +99,9 @@ struct S5<A: PI> : I where A : I, A.T == S4<A> { }
9899

99100
// Used to hit ArchetypeBuilder assertions
100101
struct SU<A: P> where A.T == SU {
102+
// expected-error@-1 3{{generic struct 'SU' has self-referential generic requirements}}
101103
}
102104

103105
struct SIU<A: PI> : I where A : I, A.T == SIU {
106+
// expected-error@-1 3{{generic struct 'SIU' has self-referential generic requirements}}
104107
}

validation-test/compiler_crashers_2_fixed/0064-rdar27627862.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// RUN: %target-swift-frontend %s -emit-ir
1+
// RUN: %target-typecheck-verify-swift
22

33
enum Term<S> where S: Sequence, S.Iterator.Element == Term {
4+
// expected-error@-1 3{{generic enum 'Term' has self-referential generic requirements}}
45
case Cons(head: String, tail: S)
56
}
67

0 commit comments

Comments
 (0)