diff options
Diffstat (limited to 'src/main/java')
3 files changed, 4 insertions, 14 deletions
diff --git a/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java b/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java index 73076a74..fd7fa39e 100644 --- a/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java +++ b/src/main/java/org/shedlang/compiler/typechecker/TypeChecker.java @@ -2093,7 +2093,7 @@ public class TypeChecker { } for (var variantType : variantTypes) { - if (!handledVariantTypes.contains(variantType.toType())) { + if (!handledVariantTypes.contains(variantType.type())) { throw new UnhandledVariantError(variantType, untyped.source()); } } diff --git a/src/main/java/org/shedlang/compiler/typechecker/TypeCheckerSubTyping.java b/src/main/java/org/shedlang/compiler/typechecker/TypeCheckerSubTyping.java index 4aab5370..49560f38 100644 --- a/src/main/java/org/shedlang/compiler/typechecker/TypeCheckerSubTyping.java +++ b/src/main/java/org/shedlang/compiler/typechecker/TypeCheckerSubTyping.java @@ -25,7 +25,7 @@ public class TypeCheckerSubTyping { if (supertype instanceof SumType supertypeSum) { var superTypeInfo = context.sumTypeInfo(supertypeSum, Sources.NULL); return superTypeInfo.variants().stream() - .anyMatch(supertypeVariant -> isSubType(subtype, supertypeVariant.toType(), context)); + .anyMatch(supertypeVariant -> isSubType(subtype, supertypeVariant.type(), context)); } if ( @@ -35,7 +35,7 @@ public class TypeCheckerSubTyping { // TODO: merge with logic for plain sum types var superTypeInfo = context.sumTypeInfo((ConstructedType<SumType>) supertypeConstructedType, Sources.NULL); return superTypeInfo.variants().stream() - .anyMatch(supertypeVariant -> isSubType(subtype, supertypeVariant.toType(), context)); + .anyMatch(supertypeVariant -> isSubType(subtype, supertypeVariant.type(), context)); } if ( diff --git a/src/main/java/org/shedlang/compiler/types/SumVariant.java b/src/main/java/org/shedlang/compiler/types/SumVariant.java index 0270a93c..9ea1c848 100644 --- a/src/main/java/org/shedlang/compiler/types/SumVariant.java +++ b/src/main/java/org/shedlang/compiler/types/SumVariant.java @@ -11,18 +11,13 @@ public sealed interface SumVariant { String describe(); - Type toType(); + Type type(); record ConstructedStruct(ConstructedType<StructType> type) implements SumVariant { @Override public String describe() { return type.describe(); } - - @Override - public Type toType() { - return type; - } } record Struct(StructType type) implements SumVariant { @@ -30,10 +25,5 @@ public sealed interface SumVariant { public String describe() { return type.describe(); } - - @Override - public Type toType() { - return type; - } } } |
