@@ -2365,8 +2365,10 @@ NeverNullType TypeResolver::resolveType(TypeRepr *repr,
2365
2365
bool isInExistential = diagnoseDisallowedExistential (opaqueRepr);
2366
2366
2367
2367
if (auto opaqueDecl = dyn_cast<OpaqueTypeDecl>(DC)) {
2368
- if (auto ordinal = opaqueDecl->getAnonymousOpaqueParamOrdinal (opaqueRepr))
2369
- return getIdentityOpaqueTypeArchetypeType (opaqueDecl, *ordinal);
2368
+ if (auto ordinal = opaqueDecl->getAnonymousOpaqueParamOrdinal (opaqueRepr)){
2369
+ if (!isInExistential)
2370
+ return getIdentityOpaqueTypeArchetypeType (opaqueDecl, *ordinal);
2371
+ }
2370
2372
}
2371
2373
2372
2374
// Check whether any of the generic parameters in the context represents
@@ -2382,7 +2384,7 @@ NeverNullType TypeResolver::resolveType(TypeRepr *repr,
2382
2384
}
2383
2385
}
2384
2386
2385
- if (!isInExistential ){
2387
+ if (!repr-> isInvalid () ){
2386
2388
// We are not inside an `OpaqueTypeDecl`, so diagnose an error.
2387
2389
if (!(options & TypeResolutionFlags::SilenceErrors)) {
2388
2390
diagnose (opaqueRepr->getOpaqueLoc (),
@@ -4712,6 +4714,7 @@ TypeResolver::resolveExistentialType(ExistentialTypeRepr *repr,
4712
4714
if (constraintType->hasError ())
4713
4715
return ErrorType::get (getASTContext ());
4714
4716
4717
+ // TO-DO: generalize this and emit the same erorr for some P?
4715
4718
if (!constraintType->isConstraintType ()) {
4716
4719
// Emit a tailored diagnostic for the incorrect optional
4717
4720
// syntax 'any P?' with a fix-it to add parenthesis.
0 commit comments