@@ -820,8 +820,10 @@ namespace {
820
820
// Figure out the actual base type, and whether we have an instance of
821
821
// that type or its metatype.
822
822
bool baseIsInstance = true ;
823
+ bool isExistentialMetatype = false ;
823
824
if (auto baseMeta = baseTy->getAs <AnyMetatypeType>()) {
824
825
baseIsInstance = false ;
826
+ isExistentialMetatype = baseMeta->is <ExistentialMetatypeType>();
825
827
baseTy = baseMeta->getInstanceType ();
826
828
}
827
829
@@ -909,11 +911,15 @@ namespace {
909
911
base, selfParamTy, member, semantics,
910
912
locator.withPathElement (ConstraintLocator::MemberRefBase));
911
913
} else {
912
- // Convert the base to an rvalue of the appropriate metatype.
913
- base = coerceToType (base,
914
- MetatypeType::get (isDynamic ? selfTy : containerTy),
915
- locator.withPathElement (
916
- ConstraintLocator::MemberRefBase));
914
+ if (!isExistentialMetatype) {
915
+ // Convert the base to an rvalue of the appropriate metatype.
916
+ base = coerceToType (base,
917
+ MetatypeType::get (
918
+ isDynamic ? selfTy : containerTy),
919
+ locator.withPathElement (
920
+ ConstraintLocator::MemberRefBase));
921
+ }
922
+
917
923
if (!base)
918
924
return nullptr ;
919
925
@@ -6452,12 +6458,6 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
6452
6458
}
6453
6459
}
6454
6460
6455
- // Allows for same-type coercion with existential metatypes.
6456
- if (auto toMeta = toType->getAs <AnyMetatypeType>()) {
6457
- if (fromMeta->getInstanceType ()->isEqual (toMeta->getInstanceType ()))
6458
- return expr;
6459
- }
6460
-
6461
6461
break ;
6462
6462
}
6463
6463
0 commit comments