diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java index b898315b7878..25f62dbef3ad 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java @@ -257,12 +257,15 @@ public static boolean anyToJBoolean(Object sourceVal) { * @return true if the value belongs to the given type, false otherwise */ public static boolean checkIsType(Object sourceVal, Type targetType) { - Context cx = context(); Type sourceType = getType(sourceVal); + if (sourceType == targetType || (sourceType.getTag() == targetType.getTag() && sourceType.equals(targetType))) { + return true; + } if (isSubType(sourceType, targetType)) { return true; } SemType sourceSemType = SemType.tryInto(sourceType); + Context cx = context(); return couldInherentTypeBeDifferent(sourceSemType) && isSubTypeWithInherentType(cx, sourceVal, SemType.tryInto(targetType)); }