Skip to content

Commit 4ae755e

Browse files
committed
GSB: Fix handling of layout requirements in stripBoundDependentMemberTypes()
There was a silly typo here. Also add some asserts to the Requirement constructor to catch this if it happens again. Fixes rdar://problem/75691385.
1 parent 986d033 commit 4ae755e

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

include/swift/AST/RequirementBase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class RequirementBase {
6363
: FirstTypeAndKind(first, kind), SecondType(second) {
6464
assert(first);
6565
assert(second);
66+
assert(kind != RequirementKind::Layout);
6667
}
6768

6869
/// Create a layout constraint requirement.
@@ -71,6 +72,7 @@ class RequirementBase {
7172
: FirstTypeAndKind(first, kind), SecondLayout(second) {
7273
assert(first);
7374
assert(second);
75+
assert(kind == RequirementKind::Layout);
7476
}
7577

7678
/// Determine the kind of requirement.

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8414,7 +8414,7 @@ static Requirement stripBoundDependentMemberTypes(Requirement req) {
84148414
}));
84158415

84168416
case RequirementKind::Layout:
8417-
return Requirement(RequirementKind::Conformance, subjectType,
8417+
return Requirement(RequirementKind::Layout, subjectType,
84188418
req.getLayoutConstraint());
84198419
}
84208420

test/Generics/rdar75691385.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-typecheck-verify-swift
2+
// RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s 2>&1 | %FileCheck %s
3+
4+
protocol P {}
5+
6+
struct S : P {}
7+
8+
struct G<T : P> {}
9+
10+
extension G {
11+
// CHECK-LABEL: Generic signature: <T, U where T == S, U : AnyObject>
12+
func f<U>(_: U) where T == S, U : AnyObject {}
13+
}

0 commit comments

Comments
 (0)