Skip to content

Commit 559927d

Browse files
authored
Merge pull request swiftlang#71931 from xedin/relax-potential-incompleteness-of-generic-param-vars
[CSBindings] Mark generic parameter type vars as complete if they don…
2 parents 1fa0179 + 22e0f4a commit 559927d

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,30 @@ bool BindingSet::involvesTypeVariables() const {
173173
}
174174

175175
bool BindingSet::isPotentiallyIncomplete() const {
176-
// Generic parameters are always potentially incomplete.
176+
// Always marking generic parameter type variables as incomplete
177+
// is too aggressive. That was the way to make sure that they
178+
// are never attempted to eagerly, but really there are only a
179+
// couple of situations where that can cause issues:
180+
//
181+
// 1. Int <: $T_param
182+
// $T1 <: $T_param
183+
//
184+
// 2. $T2 conv Generic<$T_param>
185+
// $T2 conv Generic<Int?>
186+
// Int <: $T_param
187+
//
188+
// Attempting $T_param before $T1 in 1. could result in a missed
189+
// optional type binding for example.
190+
//
191+
// Attempting $T_param too early in this case (before $T2) could
192+
// miss some transitive bindings inferred through conversion
193+
// of `Generic` type.
194+
//
195+
// If a type variable that represents a generic parameter is no longer
196+
// associated with any type variables (directly or indirectly) it's safe
197+
// to assume that its binding set is complete.
177198
if (Info.isGenericParameter())
178-
return true;
199+
return involvesTypeVariables();
179200

180201
// Key path literal type is incomplete until there is a
181202
// contextual type or key path is resolved enough to infer

0 commit comments

Comments
 (0)