From 07b45fbec7b289fc70cdeccacb6a6a424dc58b7e Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 16 Sep 2024 20:25:12 +0200 Subject: [PATCH] wasm gc: fix issues with switch expression --- .../teavm/classlib/impl/SwitchBootstrapSubstitutor.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/impl/SwitchBootstrapSubstitutor.java b/classlib/src/main/java/org/teavm/classlib/impl/SwitchBootstrapSubstitutor.java index cedd3271b..63c7a76ec 100644 --- a/classlib/src/main/java/org/teavm/classlib/impl/SwitchBootstrapSubstitutor.java +++ b/classlib/src/main/java/org/teavm/classlib/impl/SwitchBootstrapSubstitutor.java @@ -89,14 +89,14 @@ public class SwitchBootstrapSubstitutor implements BootstrapMethodSubstitutor { int val = label.getInt(); pe.when(() -> target.instanceOf(ValueType.object("java.lang.Number")).isTrue() .and(() -> target.cast(Number.class) - .invokeVirtual("intValue", int.class).isSame(pe.constant(val)))) + .invokeVirtual("intValue", int.class).isEqualTo(pe.constant(val)))) .thenDo(() -> { pe.constant(idx).propagateTo(result); pe.jump(exit); }); pe.when(() -> target.instanceOf(ValueType.object("java.lang.Character")).isTrue() .and(() -> target.cast(Character.class) - .invokeSpecial("charValue", char.class).isSame(pe.constant(val)))) + .invokeSpecial("charValue", char.class).isEqualTo(pe.constant(val)))) .thenDo(() -> { pe.constant(idx).propagateTo(result); pe.jump(exit); @@ -106,7 +106,8 @@ public class SwitchBootstrapSubstitutor implements BootstrapMethodSubstitutor { String str = label.getString(); pe.when(enumType != null ? () -> pe.getField(enumType.getClassName(), str, enumType).isSame(target) - : () -> pe.constant(str).isEqualTo(target)) + : () -> pe.constant(str).invokeVirtual("equals", boolean.class, + target.cast(Object.class)).isTrue()) .thenDo(() -> { pe.constant(idx).propagateTo(result); pe.jump(exit);