Skip to content

Commit 27e6573

Browse files
authored
Merge pull request #82785 from slavapestov/fix-rdar154684522
RequirementMachine: Increase default type differences limit to 13000
2 parents fa3db90 + c5d8ae5 commit 27e6573

File tree

5 files changed

+41
-38
lines changed

5 files changed

+41
-38
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ namespace swift {
590590

591591
/// Maximum number of "type difference" structures for the requirement machine
592592
/// property map algorithm.
593-
unsigned RequirementMachineMaxTypeDifferences = 4000;
593+
unsigned RequirementMachineMaxTypeDifferences = 13000;
594594

595595
/// Maximum number of attempts to make when splitting concrete equivalence
596596
/// classes.

lib/Sema/TypeCheckMacros.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,6 @@ std::optional<unsigned>
18931893
ExpandBodyMacroRequest::evaluate(Evaluator &evaluator,
18941894
AnyFunctionRef fn) const {
18951895
auto *dc = fn.getAsDeclContext();
1896-
auto &ctx = dc->getASTContext();
18971896
std::optional<unsigned> bufferID;
18981897
fn.forEachAttachedMacro(
18991898
MacroRole::Body,

test/Generics/infinite_concrete_type.swift

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class G<T> {}
44

55
protocol P1 { // expected-error {{cannot build rewrite system for protocol; concrete type difference limit exceeded}}
6-
// expected-note@-1 {{failed rewrite rule is [P1:B].[superclass: G<G<G<G<G<G<G<G<G<G<G<G<G<[P1].A>>>>>>>>>>>>>] => [P1:B]}}
6+
// expected-note@-1 {{failed rewrite rule is [P1:B].[superclass: G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<[P1].B>>>>>>>>>>>>>>>>>>>>>>] => [P1:B]}}
77
associatedtype A where A == G<B>
88
associatedtype B where B == G<A>
99
}
@@ -19,3 +19,40 @@ func useP2<T : P2>(_: T) {
1919
_ = T.A.self
2020
_ = T.B.self
2121
}
22+
23+
protocol P3 {
24+
associatedtype T : P3
25+
}
26+
27+
struct S<U : P3> : P3 {
28+
typealias T = S<S<U>>
29+
}
30+
31+
protocol P4Base {
32+
associatedtype T : P3
33+
associatedtype U : P3
34+
}
35+
36+
protocol P4 : P4Base where T == S<U> {
37+
// expected-error@-1 {{cannot build rewrite system for protocol; rule length limit exceeded}}
38+
// expected-note@-2 {{failed rewrite rule is [P4:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[concrete: S<S<S<S<S<S<S<S<S<S<S<S<S<S<[P4:U]>>>>>>>>>>>>>>] => [P4:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T].[P3:T]}}
39+
}
40+
41+
protocol Exponential {
42+
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type size limit exceeded}}
43+
// expected-note@-2 {{failed rewrite rule is }}
44+
associatedtype A where A == (A, A)
45+
}
46+
47+
class Base<T> {}
48+
49+
class Derived<T, U> : Base<(T, U)> {}
50+
51+
protocol TooManyDifferences {
52+
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type difference limit exceeded}}
53+
// expected-note@-2 {{failed rewrite rule is }}
54+
associatedtype A1 where A1: Derived<B, C>, A2: Base<B>, A1 == A2
55+
associatedtype A2
56+
associatedtype B
57+
associatedtype C
58+
}

test/Generics/non_confluent.swift renamed to test/Generics/non_fcrs.swift

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,39 +39,6 @@ extension P1 where Self : P2 {}
3939
// expected-error@-1 {{cannot build rewrite system for generic signature; rule length limit exceeded}}
4040
// expected-note@-2 {{failed rewrite rule is τ_0_0.[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P2] => τ_0_0.[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T]}}
4141

42-
struct S<U : P1> : P1 {
43-
typealias T = S<S<U>>
44-
}
45-
46-
protocol P3Base {
47-
associatedtype T : P1
48-
associatedtype U : P1
49-
}
50-
51-
protocol P3 : P3Base where T == S<U> {
52-
// expected-error@-1 {{cannot build rewrite system for protocol; rule length limit exceeded}}
53-
// expected-note@-2 {{failed rewrite rule is [P3:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[concrete: S<S<S<S<S<S<S<S<S<S<S<S<S<S<[P3:U]>>>>>>>>>>>>>>] => [P3:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T].[P1:T]}}
54-
}
55-
56-
protocol Exponential {
57-
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type size limit exceeded}}
58-
// expected-note@-2 {{failed rewrite rule is }}
59-
associatedtype A where A == (A, A)
60-
}
61-
62-
class Base<T> {}
63-
64-
class Derived<T, U> : Base<(T, U)> {}
65-
66-
protocol TooManyDifferences {
67-
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type difference limit exceeded}}
68-
// expected-note@-2 {{failed rewrite rule is }}
69-
associatedtype A1 where A1: Derived<B, C>, A2: Base<B>, A1 == A2
70-
associatedtype A2
71-
associatedtype B
72-
associatedtype C
73-
}
74-
7542
protocol M0 {
7643
// expected-error@-1 {{cannot build rewrite system for protocol; rule length limit exceeded}}
7744
// expected-note@-2 {{failed rewrite rule is }}

test/Generics/rdar90402519.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ protocol P1 : P0 where C == G1<I> {
2323
}
2424

2525
protocol P2 : P1 where C == G2<I> {}
26-
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type difference limit exceeded}}
27-
// expected-note@-2 {{failed rewrite rule is [P2:I].[concrete: G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<[P2:I]>>>>>>>>>>>>>>>>>>>>>>>>>> : Escapable] => [P2:I]}}
26+
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type nesting limit exceeded}}
27+
// expected-note@-2 {{failed rewrite rule is [P2:I].[concrete: G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<G<[P2:I]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] => [P2:I]}}

0 commit comments

Comments
 (0)