Skip to content

Commit a30184b

Browse files
l46kokcopybara-github
authored andcommitted
Remove adaptRuntimeTypeValueToNativeType option
PiperOrigin-RevId: 704459291
1 parent d9143ef commit a30184b

File tree

13 files changed

+13
-48
lines changed

13 files changed

+13
-48
lines changed

common/src/main/java/dev/cel/common/CelOptions.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ public enum ProtoUnsetFieldOptions {
109109

110110
public abstract ProtoUnsetFieldOptions fromProtoUnsetFieldOption();
111111

112-
public abstract boolean adaptRuntimeTypeValueToNativeType();
113-
114112
public abstract boolean enableStringConversion();
115113

116114
public abstract boolean enableStringConcatenation();
@@ -210,7 +208,6 @@ public static Builder newBuilder() {
210208
.enableCelValue(false)
211209
.comprehensionMaxIterations(-1)
212210
.unwrapWellKnownTypesOnFunctionDispatch(true)
213-
.adaptRuntimeTypeValueToNativeType(true)
214211
.fromProtoUnsetFieldOption(ProtoUnsetFieldOptions.BIND_DEFAULT)
215212
.enableStringConversion(true)
216213
.enableStringConcatenation(true)
@@ -523,14 +520,6 @@ public abstract static class Builder {
523520
*/
524521
public abstract Builder fromProtoUnsetFieldOption(ProtoUnsetFieldOptions value);
525522

526-
/**
527-
* If enabled, result of the type function call `type(foo)` will be evaluated as a native-type
528-
* equivalent {@code CelType} instead of the protobuf type equivalent from {value.proto}.
529-
*
530-
* <p>This is a temporary flag for migration purposes, and will be removed in the near future.
531-
*/
532-
public abstract Builder adaptRuntimeTypeValueToNativeType(boolean value);
533-
534523
/**
535524
* Enables string() overloads for the runtime. This option exists to maintain parity with
536525
* cel-cpp interpreter options.

common/src/test/java/dev/cel/common/values/ProtoMessageValueProviderTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ public void newValue_createProtoMessage_fieldsPopulated() {
122122
@Test
123123
public void newValue_createProtoMessage_unsignedLongFieldsPopulated() {
124124
ProtoMessageValueProvider protoMessageValueProvider =
125-
ProtoMessageValueProvider.newInstance(
126-
DYNAMIC_PROTO, CelOptions.current().enableUnsignedLongs(true).build());
125+
ProtoMessageValueProvider.newInstance(DYNAMIC_PROTO, CelOptions.current().build());
127126

128127
ProtoMessageValue protoMessageValue =
129128
(ProtoMessageValue)

common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public final class ProtoMessageValueTest {
5555

5656
private static final ProtoCelValueConverter PROTO_CEL_VALUE_CONVERTER =
5757
ProtoCelValueConverter.newInstance(
58-
CelOptions.current().enableUnsignedLongs(true).build(),
58+
CelOptions.current().build(),
5959
DefaultDescriptorPool.INSTANCE,
6060
DynamicProto.create(DefaultMessageFactory.INSTANCE));
6161

conformance/src/test/java/dev/cel/conformance/ConformanceTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ private static TypeRegistry newDefaultTypeRegistry() {
9090
private static final CelOptions OPTIONS =
9191
CelOptions.current()
9292
.enableTimestampEpoch(true)
93-
.enableUnsignedLongs(true)
94-
.adaptRuntimeTypeValueToNativeType(true)
9593
.enableHeterogeneousNumericComparisons(true)
9694
.enableProtoDifferencerEquality(true)
9795
.enableOptionalSyntax(true)

extensions/src/test/java/dev/cel/extensions/CelMathExtensionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ public void least_unsignedLongResult_withSignedLongType_success(String expr, lon
538538
+ " '3'}")
539539
public void least_unsignedLongResult_withUnsignedLongType_success(
540540
String expr, String expectedResult) throws Exception {
541-
CelOptions celOptions = CelOptions.current().enableUnsignedLongs(true).build();
541+
CelOptions celOptions = CelOptions.current().build();
542542
CelCompiler celCompiler =
543543
CelCompilerFactory.standardCelCompilerBuilder()
544544
.setOptions(celOptions)

extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,7 @@ private enum ConstantTestCases {
9191

9292
private static CelBuilder newCelBuilder() {
9393
return CelFactory.standardCelBuilder()
94-
.setOptions(
95-
CelOptions.current()
96-
.enableUnsignedLongs(true)
97-
.enableTimestampEpoch(true)
98-
.adaptRuntimeTypeValueToNativeType(true)
99-
.build())
94+
.setOptions(CelOptions.current().enableTimestampEpoch(true).build())
10095
.setStandardMacros(CelStandardMacro.STANDARD_MACROS)
10196
.setContainer("cel.expr.conformance.proto3")
10297
.addMessageTypes(TestAllTypes.getDescriptor())

extensions/src/test/java/dev/cel/extensions/CelSetsExtensionsTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343

4444
@RunWith(TestParameterInjector.class)
4545
public final class CelSetsExtensionsTest {
46-
private static final CelOptions CEL_OPTIONS =
47-
CelOptions.current().enableUnsignedLongs(true).build();
46+
private static final CelOptions CEL_OPTIONS = CelOptions.current().build();
4847
private static final CelCompiler COMPILER =
4948
CelCompilerFactory.standardCelCompilerBuilder()
5049
.addMessageTypes(TestAllTypes.getDescriptor())

runtime/src/main/java/dev/cel/runtime/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ java_library(
108108
"//common/internal:default_message_factory",
109109
"//common/internal:dynamic_proto",
110110
"//common/internal:proto_message_factory",
111+
"//common/types",
111112
"//common/types:cel_types",
112113
"//common/types:type_providers",
113114
"@cel_spec//proto/cel/expr:expr_java_proto",

runtime/src/main/java/dev/cel/runtime/DefaultInterpreter.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import static com.google.common.base.Preconditions.checkNotNull;
1818

19-
import dev.cel.expr.Value;
2019
import com.google.auto.value.AutoValue;
2120
import com.google.common.base.Joiner;
2221
import com.google.common.base.Preconditions;
@@ -40,6 +39,7 @@
4039
import dev.cel.common.ast.CelReference;
4140
import dev.cel.common.types.CelKind;
4241
import dev.cel.common.types.CelType;
42+
import dev.cel.common.types.TypeType;
4343
import java.util.ArrayDeque;
4444
import java.util.ArrayList;
4545
import java.util.Arrays;
@@ -260,10 +260,7 @@ private IntermediateResult resolveIdent(ExecutionFrame frame, CelExpr expr, Stri
260260
// Check whether the type exists in the type check map as a 'type'.
261261
Optional<CelType> checkedType = ast.getType(expr.id());
262262
if (checkedType.isPresent() && checkedType.get().kind() == CelKind.TYPE) {
263-
Object typeValue =
264-
celOptions.adaptRuntimeTypeValueToNativeType()
265-
? CelTypeResolver.adaptType(checkedType.get())
266-
: typeProvider.adaptType(checkedType.get());
263+
TypeType typeValue = CelTypeResolver.adaptType(checkedType.get());
267264
return IntermediateResult.create(typeValue);
268265
}
269266

@@ -643,15 +640,9 @@ private IntermediateResult evalType(ExecutionFrame frame, CelCall callExpr)
643640
.setLocation(metadata, typeExprArg.id())
644641
.build());
645642

646-
Object typeValue;
647-
if (celOptions.adaptRuntimeTypeValueToNativeType()) {
648-
CelType checkedTypeValue = CelTypeResolver.adaptType(checkedType);
649-
typeValue = CelTypeResolver.resolveObjectType(argResult.value(), checkedTypeValue);
650-
} else {
651-
Value checkedTypeValue = typeProvider.adaptType(checkedType);
652-
typeValue = typeProvider.resolveObjectType(argResult.value(), checkedTypeValue);
653-
}
654-
return IntermediateResult.create(typeValue);
643+
CelType checkedTypeValue = CelTypeResolver.adaptType(checkedType);
644+
return IntermediateResult.create(
645+
CelTypeResolver.resolveObjectType(argResult.value(), checkedTypeValue));
655646
}
656647

657648
private IntermediateResult evalOptionalOr(ExecutionFrame frame, CelCall callExpr)

runtime/src/test/java/dev/cel/runtime/CelTypeResolverTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ public class CelTypeResolverTest {
4343

4444
private static final Cel CEL =
4545
CelFactory.standardCelBuilder()
46-
.setOptions(
47-
CelOptions.current()
48-
.enableTimestampEpoch(true)
49-
.adaptRuntimeTypeValueToNativeType(true)
50-
.build())
46+
.setOptions(CelOptions.current().enableTimestampEpoch(true).build())
5147
.setTypeProvider(PROTO_MESSAGE_TYPE_PROVIDER)
5248
.addCompilerLibraries(CelOptionalLibrary.INSTANCE)
5349
.addRuntimeLibraries(CelOptionalLibrary.INSTANCE)

0 commit comments

Comments
 (0)