Skip to content

Commit

Permalink
Fix checkstyle violations
Browse files Browse the repository at this point in the history
  • Loading branch information
heshanpadmasiri committed Jul 31, 2024
1 parent fce9516 commit e1b7e16
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import io.ballerina.runtime.internal.types.semtype.MappingDefinition;
import io.ballerina.runtime.internal.values.AbstractObjectValue;
import io.ballerina.runtime.internal.values.DecimalValue;
import io.ballerina.runtime.internal.values.ErrorValue;
import io.ballerina.runtime.internal.values.FPValue;

import java.math.BigDecimal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,14 @@ private static TypeCheckResult isSubType(Context cx, Object sourceValue, Type so
if (result != TypeCheckResult.FALSE) {
return result;
}
result = isSubTypeWithShape(cx, sourceValue, Builder.from(cx, target));
return isSubTypeWithShape(cx, sourceValue, Builder.from(cx, source), Builder.from(cx, target));
}

private static TypeCheckResult isSubTypeWithShape(Context cx, Object sourceValue, SemType source, SemType target) {
TypeCheckResult result;
result = isSubTypeWithShapeInner(cx, sourceValue, target);
if (result == TypeCheckResult.MAYBE) {
SemType sourceSemType = Builder.from(cx, source);
if (Core.containsBasicType(sourceSemType, B_TYPE_TOP)) {
if (Core.containsBasicType(source, B_TYPE_TOP)) {
return TypeCheckResult.MAYBE;
}
return TypeCheckResult.FALSE;
Expand All @@ -591,18 +595,10 @@ private static TypeCheckResult isSubTypeInner(Context cx, Object sourceValue, Se
if (result != TypeCheckResult.FALSE) {
return result;
}
// FIXME: don't do this if the source and targets common set don't have shapes
result = isSubTypeWithShape(cx, sourceValue, target);
if (result == TypeCheckResult.MAYBE) {
if (Core.containsBasicType(source, B_TYPE_TOP)) {
return TypeCheckResult.MAYBE;
}
return TypeCheckResult.FALSE;
}
return result;
return isSubTypeWithShape(cx, sourceValue, source, target);
}

private static TypeCheckResult isSubTypeWithShape(Context cx, Object sourceValue, SemType target) {
private static TypeCheckResult isSubTypeWithShapeInner(Context cx, Object sourceValue, SemType target) {
Optional<SemType> sourceSingletonType = Builder.shapeOf(cx, sourceValue);
if (sourceSingletonType.isEmpty()) {
return fallbackToBTypeWithoutShape(sourceValue, target) ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

package io.ballerina.runtime.internal.types.semtype;

import io.ballerina.runtime.api.types.semtype.BasicTypeCode;
import io.ballerina.runtime.api.types.semtype.Bdd;
import io.ballerina.runtime.api.types.semtype.Builder;
import io.ballerina.runtime.api.types.semtype.Core;
import io.ballerina.runtime.api.types.semtype.SemType;
import io.ballerina.runtime.api.types.semtype.SubType;

import static io.ballerina.runtime.api.types.semtype.BasicTypeCode.*;
import static io.ballerina.runtime.api.types.semtype.BasicTypeCode.BT_ERROR;
import static io.ballerina.runtime.api.types.semtype.BasicTypeCode.BT_MAPPING;
import static io.ballerina.runtime.api.types.semtype.BddNode.bddAtom;
import static io.ballerina.runtime.api.types.semtype.Builder.basicSubType;
import static io.ballerina.runtime.api.types.semtype.RecAtom.createDistinctRecAtom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import java.util.Set;
import java.util.StringJoiner;

import static io.ballerina.runtime.api.PredefinedTypes.TYPE_MAP;
import static io.ballerina.runtime.api.constants.RuntimeConstants.BLANG_SRC_FILE_SUFFIX;
import static io.ballerina.runtime.api.constants.RuntimeConstants.DOT;
import static io.ballerina.runtime.api.constants.RuntimeConstants.MODULE_INIT_CLASS_NAME;
Expand Down

0 comments on commit e1b7e16

Please sign in to comment.