File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -402,6 +402,15 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
402
402
if (type->hasError ())
403
403
continue ;
404
404
405
+ // If the source of the binding is 'OptionalObject' constraint
406
+ // and type variable is on the left-hand side, that means
407
+ // that it _has_ to be of optional type, since the right-hand
408
+ // side of the constraint is object type of the optional.
409
+ if (constraint->getKind () == ConstraintKind::OptionalObject &&
410
+ kind == AllowedBindingKind::Subtypes) {
411
+ type = OptionalType::get (type);
412
+ }
413
+
405
414
// If the type we'd be binding to is a dependent member, don't try to
406
415
// resolve this type variable yet.
407
416
if (type->is <DependentMemberType>()) {
Original file line number Diff line number Diff line change @@ -1097,7 +1097,7 @@ func rdar17170728() {
1097
1097
1098
1098
let _ = [ i, j, k] . reduce ( 0 as Int ? ) {
1099
1099
$0 && $1 ? $0! + $1! : ( $0 ? $0! : ( $1 ? $1! : nil ) )
1100
- // expected-error@-1 {{type of expression is ambiguous without more context }}
1100
+ // expected-error@-1 {{ambiguous use of operator '+' }}
1101
1101
}
1102
1102
}
1103
1103
Original file line number Diff line number Diff line change @@ -267,3 +267,8 @@ class Bar {
267
267
let _: Int = result // expected-error{{cannot convert value of type 'X?' to specified type 'Int'}}
268
268
}
269
269
}
270
+
271
+ // rdar://problem/37508855
272
+ func rdar37508855( _ e1: X ? , _ e2: X ? ) -> [ X ] {
273
+ return [ e1, e2] . filter { $0 == nil } . map { $0! }
274
+ }
You can’t perform that action at this time.
0 commit comments