@@ -68,24 +68,27 @@ MethodInstance *MethodInstance::resolve(const IR::MethodCallExpression *mce,
6868 } else {
6969 const IR::IDeclaration *decl = nullptr ;
7070 const IR::Type *type = nullptr ;
71- if (auto th = mem->expr ->to <IR::This>()) {
71+ const IR::Expression *receiver = mem->expr ;
72+ while (auto ai = receiver->to <IR::ArrayIndex>()) receiver = ai->left ;
73+ if (auto th = receiver->to <IR::This>()) {
7274 type = basetype;
7375 decl = refMap->getDeclaration (th, true );
74- } else if (auto pe = mem-> expr ->to <IR::PathExpression>()) {
76+ } else if (auto pe = receiver ->to <IR::PathExpression>()) {
7577 decl = refMap->getDeclaration (pe->path , true );
7678 type = typeMap ? typeMap->getType (decl->getNode (), true ) : pe->type ;
77- } else if (auto mc = mem-> expr ->to <IR::MethodCallExpression>()) {
79+ } else if (auto mc = receiver ->to <IR::MethodCallExpression>()) {
7880 auto mi = resolve (mc, refMap, typeMap, useExpressionType);
7981 decl = mi->object ;
8082 type = mi->actualMethodType ->returnType ;
81- } else if (auto cce = mem-> expr ->to <IR::ConstructorCallExpression>()) {
83+ } else if (auto cce = receiver ->to <IR::ConstructorCallExpression>()) {
8284 auto cc = ConstructorCall::resolve (cce, refMap, typeMap);
8385 decl = cc->to <ExternConstructorCall>()->type ;
8486 type = typeMap ? typeMap->getTypeType (cce->constructedType , true ) : cce->type ;
8587 } else {
86- BUG (" unexpected expression %1% resolving method instance" , mem-> expr );
88+ BUG (" unexpected expression %1% resolving method instance" , receiver );
8789 }
8890 BUG_CHECK (type != nullptr , " Could not resolve type for %1%" , decl);
91+ while (auto st = type->to <IR::Type_Array>()) type = st->elementType ;
8992 if (type->is <IR::Type_SpecializedCanonical>())
9093 type = type->to <IR::Type_SpecializedCanonical>()->substituted ->to <IR::Type>();
9194 if (type->is <IR::IApply>() && mem->member == IR::IApply::applyMethodName) {
@@ -172,9 +175,10 @@ ConstructorCall *ConstructorCall::resolve(const IR::ConstructorCallExpression *c
172175Instantiation *Instantiation::resolve (const IR::Declaration_Instance *instance, DeclarationLookup *,
173176 TypeMap *typeMap) {
174177 auto type = typeMap ? typeMap->getTypeType (instance->type , true ) : instance->type ;
175- auto simpleType = type;
176178 const IR::Vector<IR::Type> *typeArguments;
177179
180+ while (auto at = type->to <IR::Type_Array>()) type = at->elementType ;
181+ auto simpleType = type;
178182 if (auto st = type->to <IR::Type_SpecializedCanonical>()) {
179183 simpleType = st->baseType ;
180184 typeArguments = st->arguments ;
0 commit comments