Skip to content

Commit e7c81c5

Browse files
committed
Bail out earlier when we try to recursively validate a generic signature.
Fixes one of the crashers I recently regressed.
1 parent 48ae0fd commit e7c81c5

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ Type TypeChecker::applyUnboundGenericArguments(
526526
auto genericSig = unbound->getDecl()->getGenericSignature();
527527
if (unbound->getDecl()->IsValidatingGenericSignature()) {
528528
diagnose(loc, diag::recursive_requirement_reference);
529-
return BGT;
529+
return nullptr;
530530
}
531531
assert(genericSig != nullptr);
532532
if (checkGenericArguments(dc, loc, noteLoc, unbound, genericSig,

test/Generics/generic_types.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,7 @@ var y: X5<X4, Int> // expected-error{{'X5' requires the types 'AssocP' (aka 'Int
312312

313313
// Recursive generic signature validation.
314314
class Top {}
315-
class Bottom<T : Bottom<Top>> {} // expected-error 2{{type may not reference itself as a requirement}}
316-
// expected-error@-1{{Bottom' requires that 'Top' inherit from 'Bottom<Top>'}}
317-
// expected-note@-2{{requirement specified as 'T' : 'Bottom<Top>' [with T = Top]}}
315+
class Bottom<T : Bottom<Top>> {} // expected-error {{type may not reference itself as a requirement}}
318316

319317
class X6<T> {
320318
let d: D<T>

validation-test/compiler_crashers_fixed/26403-llvm-densemapbase-llvm-smalldensemap-std-pair-llvm-arrayref-std-pair-swift-identifier.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@
88
// RUN: not %target-swift-frontend %s -parse
99
class B<T where B:d
1010
class B<T>:B<T>
11-
12-
// REQUIRES: disabled

0 commit comments

Comments
 (0)