diff --git a/base/src/main/java/org/arend/core/expr/ClassCallExpression.java b/base/src/main/java/org/arend/core/expr/ClassCallExpression.java index ad2a1547e..443c1f6ba 100644 --- a/base/src/main/java/org/arend/core/expr/ClassCallExpression.java +++ b/base/src/main/java/org/arend/core/expr/ClassCallExpression.java @@ -336,8 +336,10 @@ private Expression makeNewExpression(Expression arg, Expression type) { type = type.normalize(NormalizationMode.WHNF); if (type instanceof ClassCallExpression classCall && getDefinition().isSubClassOf(classCall.getDefinition())) { Map subImplementations = new LinkedHashMap<>(classCall.getImplementedHere()); + ClassCallExpression resultClassCall = new ClassCallExpression(classCall.getDefinition(), getLevels(((ClassCallExpression) type).getDefinition()), subImplementations, Sort.PROP, UniverseKind.NO_UNIVERSES); + Expression resultRef = new ReferenceExpression(resultClassCall.myThisBinding); for (ClassField field : classCall.getDefinition().getNotImplementedFields()) { - Expression impl = myImplementations.get(field); + Expression impl = getImplementation(field, resultRef); if (impl != null) { subImplementations.put(field, impl); } else { @@ -347,7 +349,7 @@ private Expression makeNewExpression(Expression arg, Expression type) { } } } - return new NewExpression(null, new ClassCallExpression(classCall.getDefinition(), getLevels(((ClassCallExpression) type).getDefinition()), subImplementations, Sort.PROP, UniverseKind.NO_UNIVERSES)); + return new NewExpression(null, resultClassCall); } } return null;