Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ public enum StandardIdentifier {
DURATION(newStandardIdentDecl(SimpleType.DURATION)),
TIMESTAMP(newStandardIdentDecl(SimpleType.TIMESTAMP)),
DYN(newStandardIdentDecl(SimpleType.DYN)),
TYPE(newStandardIdentDecl("type", SimpleType.DYN)),
TYPE(newStandardIdentDecl("type", TypeType.create(SimpleType.DYN))),
NULL_TYPE(newStandardIdentDecl("null_type", SimpleType.NULL_TYPE)),
LIST(newStandardIdentDecl("list", ListType.create(SimpleType.DYN))),
MAP(newStandardIdentDecl("map", MapType.create(SimpleType.DYN, SimpleType.DYN))),
Expand Down
2 changes: 1 addition & 1 deletion checker/src/test/resources/standardEnvDump.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ declare timestamp {
function int64_to_timestamp (int) -> google.protobuf.Timestamp
}
declare type {
value type(dyn)
value type(type(dyn))
}
declare type {
function type (A) -> type(A)
Expand Down
2 changes: 2 additions & 0 deletions runtime/src/main/java/dev/cel/runtime/TypeResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ TypeType adaptType(CelType typeCheckedType) {
switch (typeOfType.kind()) {
case STRUCT:
return TypeType.create(adaptStructType((StructType) typeOfType));
case TYPE:
return RUNTIME_TYPE_TYPE;
default:
return (TypeType) typeCheckedType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ private Optional<TypeType> resolveTypeLiteral(String identName, @Nullable CelTyp
*/
private static boolean isCheckedAs(CelType literalType, CelType checkedTypeParam) {
if (literalType instanceof TypeType) {
// TODO: cel-java checks the `type` literal as type(dyn), while cel-go and
// cel-cpp check it as type(type).
return checkedTypeParam instanceof TypeType || checkedTypeParam.equals(SimpleType.DYN);
return checkedTypeParam instanceof TypeType;
}
// Serialized checked expressions erase enum types to int.
return checkedTypeParam.name().equals(literalType.name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,6 @@ private enum TypeLiteralTestCase {
DURATION("google.protobuf.Duration", SimpleType.DURATION),
TIMESTAMP("google.protobuf.Timestamp", SimpleType.TIMESTAMP),
OPTIONAL("optional_type", OptionalType.create(SimpleType.DYN)),
// TODO: Align the `type` literal's runtime value with type(type).
TYPE("type", SimpleType.DYN),
PROTO_MESSAGE_TYPE(
"cel.expr.conformance.proto3.TestAllTypes",
Expand Down
Loading