Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ namespace swift {

/// Maximum number of "type difference" structures for the requirement machine
/// property map algorithm.
unsigned RequirementMachineMaxTypeDifferences = 4000;
unsigned RequirementMachineMaxTypeDifferences = 13000;

/// Maximum number of attempts to make when splitting concrete equivalence
/// classes.
Expand Down
1 change: 0 additions & 1 deletion lib/Sema/TypeCheckMacros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,6 @@ std::optional<unsigned>
ExpandBodyMacroRequest::evaluate(Evaluator &evaluator,
AnyFunctionRef fn) const {
auto *dc = fn.getAsDeclContext();
auto &ctx = dc->getASTContext();
std::optional<unsigned> bufferID;
fn.forEachAttachedMacro(
MacroRole::Body,
Expand Down
39 changes: 38 additions & 1 deletion test/Generics/infinite_concrete_type.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class G<T> {}

protocol P1 { // expected-error {{cannot build rewrite system for protocol; concrete type difference limit exceeded}}
// 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]}}
// 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]}}
associatedtype A where A == G<B>
associatedtype B where B == G<A>
}
Expand All @@ -19,3 +19,40 @@ func useP2<T : P2>(_: T) {
_ = T.A.self
_ = T.B.self
}

protocol P3 {
associatedtype T : P3
}

struct S<U : P3> : P3 {
typealias T = S<S<U>>
}

protocol P4Base {
associatedtype T : P3
associatedtype U : P3
}

protocol P4 : P4Base where T == S<U> {
// expected-error@-1 {{cannot build rewrite system for protocol; rule length limit exceeded}}
// 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]}}
}

protocol Exponential {
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type size limit exceeded}}
// expected-note@-2 {{failed rewrite rule is }}
associatedtype A where A == (A, A)
}

class Base<T> {}

class Derived<T, U> : Base<(T, U)> {}

protocol TooManyDifferences {
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type difference limit exceeded}}
// expected-note@-2 {{failed rewrite rule is }}
associatedtype A1 where A1: Derived<B, C>, A2: Base<B>, A1 == A2
associatedtype A2
associatedtype B
associatedtype C
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,39 +39,6 @@ extension P1 where Self : P2 {}
// expected-error@-1 {{cannot build rewrite system for generic signature; rule length limit exceeded}}
// 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]}}

struct S<U : P1> : P1 {
typealias T = S<S<U>>
}

protocol P3Base {
associatedtype T : P1
associatedtype U : P1
}

protocol P3 : P3Base where T == S<U> {
// expected-error@-1 {{cannot build rewrite system for protocol; rule length limit exceeded}}
// 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]}}
}

protocol Exponential {
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type size limit exceeded}}
// expected-note@-2 {{failed rewrite rule is }}
associatedtype A where A == (A, A)
}

class Base<T> {}

class Derived<T, U> : Base<(T, U)> {}

protocol TooManyDifferences {
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type difference limit exceeded}}
// expected-note@-2 {{failed rewrite rule is }}
associatedtype A1 where A1: Derived<B, C>, A2: Base<B>, A1 == A2
associatedtype A2
associatedtype B
associatedtype C
}

protocol M0 {
// expected-error@-1 {{cannot build rewrite system for protocol; rule length limit exceeded}}
// expected-note@-2 {{failed rewrite rule is }}
Expand Down
4 changes: 2 additions & 2 deletions test/Generics/rdar90402519.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ protocol P1 : P0 where C == G1<I> {
}

protocol P2 : P1 where C == G2<I> {}
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type difference limit exceeded}}
// 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]}}
// expected-error@-1 {{cannot build rewrite system for protocol; concrete type nesting limit exceeded}}
// 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]}}