Skip to content

Commit 23577af

Browse files
authored
Merge pull request #76299 from xedin/rdar-135203192
Revert "[CSBindings] Mark generic parameter type vars as complete if they don't have any adjacent vars"
2 parents a0fb54c + 6ca4a3d commit 23577af

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

lib/Sema/CSBindings.cpp

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

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

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

test/Constraints/array_literal.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,25 @@ struct TestMultipleOverloadedInits {
393393
let _ = [Float(x), Float(x), Float(x), Float(x)]
394394
}
395395
}
396+
397+
do {
398+
struct Section {
399+
var rows: [Row<Any>]?
400+
}
401+
402+
struct Row<T> {
403+
init(value: T?) {}
404+
}
405+
406+
struct Asset {
407+
var orientation: Int32
408+
}
409+
410+
func test(asset: Asset) -> [Section] {
411+
return [
412+
Section(rows: [
413+
Row(value: String(describing: asset.orientation)) // Ok
414+
])
415+
]
416+
}
417+
}

0 commit comments

Comments
 (0)