File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
main/java/dev/cel/runtime
test/java/dev/cel/runtime Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -72,9 +72,10 @@ default boolean canHandle(Object[] arguments) {
7272 }
7373
7474 if (arg instanceof Exception || arg instanceof CelUnknownSet ) {
75+ // Only non-strict functions can accept errors/unknowns as arguments to a function
7576 if (!isStrict ()) {
76- // Only non-strict functions can accept errors/unknowns as arguments to a function
77- return true ;
77+ // Skip assignability check below, but continue to validate remaining args
78+ continue ;
7879 }
7980 }
8081
Original file line number Diff line number Diff line change @@ -65,4 +65,35 @@ public void canHandle_nonMatchingTypes_returnsFalse() {
6565 public void canHandle_nonMatchingArgCount_returnsFalse () {
6666 assertThat (getIncrementIntOverload ().canHandle (new Object [] {1L , 2L })).isFalse ();
6767 }
68+
69+ @ Test
70+ public void canHandle_nonStrictOverload_returnsTrue () {
71+ CelResolvedOverload nonStrictOverload =
72+ CelResolvedOverload .of (
73+ "non_strict" ,
74+ (args ) -> {
75+ return false ;
76+ },
77+ /* isStrict= */ false ,
78+ Long .class ,
79+ Long .class );
80+ assertThat (
81+ nonStrictOverload .canHandle (
82+ new Object [] {new RuntimeException (), CelUnknownSet .create ()}))
83+ .isTrue ();
84+ }
85+
86+ @ Test
87+ public void canHandle_nonStrictOverload_returnsFalse () {
88+ CelResolvedOverload nonStrictOverload =
89+ CelResolvedOverload .of (
90+ "non_strict" ,
91+ (args ) -> {
92+ return false ;
93+ },
94+ /* isStrict= */ false ,
95+ Long .class ,
96+ Long .class );
97+ assertThat (nonStrictOverload .canHandle (new Object [] {new RuntimeException (), "Foo" })).isFalse ();
98+ }
6899}
You can’t perform that action at this time.
0 commit comments