File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -173,9 +173,30 @@ bool BindingSet::involvesTypeVariables() const {
173173}
174174
175175bool 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
You can’t perform that action at this time.
0 commit comments