@@ -2278,8 +2278,10 @@ NeverNullType TypeResolver::resolveType(TypeRepr *repr,
2278
2278
bool isInExistential = diagnoseDisallowedExistential (opaqueRepr);
2279
2279
2280
2280
if (auto opaqueDecl = dyn_cast<OpaqueTypeDecl>(DC)) {
2281
- if (auto ordinal = opaqueDecl->getAnonymousOpaqueParamOrdinal (opaqueRepr))
2282
- return getIdentityOpaqueTypeArchetypeType (opaqueDecl, *ordinal);
2281
+ if (auto ordinal = opaqueDecl->getAnonymousOpaqueParamOrdinal (opaqueRepr)){
2282
+ if (!isInExistential)
2283
+ return getIdentityOpaqueTypeArchetypeType (opaqueDecl, *ordinal);
2284
+ }
2283
2285
}
2284
2286
2285
2287
// Check whether any of the generic parameters in the context represents
@@ -2295,7 +2297,7 @@ NeverNullType TypeResolver::resolveType(TypeRepr *repr,
2295
2297
}
2296
2298
}
2297
2299
2298
- if (!isInExistential ){
2300
+ if (!repr-> isInvalid () ){
2299
2301
// We are not inside an `OpaqueTypeDecl`, so diagnose an error.
2300
2302
if (!(options & TypeResolutionFlags::SilenceErrors)) {
2301
2303
diagnose (opaqueRepr->getOpaqueLoc (),
@@ -4515,6 +4517,7 @@ TypeResolver::resolveExistentialType(ExistentialTypeRepr *repr,
4515
4517
if (constraintType->hasError ())
4516
4518
return ErrorType::get (getASTContext ());
4517
4519
4520
+ // TO-DO: generalize this and emit the same erorr for some P?
4518
4521
if (!constraintType->isConstraintType ()) {
4519
4522
// Emit a tailored diagnostic for the incorrect optional
4520
4523
// syntax 'any P?' with a fix-it to add parenthesis.
0 commit comments