File tree Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -3885,17 +3885,14 @@ bool MissingMemberFailure::diagnoseInLiteralCollectionContext() const {
3885
3885
if (!parentExpr)
3886
3886
return false ;
3887
3887
3888
- auto parentType = getType (parentExpr);
3888
+ // This could happen if collection is a dictionary literal i.e.
3889
+ // ["a": .test] - the element is a tuple - ("a", .test).
3890
+ if (isExpr<TupleExpr>(parentExpr))
3891
+ parentExpr = findParentExpr (parentExpr);
3889
3892
3890
- if (!parentType-> isKnownStdlibCollectionType () && !parentType-> is <TupleType>( ))
3893
+ if (!isExpr<CollectionExpr>(parentExpr ))
3891
3894
return false ;
3892
3895
3893
- if (isa<TupleExpr>(parentExpr)) {
3894
- parentExpr = findParentExpr (parentExpr);
3895
- if (!parentExpr)
3896
- return false ;
3897
- }
3898
-
3899
3896
if (auto *defaultableVar =
3900
3897
getRawType (parentExpr)->getAs <TypeVariableType>()) {
3901
3898
if (solution.DefaultedConstraints .count (
Original file line number Diff line number Diff line change @@ -515,3 +515,23 @@ func test_conflicting_pattern_vars() {
515
515
}
516
516
}
517
517
}
518
+
519
+ // rdar://91452726 - crash in MissingMemberFailure::diagnoseInLiteralCollectionContext
520
+ struct Test {
521
+ struct ID {
522
+ }
523
+
524
+ enum E : Hashable , Equatable {
525
+ case id
526
+ }
527
+
528
+ var arr : [ ( ID , E ) ]
529
+
530
+ func test( ) {
531
+ _ = arr. map { v in
532
+ switch v {
533
+ case . id: return true // expected-error {{value of tuple type '(Test.ID, Test.E)' has no member 'id'}}
534
+ }
535
+ }
536
+ }
537
+ }
You can’t perform that action at this time.
0 commit comments