From 2b07a0dd23552612aa05f826763e061604fc61fd Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 3 Jan 2024 21:46:20 +0000 Subject: Test subtyping when supertype is bound type param --- .../compiler/types/TypeSubstitutionMap.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/types/TypeSubstitutionMap.java b/src/main/java/org/shedlang/compiler/types/TypeSubstitutionMap.java index 0ca6b602..69cc2dba 100644 --- a/src/main/java/org/shedlang/compiler/types/TypeSubstitutionMap.java +++ b/src/main/java/org/shedlang/compiler/types/TypeSubstitutionMap.java @@ -1,6 +1,7 @@ package org.shedlang.compiler.types; import java.util.Map; +import java.util.Objects; public class TypeSubstitutionMap { @SafeVarargs @@ -17,4 +18,24 @@ public class TypeSubstitutionMap { public Type substitute(TypeParam typeParam) { return this.map.getOrDefault(typeParam, typeParam); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TypeSubstitutionMap that = (TypeSubstitutionMap) o; + return Objects.equals(map, that.map); + } + + @Override + public int hashCode() { + return Objects.hash(map); + } + + @Override + public String toString() { + return "TypeSubstitutionMap(" + + "map=" + map + + ')'; + } } -- cgit v1.2.3