diff options
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java | 17 | ||||
| -rw-r--r-- | src/main/java/org/shedlang/compiler/types/Types.java | 10 |
2 files changed, 11 insertions, 16 deletions
diff --git a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java index 5f229ebc..44fa6d47 100644 --- a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java +++ b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java @@ -119,22 +119,7 @@ public class ShidCodeGen { ) { extraArgumentCount = 1; // TODO: handle not concrete type - var methodCallReceiverType = switch (receiverNode.receiver().type()) { - case SimpleConcreteType concreteType -> - concreteType; - - case ConstructedType<?> constructedType -> { - if (constructedType.genericType() instanceof SimpleConcreteType concreteType) { - yield concreteType; - } else { - throw new UnsupportedOperationException("TODO"); - } - } - - default -> { - throw new UnsupportedOperationException("TODO"); - } - }; + var methodCallReceiverType = (SimpleConcreteType) Types.underlyingType(receiverNode.receiver().type()); context = context.addInstruction(new ShidMethodLoad( methodCallReceiverType, diff --git a/src/main/java/org/shedlang/compiler/types/Types.java b/src/main/java/org/shedlang/compiler/types/Types.java index ea4e7053..15ef9013 100644 --- a/src/main/java/org/shedlang/compiler/types/Types.java +++ b/src/main/java/org/shedlang/compiler/types/Types.java @@ -133,4 +133,14 @@ public class Types { return BOTTOM; } + + /// For constructed types, get the underlying type. For all other types, + /// just return the same type. + public static Type underlyingType(Type type) { + if (type instanceof ConstructedType<?> constructedType) { + return constructedType.genericType(); + } else { + return type; + } + } } |
