diff --git a/src/de/inetsoftware/jwebassembly/wasm/AnyType.java b/src/de/inetsoftware/jwebassembly/wasm/AnyType.java index fb2c00d..36acf7b 100644 --- a/src/de/inetsoftware/jwebassembly/wasm/AnyType.java +++ b/src/de/inetsoftware/jwebassembly/wasm/AnyType.java @@ -49,9 +49,9 @@ public interface AnyType { /** * Check if this is a sub type of given type. * - * @param type + * @param other * type to check - * @return true, if both are identical or the type is a sub type + * @return true, if both are identical or this is a sub type of other. Or if other is a parent type of this. */ - public boolean isSubTypeOf( @Nonnull AnyType type ); + public boolean isSubTypeOf( @Nonnull AnyType other ); } diff --git a/src/de/inetsoftware/jwebassembly/wasm/ValueType.java b/src/de/inetsoftware/jwebassembly/wasm/ValueType.java index 041563c..d90b7d1 100644 --- a/src/de/inetsoftware/jwebassembly/wasm/ValueType.java +++ b/src/de/inetsoftware/jwebassembly/wasm/ValueType.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2020 Volker Berlin (i-net software) + * Copyright 2017 - 2022 Volker Berlin (i-net software) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,8 +29,8 @@ public enum ValueType implements AnyType { i16(-0x07), u16(-0x07), funcref(-0x10), - externref(-0x11), - anyref(-0x12), + externref(-0x11), //TODO rename to any + anyref(-0x12), // TODO obsolete eqref(-0x13), optref(-0x14), ref(-0x15), @@ -76,6 +76,16 @@ public enum ValueType implements AnyType { */ @Override public boolean isSubTypeOf( AnyType type ) { - return type == this; + if( type == this ) { + return true; + } + switch( this ) { + case externref: + return type.isRefType(); + case eqref: + return type.isRefType() || type == externref; + default: + return false; + } } }