2323import dev .cel .common .exceptions .CelOverloadNotFoundException ;
2424
2525@ Immutable
26- final class FunctionBindingImpl implements CelFunctionBinding {
26+ final class FunctionBindingImpl implements InternalCelFunctionBinding {
27+
28+ private final String functionName ;
2729
2830 private final String overloadId ;
2931
@@ -33,6 +35,11 @@ final class FunctionBindingImpl implements CelFunctionBinding {
3335
3436 private final boolean isStrict ;
3537
38+ @ Override
39+ public String getFunctionName () {
40+ return functionName ;
41+ }
42+
3643 @ Override
3744 public String getOverloadId () {
3845 return overloadId ;
@@ -54,20 +61,34 @@ public boolean isStrict() {
5461 }
5562
5663 FunctionBindingImpl (
64+ String functionName ,
5765 String overloadId ,
5866 ImmutableList <Class <?>> argTypes ,
5967 CelFunctionOverload definition ,
6068 boolean isStrict ) {
69+ this .functionName = functionName ;
6170 this .overloadId = overloadId ;
6271 this .argTypes = argTypes ;
6372 this .definition = definition ;
6473 this .isStrict = isStrict ;
6574 }
6675
76+ FunctionBindingImpl (
77+ String overloadId ,
78+ ImmutableList <Class <?>> argTypes ,
79+ CelFunctionOverload definition ,
80+ boolean isStrict ) {
81+ this (overloadId , overloadId , argTypes , definition , isStrict );
82+ }
83+
6784 static ImmutableSet <CelFunctionBinding > groupOverloadsToFunction (
6885 String functionName , ImmutableSet <CelFunctionBinding > overloadBindings ) {
6986 ImmutableSet .Builder <CelFunctionBinding > builder = ImmutableSet .builder ();
70- builder .addAll (overloadBindings );
87+ for (CelFunctionBinding b : overloadBindings ) {
88+ builder .add (
89+ new FunctionBindingImpl (
90+ functionName , b .getOverloadId (), b .getArgTypes (), b .getDefinition (), b .isStrict ()));
91+ }
7192
7293 // If there is already a binding with the same name as the function, we treat it as a
7394 // "Singleton" binding and do not create a dynamic dispatch wrapper for it.
@@ -80,11 +101,12 @@ static ImmutableSet<CelFunctionBinding> groupOverloadsToFunction(
80101 CelFunctionBinding singleBinding = Iterables .getOnlyElement (overloadBindings );
81102 builder .add (
82103 new FunctionBindingImpl (
104+ functionName ,
83105 functionName ,
84106 singleBinding .getArgTypes (),
85107 singleBinding .getDefinition (),
86108 singleBinding .isStrict ()));
87- } else {
109+ } else if ( overloadBindings . size () > 1 ) {
88110 builder .add (new DynamicDispatchBinding (functionName , overloadBindings ));
89111 }
90112 }
@@ -93,7 +115,7 @@ static ImmutableSet<CelFunctionBinding> groupOverloadsToFunction(
93115 }
94116
95117 @ Immutable
96- static final class DynamicDispatchBinding implements CelFunctionBinding {
118+ static final class DynamicDispatchBinding implements InternalCelFunctionBinding {
97119
98120 private final boolean isStrict ;
99121 private final DynamicDispatchOverload dynamicDispatchOverload ;
@@ -103,6 +125,11 @@ public String getOverloadId() {
103125 return dynamicDispatchOverload .functionName ;
104126 }
105127
128+ @ Override
129+ public String getFunctionName () {
130+ return dynamicDispatchOverload .functionName ;
131+ }
132+
106133 @ Override
107134 public ImmutableList <Class <?>> getArgTypes () {
108135 return ImmutableList .of ();
0 commit comments