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 @@ -3976,17 +3976,14 @@ bool MissingMemberFailure::diagnoseInLiteralCollectionContext() const {
3976
3976
if (!parentExpr)
3977
3977
return false ;
3978
3978
3979
- auto parentType = getType (parentExpr);
3979
+ // This could happen if collection is a dictionary literal i.e.
3980
+ // ["a": .test] - the element is a tuple - ("a", .test).
3981
+ if (isExpr<TupleExpr>(parentExpr))
3982
+ parentExpr = findParentExpr (parentExpr);
3980
3983
3981
- if (!parentType-> isKnownStdlibCollectionType () && !parentType-> is <TupleType>( ))
3984
+ if (!isExpr<CollectionExpr>(parentExpr ))
3982
3985
return false ;
3983
3986
3984
- if (isa<TupleExpr>(parentExpr)) {
3985
- parentExpr = findParentExpr (parentExpr);
3986
- if (!parentExpr)
3987
- return false ;
3988
- }
3989
-
3990
3987
if (auto *defaultableVar =
3991
3988
getRawType (parentExpr)->getAs <TypeVariableType>()) {
3992
3989
if (solution.DefaultedConstraints .count (
Original file line number Diff line number Diff line change @@ -546,3 +546,23 @@ func test_conflicting_pattern_vars() {
546
546
}
547
547
}
548
548
}
549
+
550
+ // rdar://91452726 - crash in MissingMemberFailure::diagnoseInLiteralCollectionContext
551
+ struct Test {
552
+ struct ID {
553
+ }
554
+
555
+ enum E : Hashable , Equatable {
556
+ case id
557
+ }
558
+
559
+ var arr : [ ( ID , E ) ]
560
+
561
+ func test( ) {
562
+ _ = arr. map { v in
563
+ switch v {
564
+ case . id: return true // expected-error {{value of tuple type '(Test.ID, Test.E)' has no member 'id'}}
565
+ }
566
+ }
567
+ }
568
+ }
You can’t perform that action at this time.
0 commit comments