summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-08-09 21:31:35 +0100
committerMichael Williamson <mike@zwobble.org>2026-08-09 21:31:35 +0100
commit98962d6c17fd91be269e6c8a766977707422cbb4 (patch)
treedc2e43dd2c0f8a5ff9990afc7579ff176225f17a /src
parentcc0f7190d1254ec89354cea8b2ed0aaecbb3b391 (diff)
Introduce ConstructedStructType
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/analysis/ArbitraryValueAnalysis.java14
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNode.java4
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGenerator.java8
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java6
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java48
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java14
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java8
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java46
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java8
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerNamespaceContext.java8
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypesInfo.java6
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypesInfoInMemory.java12
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedNativeType.java17
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedStructType.java9
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedType.java24
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructibleType.java2
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/types/SimpleStructType.java (renamed from src/main/java/org/zwobble/hobgoblin/compiler/types/StructType.java)2
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/types/SimpleType.java2
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/types/SumVariant.java2
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/types/Type.java2
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/analysis/ArbitraryValueAnalysisTests.java22
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerNamespaceTests.java8
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java10
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSubtypingTests.java10
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java18
25 files changed, 162 insertions, 148 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/analysis/ArbitraryValueAnalysis.java b/src/main/java/org/zwobble/hobgoblin/compiler/analysis/ArbitraryValueAnalysis.java
index 6bc4852..39d9e3f 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/analysis/ArbitraryValueAnalysis.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/analysis/ArbitraryValueAnalysis.java
@@ -32,19 +32,19 @@ public class ArbitraryValueAnalysis {
}
return switch (type) {
- case ConstructedNativeType constructedNativeType -> {
+ case ConstructedType constructedType -> {
if (
- constructedNativeType.constructor().equals(NativeTypes.BOX) ||
- constructedNativeType.constructor().equals(NativeTypes.SHARED)
+ constructedType.constructor().equals(NativeTypes.BOX) ||
+ constructedType.constructor().equals(NativeTypes.SHARED)
) {
yield isNonRecursivelyConstructable(
- constructedNativeType.args().getFirst(),
+ constructedType.args().getFirst(),
seenTypes,
typesInfo
);
} else if (
- constructedNativeType.constructor().equals(NativeTypes.LIST) ||
- constructedNativeType.constructor().equals(NativeTypes.OPTION)
+ constructedType.constructor().equals(NativeTypes.LIST) ||
+ constructedType.constructor().equals(NativeTypes.OPTION)
) {
yield true;
} else {
@@ -58,7 +58,7 @@ public class ArbitraryValueAnalysis {
case SimpleNativeType _ ->
true;
- case StructType structType -> {
+ case SimpleStructType structType -> {
var newSeenTypes = new HashSet<>(seenTypes);
newSeenTypes.add(type);
var fields = typesInfo.fieldsOf(structType);
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNode.java
index f2e6b97..2c85f6d 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNode.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNode.java
@@ -2,13 +2,13 @@ package org.zwobble.hobgoblin.compiler.ast.typed;
import org.zwobble.hobgoblin.compiler.ast.DocComment;
import org.zwobble.hobgoblin.compiler.sources.Source;
-import org.zwobble.hobgoblin.compiler.types.StructType;
+import org.zwobble.hobgoblin.compiler.types.SimpleStructType;
import java.util.List;
import java.util.Optional;
public record TypedStructDefinitionNode(
- StructType type,
+ SimpleStructType type,
Optional<List<TypedStructFieldDefinitionNode>> fields,
DocComment docComment,
Source source
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGenerator.java
index eab31b4..1bb256c 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGenerator.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGenerator.java
@@ -149,13 +149,13 @@ public class JavaGenerator {
private JavaTypeRef generateTypeRef(Type type, boolean referenceType) {
return switch (collapseType(type)) {
- case ConstructedNativeType constructedNativeType -> {
+ case ConstructedType constructedType -> {
var innerTypeRef = generateTypeRef(
- constructedNativeType.constructor().genericType(),
+ constructedType.constructor().genericType(),
referenceType
);
- var javaArgs = constructedNativeType.args().stream()
+ var javaArgs = constructedType.args().stream()
.map(arg -> JavaTypeArg.invariant(generateTypeRef(arg, true)))
.toList();
@@ -185,7 +185,7 @@ public class JavaGenerator {
}
}
- case StructType structType ->
+ case SimpleStructType structType ->
JavaTypeRef.topLevel(
namespaceToJavaPackageName(structType.namespaceName()),
generateTypeName(structType.name())
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java
index bea3f1d..926e53d 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java
@@ -257,7 +257,7 @@ public class JavaPreciselyMatchersGenerator implements Generator {
this.typesInfo = typesInfo;
}
- public List<SumType> variantOf(StructType type) {
+ public List<SumType> variantOf(SimpleStructType type) {
return this.typesInfo.variantOf(type);
}
@@ -284,7 +284,7 @@ public class JavaPreciselyMatchersGenerator implements Generator {
);
}
- private JavaTypeRef structMatcherRef(StructType structType) {
+ private JavaTypeRef structMatcherRef(SimpleStructType structType) {
var matcherTypeName = structMatcherTypeName(structType);
return JavaTypeRef.topLevel(
@@ -293,7 +293,7 @@ public class JavaPreciselyMatchersGenerator implements Generator {
);
}
- private JavaIdentifier structMatcherTypeName(StructType structType) {
+ private JavaIdentifier structMatcherTypeName(SimpleStructType structType) {
return this.javaGenerator.generateTypeName(structType.name() + "Matcher");
}
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java
index c9c4ea0..1cc95f5 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java
@@ -835,22 +835,22 @@ public class JavaTransient0Generator implements Generator {
private List<JavaBlockStatement> generateEncode(JavaExpression value, Type type, Context context) {
return switch (type) {
- case ConstructedNativeType constructedNativeType -> {
- if (constructedNativeType.constructor().equals(NativeTypes.BOX)) {
- yield generateEncode(value, constructedNativeType.args().getFirst(), context);
- } else if (constructedNativeType.constructor().equals(NativeTypes.LIST)) {
- yield generateEncodeList(value, constructedNativeType.args().getFirst(), context);
- } else if (constructedNativeType.constructor().equals(NativeTypes.OPTION)) {
- yield generateEncodeOption(value, constructedNativeType.args().getFirst(), context);
- } else if (constructedNativeType.constructor().equals(NativeTypes.SHARED)) {
- yield generateEncodeShared(value, constructedNativeType.args().getFirst(), context);
+ case ConstructedType constructedType -> {
+ if (constructedType.constructor().equals(NativeTypes.BOX)) {
+ yield generateEncode(value, constructedType.args().getFirst(), context);
+ } else if (constructedType.constructor().equals(NativeTypes.LIST)) {
+ yield generateEncodeList(value, constructedType.args().getFirst(), context);
+ } else if (constructedType.constructor().equals(NativeTypes.OPTION)) {
+ yield generateEncodeOption(value, constructedType.args().getFirst(), context);
+ } else if (constructedType.constructor().equals(NativeTypes.SHARED)) {
+ yield generateEncodeShared(value, constructedType.args().getFirst(), context);
} else {
yield List.of(
generateEncode(
value,
- constructedNativeType.namespaceName(),
- constructedNativeType,
- constructedNativeType.args().stream()
+ constructedType.namespaceName(),
+ constructedType,
+ constructedType.args().stream()
.<JavaExpression>map(typeArg -> generateEncodeMethodRef(typeArg, context))
.toList()
)
@@ -955,22 +955,22 @@ public class JavaTransient0Generator implements Generator {
Context context
) {
return switch (type) {
- case ConstructedNativeType constructedNativeType -> {
- if (constructedNativeType.constructor().equals(NativeTypes.BOX)) {
- yield generateDecode(target, constructedNativeType.args().getFirst(), context);
- } else if (constructedNativeType.constructor().equals(NativeTypes.LIST)) {
- yield generateDecodeList(target, constructedNativeType.args().getFirst(), context);
- } else if (constructedNativeType.constructor().equals(NativeTypes.OPTION)) {
- yield generateDecodeOption(target, constructedNativeType.args().getFirst(), context);
- } else if (constructedNativeType.constructor().equals(NativeTypes.SHARED)) {
- yield generateDecodeShared(target, constructedNativeType.args().getFirst(), context);
+ case ConstructedType constructedType -> {
+ if (constructedType.constructor().equals(NativeTypes.BOX)) {
+ yield generateDecode(target, constructedType.args().getFirst(), context);
+ } else if (constructedType.constructor().equals(NativeTypes.LIST)) {
+ yield generateDecodeList(target, constructedType.args().getFirst(), context);
+ } else if (constructedType.constructor().equals(NativeTypes.OPTION)) {
+ yield generateDecodeOption(target, constructedType.args().getFirst(), context);
+ } else if (constructedType.constructor().equals(NativeTypes.SHARED)) {
+ yield generateDecodeShared(target, constructedType.args().getFirst(), context);
} else {
yield List.of(
generateDecode(
target,
- constructedNativeType.namespaceName(),
- constructedNativeType,
- constructedNativeType.args().stream()
+ constructedType.namespaceName(),
+ constructedType,
+ constructedType.args().stream()
.<JavaExpression>map(typeArg -> generateDecodeMethodRef(typeArg, context))
.toList()
)
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java
index 33072d7..9ba7397 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java
@@ -528,13 +528,13 @@ public class JavaTypesGenerator implements Generator {
private Optional<JavaTypeRef> generateBuilderTypeRef(Type type) {
return switch (type) {
- case StructType structType -> Optional.of(generateBuilderTypeRef(structType));
+ case SimpleStructType structType -> Optional.of(generateBuilderTypeRef(structType));
case SumType sumType -> Optional.of(generateBuilderTypeRef(sumType));
default -> Optional.empty();
};
}
- private JavaTypeRef generateBuilderTypeRef(StructType type) {
+ private JavaTypeRef generateBuilderTypeRef(SimpleStructType type) {
return generateBuilderTypeRef(type.namespaceName(), type.name());
}
@@ -556,8 +556,8 @@ public class JavaTypesGenerator implements Generator {
private JavaExpression arbitraryValue(Type type, Context context) {
return switch (this.javaGenerator.collapseType(type)) {
- case ConstructedNativeType constructedNativeType -> {
- yield arbitraryValue(constructedNativeType.constructor().genericType(), context);
+ case ConstructedType constructedType -> {
+ yield arbitraryValue(constructedType.constructor().genericType(), context);
}
case EnumType enumType -> {
@@ -581,7 +581,7 @@ public class JavaTypesGenerator implements Generator {
});
}
- case StructType structType -> {
+ case SimpleStructType structType -> {
yield new JavaMethodCall(
new JavaStaticMethodCall(generateTypeRef(structType, context), ARBITRARY_METHOD_NAME, List.of()),
BUILD_METHOD_NAME,
@@ -631,11 +631,11 @@ public class JavaTypesGenerator implements Generator {
return this.typesInfo.enumVariants(type);
}
- public Optional<List<Field>> fieldsOf(StructType type) {
+ public Optional<List<Field>> fieldsOf(SimpleStructType type) {
return this.typesInfo.fieldsOf(type);
}
- public List<SumType> variantOf(StructType type) {
+ public List<SumType> variantOf(SimpleStructType type) {
return this.typesInfo.variantOf(type);
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java
index 602c804..089a854 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java
@@ -34,11 +34,11 @@ public class RustGenerator {
public RustPath generateRustTypeExpression(Type type) {
return switch (type) {
- case ConstructedNativeType constructedNativeType -> {
+ case ConstructedType constructedType -> {
var rustType = generateRustTypeExpression(
- constructedNativeType.constructor().genericType()
+ constructedType.constructor().genericType()
);
- var rustArgs = constructedNativeType.args().stream()
+ var rustArgs = constructedType.args().stream()
.<RustType>map(arg -> generateRustTypeExpression(arg))
.toList();
yield rustType.withArgs(rustArgs);
@@ -60,7 +60,7 @@ public class RustGenerator {
));
}
- case StructType structType -> {
+ case SimpleStructType structType -> {
yield generateTypePath(
structType.namespaceName(),
structType.name()
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java
index 49a35f6..b2319d6 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java
@@ -634,21 +634,21 @@ public class RustTransient0Generator implements Generator {
private RustStatement generateEncode(RustExpression value, Type type) {
return switch (type) {
- case ConstructedNativeType constructedNativeType -> {
- if (constructedNativeType.constructor().equals(NativeTypes.BOX)) {
- yield generateEncodeBox(value, constructedNativeType.args().getFirst());
- } else if (constructedNativeType.constructor().equals(NativeTypes.LIST)) {
- yield generateEncodeList(value, constructedNativeType.args().getFirst());
- } else if (constructedNativeType.constructor().equals(NativeTypes.OPTION)) {
- yield generateEncodeOption(value, constructedNativeType.args().getFirst());
- } else if (constructedNativeType.constructor().equals(NativeTypes.SHARED)) {
- yield generateEncodeShared(value, constructedNativeType.args().getFirst());
+ case ConstructedType constructedType -> {
+ if (constructedType.constructor().equals(NativeTypes.BOX)) {
+ yield generateEncodeBox(value, constructedType.args().getFirst());
+ } else if (constructedType.constructor().equals(NativeTypes.LIST)) {
+ yield generateEncodeList(value, constructedType.args().getFirst());
+ } else if (constructedType.constructor().equals(NativeTypes.OPTION)) {
+ yield generateEncodeOption(value, constructedType.args().getFirst());
+ } else if (constructedType.constructor().equals(NativeTypes.SHARED)) {
+ yield generateEncodeShared(value, constructedType.args().getFirst());
} else {
yield generateEncode(
value,
- constructedNativeType.namespaceName(),
+ constructedType.namespaceName(),
type,
- constructedNativeType.args().stream()
+ constructedType.args().stream()
.<RustExpression>map(typeArg -> new RustClosureExpression(
RustGenerator.functionParamsToClosureParams(generateEncodeParams(
this.rustGenerator.generateRustTypeExpression(typeArg)
@@ -682,20 +682,20 @@ public class RustTransient0Generator implements Generator {
private RustExpression generateDecode(Type type) {
return switch (type) {
- case ConstructedNativeType constructedNativeType -> {
- if (constructedNativeType.constructor().equals(NativeTypes.BOX)) {
- yield generateDecodeBox(constructedNativeType.args().getFirst());
- } else if (constructedNativeType.constructor().equals(NativeTypes.LIST)) {
- yield generateDecodeList(constructedNativeType.args().getFirst());
- } else if (constructedNativeType.constructor().equals(NativeTypes.OPTION)) {
- yield generateDecodeOption(constructedNativeType.args().getFirst());
- } else if (constructedNativeType.constructor().equals(NativeTypes.SHARED)) {
- yield generateDecodeShared(constructedNativeType.args().getFirst());
+ case ConstructedType constructedType -> {
+ if (constructedType.constructor().equals(NativeTypes.BOX)) {
+ yield generateDecodeBox(constructedType.args().getFirst());
+ } else if (constructedType.constructor().equals(NativeTypes.LIST)) {
+ yield generateDecodeList(constructedType.args().getFirst());
+ } else if (constructedType.constructor().equals(NativeTypes.OPTION)) {
+ yield generateDecodeOption(constructedType.args().getFirst());
+ } else if (constructedType.constructor().equals(NativeTypes.SHARED)) {
+ yield generateDecodeShared(constructedType.args().getFirst());
} else {
yield generateDecode(
- constructedNativeType.namespaceName(),
- constructedNativeType,
- constructedNativeType.args().stream()
+ constructedType.namespaceName(),
+ constructedType,
+ constructedType.args().stream()
.<RustExpression>map(typeArg -> new RustClosureExpression(
RustGenerator.functionParamsToClosureParams(generateDecodeParams()),
new RustCallExpression(
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java
index e403f5b..e1ad8d2 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java
@@ -207,7 +207,7 @@ public class TypeChecker {
UntypedStructDefinitionNode untyped,
TypeCheckerNamespaceContext context
) {
- var structType = new StructType(context.namespaceName(), untyped.name());
+ var structType = new SimpleStructType(context.namespaceName(), untyped.name());
var metaType = new TypeLevelValueType(structType);
context.declare(untyped.name(), metaType, untyped.source());
return metaType;
@@ -217,7 +217,7 @@ public class TypeChecker {
UntypedStructDefinitionNode untyped,
TypeCheckerNamespaceContext context
) {
- var structType = (StructType) lookupMetaType(untyped.name(), untyped.source(), context);
+ var structType = (SimpleStructType) lookupMetaType(untyped.name(), untyped.source(), context);
var typeCheckedFieldDefinitions = untyped.fields().isPresent()
? Optional.of(typeCheckFieldDefinitions(untyped.fields().get(), context))
@@ -307,7 +307,7 @@ public class TypeChecker {
variantValueType = variantType.value();
}
- if (!(variantValueType instanceof StructType variantValueStructType)) {
+ if (!(variantValueType instanceof SimpleStructType variantValueStructType)) {
throw new SumVariantMustBeStructError(variantValueType, untypedVariant.source());
}
@@ -371,7 +371,7 @@ public class TypeChecker {
private static void typeCheckVariantType(
SumType sumType,
List<Field> sumTypeFields,
- StructType variantType,
+ SimpleStructType variantType,
Optional<List<Field>> variantTypeFields,
TypesInfo typesInfo
) {
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerNamespaceContext.java b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerNamespaceContext.java
index 56bc5ed..2c8ad67 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerNamespaceContext.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerNamespaceContext.java
@@ -61,15 +61,15 @@ public class TypeCheckerNamespaceContext {
this.typesInfo.defineEnumType(enumType, enumVariants);
}
- public void defineStructType(StructType structType, Optional<List<Field>> fields) {
+ public void defineStructType(SimpleStructType structType, Optional<List<Field>> fields) {
this.typesInfo.defineStructType(structType, fields);
}
- public boolean isDefined(StructType type) {
+ public boolean isDefined(SimpleStructType type) {
return this.typesInfo.isDefined(type);
}
- public Optional<List<Field>> fieldsOf(StructType type) {
+ public Optional<List<Field>> fieldsOf(SimpleStructType type) {
return this.typesInfo.fieldsOf(type);
}
@@ -82,7 +82,7 @@ public class TypeCheckerNamespaceContext {
this.typesInfo.defineSumType(sumType, variantTypes, fields, source);
}
- public List<SumType> variantOf(StructType variantType) {
+ public List<SumType> variantOf(SimpleStructType variantType) {
return this.typesInfo.variantOf(variantType);
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypesInfo.java b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypesInfo.java
index d812753..d13d2c6 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypesInfo.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypesInfo.java
@@ -8,10 +8,10 @@ import java.util.Optional;
public interface TypesInfo {
TypesInfo EMPTY = TypesInfoInMemory.empty();
- boolean isDefined(StructType type);
- Optional<List<Field>> fieldsOf(StructType structType);
+ boolean isDefined(SimpleStructType type);
+ Optional<List<Field>> fieldsOf(SimpleStructType structType);
- List<SumType> variantOf(StructType variantType);
+ List<SumType> variantOf(SimpleStructType variantType);
List<SumVariant> sumVariants(SumType type);
SumTypeInfo sumTypeInfo(SumType type);
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypesInfoInMemory.java b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypesInfoInMemory.java
index f97badf..67d5c3b 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypesInfoInMemory.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypesInfoInMemory.java
@@ -20,13 +20,13 @@ public class TypesInfoInMemory implements TypesInfo {
private final Map<Type, Optional<List<Field>>> structFields;
private final Map<SumType, SumTypeInfo> sumTypeInfos;
- private final Map<StructType, List<SumType>> variantToSums;
+ private final Map<SimpleStructType, List<SumType>> variantToSums;
private TypesInfoInMemory(
Map<EnumType, List<EnumVariant>> enumVariants,
Map<Type, Optional<List<Field>>> structFields,
Map<SumType, SumTypeInfo> sumTypeInfos,
- Map<StructType, List<SumType>> variantToSums
+ Map<SimpleStructType, List<SumType>> variantToSums
) {
this.enumVariants = enumVariants;
this.structFields = structFields;
@@ -42,17 +42,17 @@ public class TypesInfoInMemory implements TypesInfo {
return this.enumVariants.get(enumType);
}
- public void defineStructType(StructType structType, Optional<List<Field>> fields) {
+ public void defineStructType(SimpleStructType structType, Optional<List<Field>> fields) {
this.structFields.put(structType, fields);
}
@Override
- public boolean isDefined(StructType type) {
+ public boolean isDefined(SimpleStructType type) {
return this.structFields.containsKey(type);
}
@Override
- public Optional<List<Field>> fieldsOf(StructType structType) {
+ public Optional<List<Field>> fieldsOf(SimpleStructType structType) {
var fields = this.structFields.get(structType);
if (fields == null) {
// TODO: better error
@@ -77,7 +77,7 @@ public class TypesInfoInMemory implements TypesInfo {
}
}
- public List<SumType> variantOf(StructType variantType) {
+ public List<SumType> variantOf(SimpleStructType variantType) {
return this.variantToSums.getOrDefault(variantType, List.of());
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedNativeType.java b/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedNativeType.java
index 5e49e31..8accfc7 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedNativeType.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedNativeType.java
@@ -1,26 +1,9 @@
package org.zwobble.hobgoblin.compiler.types;
import java.util.List;
-import java.util.stream.Collectors;
public record ConstructedNativeType(
TypeConstructor<SimpleNativeType> constructor,
List<Type> args
) implements ConstructedType, Type {
- public NamespaceName namespaceName() {
- return constructor.genericType().namespaceName();
- }
-
- @Override
- public String name() {
- return constructor.genericType().name();
- }
-
- @Override
- public String describe() {
- var argsString = args().stream()
- .map(arg -> arg.describe())
- .collect(Collectors.joining(", "));
- return constructor.describe() + "[" + argsString + "]";
- }
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedStructType.java b/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedStructType.java
new file mode 100644
index 0000000..a95e07f
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedStructType.java
@@ -0,0 +1,9 @@
+package org.zwobble.hobgoblin.compiler.types;
+
+import java.util.List;
+
+public record ConstructedStructType(
+ TypeConstructor<SimpleStructType> constructor,
+ List<Type> args
+) implements ConstructedType, Type {
+}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedType.java b/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedType.java
index 6224331..2488821 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedType.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructedType.java
@@ -1,4 +1,26 @@
package org.zwobble.hobgoblin.compiler.types;
-public sealed interface ConstructedType extends Type permits ConstructedNativeType {
+import java.util.List;
+import java.util.stream.Collectors;
+
+public sealed interface ConstructedType extends Type permits ConstructedNativeType, ConstructedStructType {
+ TypeConstructor<? extends SimpleType> constructor();
+ List<Type> args();
+
+ default NamespaceName namespaceName() {
+ return constructor().genericType().namespaceName();
+ }
+
+ @Override
+ default String name() {
+ return constructor().genericType().name();
+ }
+
+ @Override
+ default String describe() {
+ var argsString = args().stream()
+ .map(arg -> arg.describe())
+ .collect(Collectors.joining(", "));
+ return constructor().describe() + "[" + argsString + "]";
+ }
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructibleType.java b/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructibleType.java
index 50b298d..05fd042 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructibleType.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/types/ConstructibleType.java
@@ -1,4 +1,4 @@
package org.zwobble.hobgoblin.compiler.types;
-public sealed interface ConstructibleType extends Type permits SimpleNativeType {
+public sealed interface ConstructibleType extends Type permits SimpleNativeType, SimpleStructType {
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/types/StructType.java b/src/main/java/org/zwobble/hobgoblin/compiler/types/SimpleStructType.java
index 5012203..a67eeb0 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/types/StructType.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/types/SimpleStructType.java
@@ -1,6 +1,6 @@
package org.zwobble.hobgoblin.compiler.types;
-public record StructType(NamespaceName namespaceName, String name) implements Type, SimpleType {
+public record SimpleStructType(NamespaceName namespaceName, String name) implements Type, SimpleType, ConstructibleType {
@Override
public String describe() {
return namespaceName.toString() + "." + name;
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/types/SimpleType.java b/src/main/java/org/zwobble/hobgoblin/compiler/types/SimpleType.java
index 2160802..f02ff59 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/types/SimpleType.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/types/SimpleType.java
@@ -1,5 +1,5 @@
package org.zwobble.hobgoblin.compiler.types;
-public sealed interface SimpleType extends Type permits EnumType, SimpleNativeType, StructType, SumType {
+public sealed interface SimpleType extends Type permits EnumType, SimpleNativeType, SimpleStructType, SumType {
NamespaceName namespaceName();
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/types/SumVariant.java b/src/main/java/org/zwobble/hobgoblin/compiler/types/SumVariant.java
index 72dbe71..c2e716d 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/types/SumVariant.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/types/SumVariant.java
@@ -5,7 +5,7 @@ import org.zwobble.hobgoblin.compiler.builtins.NativeTypes;
public record SumVariant(
int tag,
Type containerType,
- StructType valueType
+ SimpleStructType valueType
) {
public boolean isBox() {
return (
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/types/Type.java b/src/main/java/org/zwobble/hobgoblin/compiler/types/Type.java
index 90dcc9b..57b85cd 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/types/Type.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/types/Type.java
@@ -1,5 +1,5 @@
package org.zwobble.hobgoblin.compiler.types;
-public sealed interface Type extends TypeLevelValue permits ConstructedNativeType, ConstructedType, ConstructibleType, EnumType, SimpleNativeType, SimpleType, StructType, SumType, TypeLevelValueType, TypeParam {
+public sealed interface Type extends TypeLevelValue permits ConstructedNativeType, ConstructedStructType, ConstructedType, ConstructibleType, EnumType, SimpleNativeType, SimpleType, SimpleStructType, SumType, TypeLevelValueType, TypeParam {
String name();
}
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/analysis/ArbitraryValueAnalysisTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/analysis/ArbitraryValueAnalysisTests.java
index b802386..7238a3d 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/analysis/ArbitraryValueAnalysisTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/analysis/ArbitraryValueAnalysisTests.java
@@ -34,7 +34,7 @@ public class ArbitraryValueAnalysisTests {
@Test
public void whenTypeIsInfiniteThenErrorIsThrown() {
var sumType = new SumType(NamespaceName.of(), "X");
- var variantType = new StructType(NamespaceName.of(), "Y");
+ var variantType = new SimpleStructType(NamespaceName.of(), "Y");
var typesInfo = TypesInfoInMemory.empty();
typesInfo.defineSumType(
sumType,
@@ -59,8 +59,8 @@ public class ArbitraryValueAnalysisTests {
@Test
public void firstNonRecursivelyConstructibleVariantIsChosen() {
var sumType = new SumType(NamespaceName.of(), "X");
- var recursiveVariantType = new StructType(NamespaceName.of(), "Y");
- var nonRecursiveVariantType = new StructType(NamespaceName.of(), "Z");
+ var recursiveVariantType = new SimpleStructType(NamespaceName.of(), "Y");
+ var nonRecursiveVariantType = new SimpleStructType(NamespaceName.of(), "Z");
var typesInfo = TypesInfoInMemory.empty();
typesInfo.defineSumType(
sumType,
@@ -86,8 +86,8 @@ public class ArbitraryValueAnalysisTests {
@Test
public void boxIsRecursivelyConstructibleIffInnerTypeIsRecursivelyConstructible() {
var sumType = new SumType(NamespaceName.of(), "X");
- var recursiveVariantType = new StructType(NamespaceName.of(), "Y");
- var nonRecursiveVariantType = new StructType(NamespaceName.of(), "Z");
+ var recursiveVariantType = new SimpleStructType(NamespaceName.of(), "Y");
+ var nonRecursiveVariantType = new SimpleStructType(NamespaceName.of(), "Z");
var typesInfo = TypesInfoInMemory.empty();
typesInfo.defineSumType(
sumType,
@@ -113,8 +113,8 @@ public class ArbitraryValueAnalysisTests {
@Test
public void listIsAlwaysNonRecursivelyConstructible() {
var sumType = new SumType(NamespaceName.of(), "X");
- var recursiveVariantType = new StructType(NamespaceName.of(), "Y");
- var nonRecursiveVariantType = new StructType(NamespaceName.of(), "Z");
+ var recursiveVariantType = new SimpleStructType(NamespaceName.of(), "Y");
+ var nonRecursiveVariantType = new SimpleStructType(NamespaceName.of(), "Z");
var typesInfo = TypesInfoInMemory.empty();
typesInfo.defineSumType(
sumType,
@@ -140,8 +140,8 @@ public class ArbitraryValueAnalysisTests {
@Test
public void optionIsAlwaysNonRecursivelyConstructible() {
var sumType = new SumType(NamespaceName.of(), "X");
- var recursiveVariantType = new StructType(NamespaceName.of(), "Y");
- var nonRecursiveVariantType = new StructType(NamespaceName.of(), "Z");
+ var recursiveVariantType = new SimpleStructType(NamespaceName.of(), "Y");
+ var nonRecursiveVariantType = new SimpleStructType(NamespaceName.of(), "Z");
var typesInfo = TypesInfoInMemory.empty();
typesInfo.defineSumType(
sumType,
@@ -167,8 +167,8 @@ public class ArbitraryValueAnalysisTests {
@Test
public void sharedIsRecursivelyConstructibleIffInnerTypeIsRecursivelyConstructible() {
var sumType = new SumType(NamespaceName.of(), "X");
- var recursiveVariantType = new StructType(NamespaceName.of(), "Y");
- var nonRecursiveVariantType = new StructType(NamespaceName.of(), "Z");
+ var recursiveVariantType = new SimpleStructType(NamespaceName.of(), "Y");
+ var nonRecursiveVariantType = new SimpleStructType(NamespaceName.of(), "Z");
var typesInfo = TypesInfoInMemory.empty();
typesInfo.defineSumType(
sumType,
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerNamespaceTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerNamespaceTests.java
index 95ad671..9545bce 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerNamespaceTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerNamespaceTests.java
@@ -41,14 +41,14 @@ public class TypeCheckerNamespaceTests {
has(
"type",
TypedStructDefinitionNode::type,
- equalTo(new StructType(NamespaceName.of("a", "b"), "X"))
+ equalTo(new SimpleStructType(NamespaceName.of("a", "b"), "X"))
)
)
))
)));
assertThat(
context.namespaceFields(NamespaceName.of("a", "b")).orElseThrow().fieldType("X").orElseThrow(),
- isMetaType(new StructType(NamespaceName.of("a", "b"), "X"))
+ isMetaType(new SimpleStructType(NamespaceName.of("a", "b"), "X"))
);
}
@@ -93,13 +93,13 @@ public class TypeCheckerNamespaceTests {
has(
"type",
TypedStructDefinitionNode::type,
- equalTo(new StructType(NamespaceName.of("a", "b"), "X"))
+ equalTo(new SimpleStructType(NamespaceName.of("a", "b"), "X"))
)
)
))
)));
assertThat(
- context.toTypesInfo().fieldsOf(new StructType(NamespaceName.of("a", "b"), "X")),
+ context.toTypesInfo().fieldsOf(new SimpleStructType(NamespaceName.of("a", "b"), "X")),
isOptionalOf(isSequence(
isField("y", new SimpleNativeType(NamespaceName.of("a", "c"), "Y"))
))
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java
index ceb7a9b..905ff32 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java
@@ -11,7 +11,7 @@ import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedStructDefinitionNode;
import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedStructFieldDefinitionNode;
import org.zwobble.hobgoblin.compiler.types.NamespaceName;
import org.zwobble.hobgoblin.compiler.types.SimpleNativeType;
-import org.zwobble.hobgoblin.compiler.types.StructType;
+import org.zwobble.hobgoblin.compiler.types.SimpleStructType;
import java.util.List;
import java.util.Optional;
@@ -36,7 +36,7 @@ public class TypeCheckerStructDefinitionTests {
has(
"type",
TypedStructDefinitionNode::type,
- equalTo(new StructType(NamespaceName.of("a", "b"), "X"))
+ equalTo(new SimpleStructType(NamespaceName.of("a", "b"), "X"))
)
));
}
@@ -87,7 +87,7 @@ public class TypeCheckerStructDefinitionTests {
));
var typesInfo = globalContext.toTypesInfo();
assertThat(
- typesInfo.fieldsOf(new StructType(namespaceName, "X")),
+ typesInfo.fieldsOf(new SimpleStructType(namespaceName, "X")),
isOptionalOf(isSequence(
isField("a", int32Type),
isField("b", int64Type)
@@ -121,7 +121,7 @@ public class TypeCheckerStructDefinitionTests {
));
var typesInfo = globalContext.toTypesInfo();
assertThat(
- typesInfo.fieldsOf(new StructType(namespaceName, "X")),
+ typesInfo.fieldsOf(new SimpleStructType(namespaceName, "X")),
isOptionalEmpty()
);
}
@@ -168,7 +168,7 @@ public class TypeCheckerStructDefinitionTests {
has("type", TypedStructFieldDefinitionNode::type, has(
"value",
TypedTypeLevelExpressionNode::value,
- equalTo(new StructType(namespaceName, "Y"))
+ equalTo(new SimpleStructType(namespaceName, "Y"))
))
)
))
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSubtypingTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSubtypingTests.java
index f22bc3e..0790561 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSubtypingTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSubtypingTests.java
@@ -33,8 +33,8 @@ public class TypeCheckerSubtypingTests {
@Test
public void variantIsSubtypeOfSumType() {
- var variantType1 = new StructType(NamespaceName.of(), "Rectangle");
- var variantType2 = new StructType(NamespaceName.of(), "Circle");
+ var variantType1 = new SimpleStructType(NamespaceName.of(), "Rectangle");
+ var variantType2 = new SimpleStructType(NamespaceName.of(), "Circle");
var sumType = new SumType(NamespaceName.of(), "Shape");
var typesInfo = TypesInfoInMemory.empty();
typesInfo.defineSumType(
@@ -56,8 +56,8 @@ public class TypeCheckerSubtypingTests {
public void variantIsNotSubtypeOfUnrelatedSumType() {
var typesInfo = TypesInfoInMemory.empty();
- var variantType1 = new StructType(NamespaceName.of(), "Rectangle");
- var variantType2 = new StructType(NamespaceName.of(), "Circle");
+ var variantType1 = new SimpleStructType(NamespaceName.of(), "Rectangle");
+ var variantType2 = new SimpleStructType(NamespaceName.of(), "Circle");
var sumType = new SumType(NamespaceName.of(), "Shape");
typesInfo.defineSumType(
sumType,
@@ -70,7 +70,7 @@ public class TypeCheckerSubtypingTests {
);
var otherSumType = new SumType(NamespaceName.of(), "Shape3D");
- var otherVariantType = new StructType(NamespaceName.of(), "Cube");
+ var otherVariantType = new SimpleStructType(NamespaceName.of(), "Cube");
typesInfo.defineSumType(
otherSumType,
List.of(new SumVariant(0, otherVariantType, otherVariantType)),
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java
index be9790a..693f2fa 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java
@@ -44,8 +44,8 @@ public class TypeCheckerSumDefinitionTests {
@Test
public void variantsAreTypeChecked() {
- var rectangleType = new StructType(NamespaceName.of("a", "b"), "Rectangle");
- var triangleType = new StructType(NamespaceName.of("a", "b"), "Triangle");
+ var rectangleType = new SimpleStructType(NamespaceName.of("a", "b"), "Rectangle");
+ var triangleType = new SimpleStructType(NamespaceName.of("a", "b"), "Triangle");
var untyped = UntypedSumDefinitionNode.arbitrary()
.withName("X")
.withVariants(List.of(
@@ -95,8 +95,8 @@ public class TypeCheckerSumDefinitionTests {
@Test
public void variantCanHaveBoxType() {
- var rectangleType = new StructType(NamespaceName.of("a", "b"), "Rectangle");
- var triangleType = new StructType(NamespaceName.of("a", "b"), "Triangle");
+ var rectangleType = new SimpleStructType(NamespaceName.of("a", "b"), "Rectangle");
+ var triangleType = new SimpleStructType(NamespaceName.of("a", "b"), "Triangle");
var untyped = UntypedSumDefinitionNode.arbitrary()
.withName("X")
.withVariants(List.of(
@@ -184,7 +184,7 @@ public class TypeCheckerSumDefinitionTests {
.build()
))
.build();
- var variantType = new StructType(NamespaceName.of("other"), "Variant");
+ var variantType = new SimpleStructType(NamespaceName.of("other"), "Variant");
var globalContext = TypeCheckerGlobalContext.initial();
globalContext.addNativeTypeConstructor(NativeTypes.BOX);
var namespaceContext = globalContext
@@ -273,7 +273,7 @@ public class TypeCheckerSumDefinitionTests {
var namespaceName = NamespaceName.of("a", "b");
var namespaceContext = globalContext
.enterNamespace(namespaceName);
- var variantType = new StructType(namespaceName, "Square");
+ var variantType = new SimpleStructType(namespaceName, "Square");
namespaceContext.declare("Square", new TypeLevelValueType(variantType), NullSource.INSTANCE);
namespaceContext.defineStructType(variantType, Optional.of(List.of()));
@@ -310,7 +310,7 @@ public class TypeCheckerSumDefinitionTests {
var namespaceName = NamespaceName.of("a", "b");
var namespaceContext = globalContext
.enterNamespace(namespaceName);
- var variantType = new StructType(namespaceName, "Square");
+ var variantType = new SimpleStructType(namespaceName, "Square");
namespaceContext.declare("Square", new TypeLevelValueType(variantType), NullSource.INSTANCE);
namespaceContext.defineStructType(variantType, Optional.of(List.of(new Field("area", int64Type, NullSource.INSTANCE))));
@@ -346,7 +346,7 @@ public class TypeCheckerSumDefinitionTests {
var namespaceName = NamespaceName.of("a", "b");
var namespaceContext = globalContext
.enterNamespace(namespaceName);
- var variantType = new StructType(namespaceName, "Square");
+ var variantType = new SimpleStructType(namespaceName, "Square");
namespaceContext.declare("Square", new TypeLevelValueType(variantType), NullSource.INSTANCE);
namespaceContext.defineStructType(variantType, Optional.of(List.of()));
@@ -368,7 +368,7 @@ public class TypeCheckerSumDefinitionTests {
var namespaceContext = globalContext
.enterNamespace(namespaceName);
var sumType = new SumType(namespaceName, "Shape");
- var variantType = new StructType(namespaceName, "Square");
+ var variantType = new SimpleStructType(namespaceName, "Square");
namespaceContext.declare("Sum", new TypeLevelValueType(sumType), NullSource.INSTANCE);
namespaceContext.defineSumType(
sumType,