diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-01-03 21:46:20 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-01-03 21:46:20 +0000 |
| commit | 2b07a0dd23552612aa05f826763e061604fc61fd (patch) | |
| tree | 748bdba9ed53d7840ffd5fdc07a1501f6bd60fb2 /src/main/java | |
| parent | d81c270ad90334f47e39e2dd3b00d47796cdc348 (diff) | |
Test subtyping when supertype is bound type param
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/types/TypeSubstitutionMap.java | 21 |
1 files changed, 21 insertions, 0 deletions
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 + + ')'; + } } |
