Skip to content

Commit

Permalink
Improve perf of type checker for equal types
Browse files Browse the repository at this point in the history
  • Loading branch information
warunalakshitha committed Dec 11, 2024
1 parent f0875b7 commit 7e5f313
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 7e5f313

Please sign in to comment.