@@ -2576,6 +2576,10 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
2576
2576
declOrOffset = assocType;
2577
2577
2578
2578
assocType->computeType ();
2579
+
2580
+ assert (!assocType->getDeclaredInterfaceType ()->hasError () &&
2581
+ " erroneous associated type" );
2582
+
2579
2583
Accessibility parentAccess = cast<ProtocolDecl>(DC)->getFormalAccess ();
2580
2584
assocType->setAccessibility (std::max (parentAccess,Accessibility::Internal));
2581
2585
if (isImplicit)
@@ -3031,8 +3035,6 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
3031
3035
getIdentifier (nameID), None);
3032
3036
declOrOffset = proto;
3033
3037
3034
- configureGenericEnvironment (proto, genericEnvID);
3035
-
3036
3038
proto->setRequiresClass (isClassBounded);
3037
3039
3038
3040
if (auto accessLevel = getActualAccessibility (rawAccessLevel)) {
@@ -3042,6 +3044,10 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
3042
3044
return nullptr ;
3043
3045
}
3044
3046
3047
+ auto genericParams = maybeReadGenericParams (DC);
3048
+ assert (genericParams && " protocol with no generic parameters?" );
3049
+ proto->setGenericParams (genericParams);
3050
+
3045
3051
auto protocols = ctx.Allocate <ProtocolDecl *>(numProtocols);
3046
3052
for_each (protocols, rawProtocolAndInheritedIDs.slice (0 , numProtocols),
3047
3053
[this ](ProtocolDecl *&p, uint64_t rawID) {
@@ -3051,9 +3057,7 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
3051
3057
3052
3058
handleInherited (proto, rawProtocolAndInheritedIDs.slice (numProtocols));
3053
3059
3054
- auto genericParams = maybeReadGenericParams (DC);
3055
- assert (genericParams && " protocol with no generic parameters?" );
3056
- proto->setGenericParams (genericParams);
3060
+ configureGenericEnvironment (proto, genericEnvID);
3057
3061
3058
3062
SmallVector<Requirement, 4 > requirements;
3059
3063
readGenericRequirements (requirements, DeclTypeCursor);
0 commit comments