File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -5136,11 +5136,12 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
5136
5136
// collection type couldn't be determined without unification to
5137
5137
// `Any` and `+` failing for all numeric overloads is just a consequence.
5138
5138
if (typeVar && type->isAny ()) {
5139
- auto *GP = typeVar->getImpl ().getGenericParameter ();
5140
- if (auto *GPD = GP->getDecl ()) {
5141
- auto *DC = GPD->getDeclContext ();
5142
- if (DC->isTypeContext () && DC->getSelfInterfaceType ()->isEqual (GP))
5143
- return SolutionKind::Error;
5139
+ if (auto *GP = typeVar->getImpl ().getGenericParameter ()) {
5140
+ if (auto *GPD = GP->getDecl ()) {
5141
+ auto *DC = GPD->getDeclContext ();
5142
+ if (DC->isTypeContext () && DC->getSelfInterfaceType ()->isEqual (GP))
5143
+ return SolutionKind::Error;
5144
+ }
5144
5145
}
5145
5146
}
5146
5147
Original file line number Diff line number Diff line change @@ -420,3 +420,10 @@ func test_force_unwrap_not_being_too_eager() {
420
420
if let _ = obj. delegate? . window { // Ok
421
421
}
422
422
}
423
+
424
+ // rdar://problem/57097401
425
+ func invalidOptionalChaining( a: Any ) {
426
+ a == " = " ? // expected-error {{cannot use optional chaining on non-optional value of type 'String'}}
427
+ // expected-error@-1 {{value of protocol type 'Any' cannot conform to 'Equatable'; only struct/enum/class types can conform to protocols}}
428
+ // expected-note@-2 {{requirement from conditional conformance of 'Any?' to 'Equatable'}}
429
+ }
You can’t perform that action at this time.
0 commit comments