Skip to content

Commit 4aa8fe3

Browse files
authored
Merge pull request #71756 from xedin/pr-71701-nil-in-init
[CSSimplify] Adjust `isBindable` to reject binding if it's directly t…
2 parents 5b35938 + 2eda1cb commit 4aa8fe3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4358,8 +4358,13 @@ static bool isBindable(TypeVariableType *typeVar, Type type) {
43584358
// what the \c type is, because contextual type is just a hint
43594359
// in this situation and type variable would be bound to its
43604360
// opened type instead.
4361+
//
4362+
// Note that although inference doesn't allow direct bindings to
4363+
// type variables, they can still get through via `matchTypes`
4364+
// when type is a partially resolved pack expansion that simplifies
4365+
// down to a type variable.
43614366
return typeVar->getImpl().isPackExpansion() ||
4362-
!type->is<DependentMemberType>();
4367+
!(type->is<TypeVariableType>() || type->is<DependentMemberType>());
43634368
}
43644369

43654370
ConstraintSystem::TypeMatchResult
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: not %target-swift-frontend %s -typecheck
2+
3+
// https://github.com/apple/swift/issues/71701
4+
5+
struct S<each T> {
6+
init(_ values: repeat each T) {}
7+
}
8+
9+
_ = S(nil)
10+
_ = S.init(nil)

0 commit comments

Comments
 (0)