@@ -74,6 +74,8 @@ class InterceptorStubGenerator {
74
74
condition = js ('(typeof receiver) == "string"' );
75
75
} else if (cls == _commonElements.jsNullClass) {
76
76
condition = js ('receiver == null' );
77
+ } else if (cls == _commonElements.jsJavaScriptFunctionClass) {
78
+ condition = js ('(typeof receiver) == "function"' );
77
79
} else {
78
80
throw 'internal error' ;
79
81
}
@@ -89,6 +91,7 @@ class InterceptorStubGenerator {
89
91
bool hasString = false ;
90
92
bool hasNative = false ;
91
93
bool anyNativeClasses = _nativeCodegenEnqueuer.hasInstantiatedNativeClasses;
94
+ bool hasJavaScriptFunction = false ;
92
95
93
96
for (ClassEntity cls in classes) {
94
97
if (cls == _commonElements.jsArrayClass ||
@@ -108,6 +111,8 @@ class InterceptorStubGenerator {
108
111
hasNumber = true ;
109
112
else if (cls == _commonElements.jsStringClass)
110
113
hasString = true ;
114
+ else if (cls == _commonElements.jsJavaScriptFunctionClass)
115
+ hasJavaScriptFunction = true ;
111
116
else {
112
117
// The set of classes includes classes mixed-in to interceptor classes
113
118
// and user extensions of native classes.
@@ -180,6 +185,14 @@ class InterceptorStubGenerator {
180
185
statements.add (buildInterceptorCheck (_commonElements.jsArrayClass));
181
186
}
182
187
188
+ // If a program `hasNative` then we will insert a check for
189
+ // `JavaScriptFunction` in the `hasNative` block of the interceptor logic.
190
+ // Otherwise, we have to insert a specific check for `JavScriptFunction.
191
+ if (hasJavaScriptFunction && ! hasNative) {
192
+ statements.add (
193
+ buildInterceptorCheck (_commonElements.jsJavaScriptFunctionClass));
194
+ }
195
+
183
196
if (hasNative) {
184
197
statements.add (js.statement (r'''{
185
198
if (typeof receiver != "object") {
0 commit comments