diff --git a/common/src/main/java/dev/cel/common/CelOptions.java b/common/src/main/java/dev/cel/common/CelOptions.java index dd0ccf87..5c49936d 100644 --- a/common/src/main/java/dev/cel/common/CelOptions.java +++ b/common/src/main/java/dev/cel/common/CelOptions.java @@ -109,8 +109,6 @@ public enum ProtoUnsetFieldOptions { public abstract ProtoUnsetFieldOptions fromProtoUnsetFieldOption(); - public abstract boolean adaptRuntimeTypeValueToNativeType(); - public abstract boolean enableStringConversion(); public abstract boolean enableStringConcatenation(); @@ -210,7 +208,6 @@ public static Builder newBuilder() { .enableCelValue(false) .comprehensionMaxIterations(-1) .unwrapWellKnownTypesOnFunctionDispatch(true) - .adaptRuntimeTypeValueToNativeType(true) .fromProtoUnsetFieldOption(ProtoUnsetFieldOptions.BIND_DEFAULT) .enableStringConversion(true) .enableStringConcatenation(true) @@ -523,14 +520,6 @@ public abstract static class Builder { */ public abstract Builder fromProtoUnsetFieldOption(ProtoUnsetFieldOptions value); - /** - * If enabled, result of the type function call `type(foo)` will be evaluated as a native-type - * equivalent {@code CelType} instead of the protobuf type equivalent from {value.proto}. - * - *

This is a temporary flag for migration purposes, and will be removed in the near future. - */ - public abstract Builder adaptRuntimeTypeValueToNativeType(boolean value); - /** * Enables string() overloads for the runtime. This option exists to maintain parity with * cel-cpp interpreter options. diff --git a/common/src/test/java/dev/cel/common/values/ProtoMessageValueProviderTest.java b/common/src/test/java/dev/cel/common/values/ProtoMessageValueProviderTest.java index 4130b2db..2ce41605 100644 --- a/common/src/test/java/dev/cel/common/values/ProtoMessageValueProviderTest.java +++ b/common/src/test/java/dev/cel/common/values/ProtoMessageValueProviderTest.java @@ -122,8 +122,7 @@ public void newValue_createProtoMessage_fieldsPopulated() { @Test public void newValue_createProtoMessage_unsignedLongFieldsPopulated() { ProtoMessageValueProvider protoMessageValueProvider = - ProtoMessageValueProvider.newInstance( - DYNAMIC_PROTO, CelOptions.current().enableUnsignedLongs(true).build()); + ProtoMessageValueProvider.newInstance(DYNAMIC_PROTO, CelOptions.current().build()); ProtoMessageValue protoMessageValue = (ProtoMessageValue) diff --git a/common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java b/common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java index cf9cc8ab..ab3c52d1 100644 --- a/common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java +++ b/common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java @@ -55,7 +55,7 @@ public final class ProtoMessageValueTest { private static final ProtoCelValueConverter PROTO_CEL_VALUE_CONVERTER = ProtoCelValueConverter.newInstance( - CelOptions.current().enableUnsignedLongs(true).build(), + CelOptions.current().build(), DefaultDescriptorPool.INSTANCE, DynamicProto.create(DefaultMessageFactory.INSTANCE)); diff --git a/conformance/src/test/java/dev/cel/conformance/ConformanceTest.java b/conformance/src/test/java/dev/cel/conformance/ConformanceTest.java index 47c8beea..b27fd1bc 100644 --- a/conformance/src/test/java/dev/cel/conformance/ConformanceTest.java +++ b/conformance/src/test/java/dev/cel/conformance/ConformanceTest.java @@ -90,8 +90,6 @@ private static TypeRegistry newDefaultTypeRegistry() { private static final CelOptions OPTIONS = CelOptions.current() .enableTimestampEpoch(true) - .enableUnsignedLongs(true) - .adaptRuntimeTypeValueToNativeType(true) .enableHeterogeneousNumericComparisons(true) .enableProtoDifferencerEquality(true) .enableOptionalSyntax(true) diff --git a/extensions/src/test/java/dev/cel/extensions/CelMathExtensionsTest.java b/extensions/src/test/java/dev/cel/extensions/CelMathExtensionsTest.java index a0bf39e7..65b7542c 100644 --- a/extensions/src/test/java/dev/cel/extensions/CelMathExtensionsTest.java +++ b/extensions/src/test/java/dev/cel/extensions/CelMathExtensionsTest.java @@ -538,7 +538,7 @@ public void least_unsignedLongResult_withSignedLongType_success(String expr, lon + " '3'}") public void least_unsignedLongResult_withUnsignedLongType_success( String expr, String expectedResult) throws Exception { - CelOptions celOptions = CelOptions.current().enableUnsignedLongs(true).build(); + CelOptions celOptions = CelOptions.current().build(); CelCompiler celCompiler = CelCompilerFactory.standardCelCompilerBuilder() .setOptions(celOptions) diff --git a/extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java b/extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java index f35745e2..06f748a4 100644 --- a/extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java +++ b/extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java @@ -91,12 +91,7 @@ private enum ConstantTestCases { private static CelBuilder newCelBuilder() { return CelFactory.standardCelBuilder() - .setOptions( - CelOptions.current() - .enableUnsignedLongs(true) - .enableTimestampEpoch(true) - .adaptRuntimeTypeValueToNativeType(true) - .build()) + .setOptions(CelOptions.current().enableTimestampEpoch(true).build()) .setStandardMacros(CelStandardMacro.STANDARD_MACROS) .setContainer("cel.expr.conformance.proto3") .addMessageTypes(TestAllTypes.getDescriptor()) diff --git a/extensions/src/test/java/dev/cel/extensions/CelSetsExtensionsTest.java b/extensions/src/test/java/dev/cel/extensions/CelSetsExtensionsTest.java index 7d6f9721..808cc50f 100644 --- a/extensions/src/test/java/dev/cel/extensions/CelSetsExtensionsTest.java +++ b/extensions/src/test/java/dev/cel/extensions/CelSetsExtensionsTest.java @@ -43,8 +43,7 @@ @RunWith(TestParameterInjector.class) public final class CelSetsExtensionsTest { - private static final CelOptions CEL_OPTIONS = - CelOptions.current().enableUnsignedLongs(true).build(); + private static final CelOptions CEL_OPTIONS = CelOptions.current().build(); private static final CelCompiler COMPILER = CelCompilerFactory.standardCelCompilerBuilder() .addMessageTypes(TestAllTypes.getDescriptor()) diff --git a/runtime/src/main/java/dev/cel/runtime/BUILD.bazel b/runtime/src/main/java/dev/cel/runtime/BUILD.bazel index 7d7700c8..093d8d86 100644 --- a/runtime/src/main/java/dev/cel/runtime/BUILD.bazel +++ b/runtime/src/main/java/dev/cel/runtime/BUILD.bazel @@ -108,6 +108,7 @@ java_library( "//common/internal:default_message_factory", "//common/internal:dynamic_proto", "//common/internal:proto_message_factory", + "//common/types", "//common/types:cel_types", "//common/types:type_providers", "@cel_spec//proto/cel/expr:expr_java_proto", diff --git a/runtime/src/main/java/dev/cel/runtime/DefaultInterpreter.java b/runtime/src/main/java/dev/cel/runtime/DefaultInterpreter.java index 1d1b110e..0db9587b 100644 --- a/runtime/src/main/java/dev/cel/runtime/DefaultInterpreter.java +++ b/runtime/src/main/java/dev/cel/runtime/DefaultInterpreter.java @@ -16,7 +16,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -import dev.cel.expr.Value; import com.google.auto.value.AutoValue; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; @@ -40,6 +39,7 @@ import dev.cel.common.ast.CelReference; import dev.cel.common.types.CelKind; import dev.cel.common.types.CelType; +import dev.cel.common.types.TypeType; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; @@ -260,10 +260,7 @@ private IntermediateResult resolveIdent(ExecutionFrame frame, CelExpr expr, Stri // Check whether the type exists in the type check map as a 'type'. Optional checkedType = ast.getType(expr.id()); if (checkedType.isPresent() && checkedType.get().kind() == CelKind.TYPE) { - Object typeValue = - celOptions.adaptRuntimeTypeValueToNativeType() - ? CelTypeResolver.adaptType(checkedType.get()) - : typeProvider.adaptType(checkedType.get()); + TypeType typeValue = CelTypeResolver.adaptType(checkedType.get()); return IntermediateResult.create(typeValue); } @@ -643,15 +640,9 @@ private IntermediateResult evalType(ExecutionFrame frame, CelCall callExpr) .setLocation(metadata, typeExprArg.id()) .build()); - Object typeValue; - if (celOptions.adaptRuntimeTypeValueToNativeType()) { - CelType checkedTypeValue = CelTypeResolver.adaptType(checkedType); - typeValue = CelTypeResolver.resolveObjectType(argResult.value(), checkedTypeValue); - } else { - Value checkedTypeValue = typeProvider.adaptType(checkedType); - typeValue = typeProvider.resolveObjectType(argResult.value(), checkedTypeValue); - } - return IntermediateResult.create(typeValue); + CelType checkedTypeValue = CelTypeResolver.adaptType(checkedType); + return IntermediateResult.create( + CelTypeResolver.resolveObjectType(argResult.value(), checkedTypeValue)); } private IntermediateResult evalOptionalOr(ExecutionFrame frame, CelCall callExpr) diff --git a/runtime/src/test/java/dev/cel/runtime/CelTypeResolverTest.java b/runtime/src/test/java/dev/cel/runtime/CelTypeResolverTest.java index f19219c8..1d94ac86 100644 --- a/runtime/src/test/java/dev/cel/runtime/CelTypeResolverTest.java +++ b/runtime/src/test/java/dev/cel/runtime/CelTypeResolverTest.java @@ -43,11 +43,7 @@ public class CelTypeResolverTest { private static final Cel CEL = CelFactory.standardCelBuilder() - .setOptions( - CelOptions.current() - .enableTimestampEpoch(true) - .adaptRuntimeTypeValueToNativeType(true) - .build()) + .setOptions(CelOptions.current().enableTimestampEpoch(true).build()) .setTypeProvider(PROTO_MESSAGE_TYPE_PROVIDER) .addCompilerLibraries(CelOptionalLibrary.INSTANCE) .addRuntimeLibraries(CelOptionalLibrary.INSTANCE) diff --git a/runtime/src/test/java/dev/cel/runtime/RuntimeEqualityTest.java b/runtime/src/test/java/dev/cel/runtime/RuntimeEqualityTest.java index b7501521..0418c0c4 100644 --- a/runtime/src/test/java/dev/cel/runtime/RuntimeEqualityTest.java +++ b/runtime/src/test/java/dev/cel/runtime/RuntimeEqualityTest.java @@ -70,12 +70,11 @@ public final class RuntimeEqualityTest { .enableProtoDifferencerEquality(true) .build(); private static final CelOptions UNSIGNED_LONGS = - CelOptions.newBuilder().disableCelStandardEquality(false).enableUnsignedLongs(true).build(); + CelOptions.newBuilder().disableCelStandardEquality(false).build(); private static final CelOptions PROTO_EQUALITY_UNSIGNED_LONGS = CelOptions.newBuilder() .disableCelStandardEquality(false) .enableProtoDifferencerEquality(true) - .enableUnsignedLongs(true) .build(); private static final RuntimeEquality RUNTIME_EQUALITY = diff --git a/testing/src/main/java/dev/cel/testing/BaseInterpreterTest.java b/testing/src/main/java/dev/cel/testing/BaseInterpreterTest.java index ef8b2345..a14d359a 100644 --- a/testing/src/main/java/dev/cel/testing/BaseInterpreterTest.java +++ b/testing/src/main/java/dev/cel/testing/BaseInterpreterTest.java @@ -100,7 +100,6 @@ private static CelOptions.Builder newBaseOptions() { /** Test options to supply for interpreter tests. */ protected enum InterpreterTestOption { - ADAPT_TYPE_VALUE(newBaseOptions().adaptRuntimeTypeValueToNativeType(true).build(), true), CEL_TYPE(newBaseOptions().build(), true), PROTO_TYPE(newBaseOptions().build(), false), ; diff --git a/testing/src/main/java/dev/cel/testing/CelBaselineTestCase.java b/testing/src/main/java/dev/cel/testing/CelBaselineTestCase.java index 630cb26b..50382436 100644 --- a/testing/src/main/java/dev/cel/testing/CelBaselineTestCase.java +++ b/testing/src/main/java/dev/cel/testing/CelBaselineTestCase.java @@ -57,7 +57,6 @@ public abstract class CelBaselineTestCase extends BaselineTestCase { protected static final CelOptions TEST_OPTIONS = CelOptions.current() .enableTimestampEpoch(true) - .enableUnsignedLongs(true) .enableHeterogeneousNumericComparisons(true) .enableOptionalSyntax(true) .comprehensionMaxIterations(1_000)