@@ -2365,8 +2365,10 @@ NeverNullType TypeResolver::resolveType(TypeRepr *repr,
23652365 bool isInExistential = diagnoseDisallowedExistential (opaqueRepr);
23662366
23672367 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+ }
23702372 }
23712373
23722374 // Check whether any of the generic parameters in the context represents
@@ -2382,7 +2384,7 @@ NeverNullType TypeResolver::resolveType(TypeRepr *repr,
23822384 }
23832385 }
23842386
2385- if (!isInExistential ){
2387+ if (!repr-> isInvalid () ){
23862388 // We are not inside an `OpaqueTypeDecl`, so diagnose an error.
23872389 if (!(options & TypeResolutionFlags::SilenceErrors)) {
23882390 diagnose (opaqueRepr->getOpaqueLoc (),
@@ -4712,6 +4714,7 @@ TypeResolver::resolveExistentialType(ExistentialTypeRepr *repr,
47124714 if (constraintType->hasError ())
47134715 return ErrorType::get (getASTContext ());
47144716
4717+ // TO-DO: generalize this and emit the same erorr for some P?
47154718 if (!constraintType->isConstraintType ()) {
47164719 // Emit a tailored diagnostic for the incorrect optional
47174720 // syntax 'any P?' with a fix-it to add parenthesis.
0 commit comments