diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-12-31 10:05:08 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-12-31 10:05:08 +0000 |
| commit | e6a7ea7a3eaecd2399d02c7264b89295752a63b7 (patch) | |
| tree | b27dcf0f22235c5be0698151f8c32ec6c96dbde3 /src/main/java | |
| parent | 73ddea59a1628f9aa12a32297129138cf6f481b4 (diff) | |
Fix common supertype when first type is Bottom
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/types/Types.java | 5 |
1 files changed, 3 insertions, 2 deletions
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 <T extends StructuredType> ConstructedType<T> constructedType( TypeConstructor<T> constructor, - List<Type> args + List<? extends Type> args ) { return new ConstructedType<>(constructor, args); } public static Type commonSupertype(List<Type> 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; } |
