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 @@ -5175,11 +5175,12 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
5175
5175
// collection type couldn't be determined without unification to
5176
5176
// `Any` and `+` failing for all numeric overloads is just a consequence.
5177
5177
if (typeVar && type->isAny ()) {
5178
- auto *GP = typeVar->getImpl ().getGenericParameter ();
5179
- if (auto *GPD = GP->getDecl ()) {
5180
- auto *DC = GPD->getDeclContext ();
5181
- if (DC->isTypeContext () && DC->getSelfInterfaceType ()->isEqual (GP))
5182
- return SolutionKind::Error;
5178
+ if (auto *GP = typeVar->getImpl ().getGenericParameter ()) {
5179
+ if (auto *GPD = GP->getDecl ()) {
5180
+ auto *DC = GPD->getDeclContext ();
5181
+ if (DC->isTypeContext () && DC->getSelfInterfaceType ()->isEqual (GP))
5182
+ return SolutionKind::Error;
5183
+ }
5183
5184
}
5184
5185
}
5185
5186
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