@@ -85,20 +85,6 @@ filterForEnumElement(DeclContext *DC, SourceLoc UseLoc,
85
85
ValueDecl *e = result.getValueDecl ();
86
86
assert (e);
87
87
88
- // Check `isInvalid` only if the declaration has been
89
- // verified, otherwise this would cause a problem if
90
- // this declaration is found in the body of a result
91
- // builder because it wouldn't have a type set until
92
- // whole body is type-checked, and `isInvalid` would
93
- // trigger a separate type-check that interfers with
94
- // result builder transformation and causes crashes.
95
- //
96
- // Note: This check cannot simply be removed because
97
- // enums with re-declarationed members would trigger
98
- // an ambiguity assertion below.
99
- if (e->hasInterfaceType () && e->isInvalid ())
100
- continue ;
101
-
102
88
// Skip if the enum element was referenced as an instance member
103
89
if (unqualifiedLookup) {
104
90
if (!result.getBaseDecl () ||
@@ -108,8 +94,10 @@ filterForEnumElement(DeclContext *DC, SourceLoc UseLoc,
108
94
}
109
95
110
96
if (auto *oe = dyn_cast<EnumElementDecl>(e)) {
111
- // Ambiguities should be ruled out by parsing.
112
- assert (!foundElement && " ambiguity in enum case name lookup?!" );
97
+ // Note that there could be multiple elements with the same
98
+ // name, such results in a re-declaration error, so let's
99
+ // just always pick the last element, just like in `foundConstant`
100
+ // case.
113
101
foundElement = oe;
114
102
continue ;
115
103
}
0 commit comments