Skip to content

Commit 3316c47

Browse files
committed
[TypeChecker] Remove isInvalid and related assertion from filterForEnumElement
Since re-declaration error is going to be emitted anyway it doesn't matter which declaration would get returned.
1 parent 3710967 commit 3316c47

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

lib/Sema/TypeCheckPattern.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,6 @@ filterForEnumElement(DeclContext *DC, SourceLoc UseLoc,
8585
ValueDecl *e = result.getValueDecl();
8686
assert(e);
8787

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-
10288
// Skip if the enum element was referenced as an instance member
10389
if (unqualifiedLookup) {
10490
if (!result.getBaseDecl() ||
@@ -108,8 +94,10 @@ filterForEnumElement(DeclContext *DC, SourceLoc UseLoc,
10894
}
10995

11096
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.
113101
foundElement = oe;
114102
continue;
115103
}

0 commit comments

Comments
 (0)