diff options
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java index 44fa6d47..9987944a 100644 --- a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java +++ b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java @@ -424,11 +424,12 @@ public class ShidCodeGen { ) { context = compileExpression(node.receiver(), context); // TODO: handle not a type with member - var receiverType = node.receiver().type(); - var receiver = receiverTypeToReceiver(receiverType); return switch (node.memberKind()) { case FIELD -> { + var receiverType = node.receiver().type(); + var receiver = fieldReceiverTypeToReceiver(receiverType); + yield context.addInstruction(new ShidFieldLoad( receiver, node.memberName(), @@ -436,8 +437,8 @@ public class ShidCodeGen { )); } case METHOD -> { - // TODO: handle not a struct type - var structType = ((ShidFieldLoad.Receiver.Struct) receiver).type(); + // TODO: handle not a concrete type + var structType = (SimpleConcreteType) Types.underlyingType(node.receiver().type()); // TODO: handle not a function type var methodType = (FunctionType) node.type(); @@ -527,10 +528,10 @@ public class ShidCodeGen { }; } - private static ShidFieldLoad.Receiver receiverTypeToReceiver(Type receiverType) { + private static ShidFieldLoad.Receiver fieldReceiverTypeToReceiver(Type receiverType) { return switch (receiverType) { case ConstructedType<?> constructedType -> - receiverTypeToReceiver(constructedType.genericType()); + fieldReceiverTypeToReceiver(constructedType.genericType()); case NamespaceType namespaceType -> new ShidFieldLoad.Receiver.Namespace(namespaceType.namespaceName()); |
