@@ -2274,7 +2274,13 @@ TypeResolver::resolveAttributedType(TypeAttributes &attrs, TypeRepr *repr,
2274
2274
Optional<MetatypeRepresentation> storedRepr;
2275
2275
// The instance type is not a SIL type.
2276
2276
auto instanceOptions = options;
2277
- instanceOptions.setContext (None);
2277
+ TypeResolverContext context = TypeResolverContext::None;
2278
+ if (isa<MetatypeTypeRepr>(repr)) {
2279
+ context = TypeResolverContext::MetatypeBase;
2280
+ } else if (isa<ProtocolTypeRepr>(repr)) {
2281
+ context = TypeResolverContext::ProtocolMetatypeBase;
2282
+ }
2283
+ instanceOptions.setContext (context);
2278
2284
instanceOptions -= TypeResolutionFlags::SILType;
2279
2285
2280
2286
auto instanceTy = resolveType (base, instanceOptions);
@@ -3166,7 +3172,8 @@ NeverNullType TypeResolver::resolveSILFunctionType(
3166
3172
3167
3173
ProtocolConformanceRef witnessMethodConformance;
3168
3174
if (witnessMethodProtocol) {
3169
- auto resolved = resolveType (witnessMethodProtocol, options);
3175
+ auto resolved = resolveType (witnessMethodProtocol,
3176
+ options.withContext (TypeResolverContext::GenericRequirement));
3170
3177
if (resolved->hasError ())
3171
3178
return resolved;
3172
3179
@@ -3443,9 +3450,7 @@ TypeResolver::resolveIdentifierType(IdentTypeRepr *IdType,
3443
3450
}
3444
3451
3445
3452
// FIXME: Don't use ExistentialType for AnyObject for now.
3446
- bool isConstraintType = (result->is <ProtocolType>() &&
3447
- !result->isAnyObject ());
3448
- if (isConstraintType &&
3453
+ if (result->isConstraintType () && !result->isAnyObject () &&
3449
3454
getASTContext ().LangOpts .EnableExplicitExistentialTypes &&
3450
3455
options.isConstraintImplicitExistential ()) {
3451
3456
return ExistentialType::get (result);
@@ -3807,7 +3812,7 @@ TypeResolver::resolveCompositionType(CompositionTypeRepr *repr,
3807
3812
continue ;
3808
3813
}
3809
3814
3810
- if (ty->isExistentialType ()) {
3815
+ if (ty->isConstraintType ()) {
3811
3816
auto layout = ty->getExistentialLayout ();
3812
3817
if (auto superclass = layout.explicitSuperclass )
3813
3818
if (checkSuperclass (tyR->getStartLoc (), superclass))
0 commit comments