Skip to content

Commit f198960

Browse files
committed
TypeCheckType: Mark misspelled optional existential as invalid
So that is does not show up in other diagnostic passes
1 parent 6e1cd3a commit f198960

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5907,6 +5907,10 @@ TypeResolver::resolveExistentialType(ExistentialTypeRepr *repr,
59075907
diagnose(repr->getLoc(), diag::incorrect_optional_any,
59085908
constraintType)
59095909
.fixItReplace(repr->getSourceRange(), fix);
5910+
5911+
// Recover by returning the intended type, but mark the type
5912+
// representation as invalid to prevent it from being diagnosed elsewhere.
5913+
repr->setInvalid();
59105914
return constraintType;
59115915
}
59125916

@@ -6348,13 +6352,6 @@ class ExistentialTypeSyntaxChecker : public ASTWalker {
63486352
continue;
63496353
}
63506354

6351-
// Look through '?' and '!' too; `any P?` et al. is diagnosed in the
6352-
// type resolver.
6353-
if (isa<OptionalTypeRepr>(*it) ||
6354-
isa<ImplicitlyUnwrappedOptionalTypeRepr>(*it)) {
6355-
continue;
6356-
}
6357-
63586355
break;
63596356
}
63606357

0 commit comments

Comments
 (0)