@@ -701,15 +701,17 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
701701 if (!AlreadyDiagnosedMetatypes.insert (E).second )
702702 return ;
703703
704- // In Swift < 6 warn about plain type name passed as an
705- // argument to a subscript, dynamic subscript, or ObjC
706- // literal since it used to be accepted.
707704 DiagnosticBehavior behavior = DiagnosticBehavior::Error;
708705
709706 if (auto *ParentExpr = Parent.getAsExpr ()) {
710707 if (ParentExpr->isValidParentOfTypeExpr (E))
711708 return ;
712709
710+ // In Swift < 6 warn about
711+ // - plain type name passed as an argument to a subscript, dynamic
712+ // subscript, or ObjC literal since it used to be accepted.
713+ // - member type expressions rooted on non-identifier types, e.g.
714+ // '[X].Y' since they used to be accepted without the '.self'.
713715 if (!Ctx.LangOpts .isSwiftVersionAtLeast (6 )) {
714716 if (isa<SubscriptExpr>(ParentExpr) ||
715717 isa<DynamicSubscriptExpr>(ParentExpr) ||
@@ -718,12 +720,21 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
718720 assert (argList);
719721 if (argList->isUnlabeledUnary ())
720722 behavior = DiagnosticBehavior::Warning;
723+ } else if (auto *TE = dyn_cast<TypeExpr>(E)) {
724+ if (auto *TR =
725+ dyn_cast_or_null<MemberTypeRepr>(TE->getTypeRepr ())) {
726+ if (!isa<IdentTypeRepr>(TR->getBaseComponent ())) {
727+ behavior = DiagnosticBehavior::Warning;
728+ }
729+ }
721730 }
722731 }
723732 }
724733
725734 // Is this a protocol metatype?
726- Ctx.Diags .diagnose (E->getStartLoc (), diag::value_of_metatype_type)
735+ Ctx.Diags
736+ .diagnose (E->getStartLoc (), diag::value_of_metatype_type,
737+ behavior == DiagnosticBehavior::Warning)
727738 .limitBehavior (behavior);
728739
729740 // Add fix-it to insert '()', only if this is a metatype of
0 commit comments