@@ -2207,7 +2207,13 @@ TypeResolver::resolveAttributedType(TypeAttributes &attrs, TypeRepr *repr,
2207
2207
Optional<MetatypeRepresentation> storedRepr;
2208
2208
// The instance type is not a SIL type.
2209
2209
auto instanceOptions = options;
2210
- instanceOptions.setContext (None);
2210
+ TypeResolverContext context = TypeResolverContext::None;
2211
+ if (isa<MetatypeTypeRepr>(repr)) {
2212
+ context = TypeResolverContext::MetatypeBase;
2213
+ } else if (isa<ProtocolTypeRepr>(repr)) {
2214
+ context = TypeResolverContext::ProtocolMetatypeBase;
2215
+ }
2216
+ instanceOptions.setContext (context);
2211
2217
instanceOptions -= TypeResolutionFlags::SILType;
2212
2218
2213
2219
auto instanceTy = resolveType (base, instanceOptions);
@@ -3106,7 +3112,8 @@ NeverNullType TypeResolver::resolveSILFunctionType(
3106
3112
3107
3113
ProtocolConformanceRef witnessMethodConformance;
3108
3114
if (witnessMethodProtocol) {
3109
- auto resolved = resolveType (witnessMethodProtocol, options);
3115
+ auto resolved = resolveType (witnessMethodProtocol,
3116
+ options.withContext (TypeResolverContext::GenericRequirement));
3110
3117
if (resolved->hasError ())
3111
3118
return resolved;
3112
3119
@@ -3383,9 +3390,7 @@ TypeResolver::resolveIdentifierType(IdentTypeRepr *IdType,
3383
3390
}
3384
3391
3385
3392
// FIXME: Don't use ExistentialType for AnyObject for now.
3386
- bool isConstraintType = (result->is <ProtocolType>() &&
3387
- !result->isAnyObject ());
3388
- if (isConstraintType &&
3393
+ if (result->isConstraintType () && !result->isAnyObject () &&
3389
3394
getASTContext ().LangOpts .EnableExplicitExistentialTypes &&
3390
3395
options.isConstraintImplicitExistential ()) {
3391
3396
return ExistentialType::get (result);
@@ -3728,7 +3733,7 @@ TypeResolver::resolveCompositionType(CompositionTypeRepr *repr,
3728
3733
continue ;
3729
3734
}
3730
3735
3731
- if (ty->isExistentialType ()) {
3736
+ if (ty->isConstraintType ()) {
3732
3737
auto layout = ty->getExistentialLayout ();
3733
3738
if (auto superclass = layout.explicitSuperclass )
3734
3739
if (checkSuperclass (tyR->getStartLoc (), superclass))
0 commit comments