From e6a7ea7a3eaecd2399d02c7264b89295752a63b7 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 31 Dec 2023 10:05:08 +0000 Subject: Fix common supertype when first type is Bottom --- src/main/java/org/shedlang/compiler/types/Types.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/types/Types.java b/src/main/java/org/shedlang/compiler/types/Types.java index 20c8e0cc..45476a03 100644 --- a/src/main/java/org/shedlang/compiler/types/Types.java +++ b/src/main/java/org/shedlang/compiler/types/Types.java @@ -51,12 +51,13 @@ public class Types { public static ConstructedType constructedType( TypeConstructor constructor, - List args + List args ) { return new ConstructedType<>(constructor, args); } public static Type commonSupertype(List subtypes) { + // TODO: test this! var uniqueSubtypes = subtypes.stream() .filter(subtype -> subtype != Types.BOTTOM) .collect(Collectors.toSet()); @@ -64,7 +65,7 @@ public class Types { if (uniqueSubtypes.isEmpty()) { return BOTTOM; } else if (uniqueSubtypes.size() == 1) { - return subtypes.get(0); + return uniqueSubtypes.iterator().next(); } else { return TOP; } -- cgit v1.2.3