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 {
38853885 if (!parentExpr)
38863886 return false ;
38873887
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);
38893892
3890- if (!parentType-> isKnownStdlibCollectionType () && !parentType-> is <TupleType>( ))
3893+ if (!isExpr<CollectionExpr>(parentExpr ))
38913894 return false ;
38923895
3893- if (isa<TupleExpr>(parentExpr)) {
3894- parentExpr = findParentExpr (parentExpr);
3895- if (!parentExpr)
3896- return false ;
3897- }
3898-
38993896 if (auto *defaultableVar =
39003897 getRawType (parentExpr)->getAs <TypeVariableType>()) {
39013898 if (solution.DefaultedConstraints .count (
Original file line number Diff line number Diff line change @@ -515,3 +515,23 @@ func test_conflicting_pattern_vars() {
515515 }
516516 }
517517}
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