@@ -126,6 +126,7 @@ Type TypeResolution::resolveDependentMemberType(
126
126
// FIXME(ModQual): Reject qualified names immediately; they cannot be
127
127
// dependent member types.
128
128
Identifier refIdentifier = ref->getNameRef ().getBaseIdentifier ();
129
+ ASTContext &ctx = DC->getASTContext ();
129
130
130
131
switch (stage) {
131
132
case TypeResolutionStage::Structural:
@@ -146,8 +147,6 @@ Type TypeResolution::resolveDependentMemberType(
146
147
// Record the type we found.
147
148
ref->setValue (nestedType, nullptr );
148
149
} else {
149
- ASTContext &ctx = DC->getASTContext ();
150
-
151
150
// Resolve the base to a potential archetype.
152
151
// Perform typo correction.
153
152
TypoCorrectionResults corrections (ref->getNameRef (), ref->getNameLoc ());
@@ -188,6 +187,25 @@ Type TypeResolution::resolveDependentMemberType(
188
187
189
188
auto *concrete = ref->getBoundDecl ();
190
189
190
+ if (auto concreteBase = genericSig->getConcreteType (baseTy)) {
191
+ bool hasUnboundOpener = !!getUnboundTypeOpener ();
192
+ switch (TypeChecker::isUnsupportedMemberTypeAccess (concreteBase, concrete,
193
+ hasUnboundOpener)) {
194
+ case TypeChecker::UnsupportedMemberTypeAccessKind::TypeAliasOfExistential:
195
+ ctx.Diags .diagnose (ref->getNameLoc (),
196
+ diag::typealias_outside_of_protocol,
197
+ ref->getNameRef (), concreteBase);
198
+ break ;
199
+ case TypeChecker::UnsupportedMemberTypeAccessKind::AssociatedTypeOfExistential:
200
+ ctx.Diags .diagnose (ref->getNameLoc (),
201
+ diag::assoc_type_outside_of_protocol,
202
+ ref->getNameRef (), concreteBase);
203
+ break ;
204
+ default :
205
+ break ;
206
+ };
207
+ }
208
+
191
209
// If the nested type has been resolved to an associated type, use it.
192
210
if (auto assocType = dyn_cast<AssociatedTypeDecl>(concrete)) {
193
211
return DependentMemberType::get (baseTy, assocType);
0 commit comments