aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-31 10:05:08 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-31 10:05:08 +0000
commite6a7ea7a3eaecd2399d02c7264b89295752a63b7 (patch)
treeb27dcf0f22235c5be0698151f8c32ec6c96dbde3 /src/main/java
parent73ddea59a1628f9aa12a32297129138cf6f481b4 (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.java5
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;
}