@@ -13,7 +13,7 @@ type charContext struct {
13
13
inputsAreStatic bool
14
14
}
15
15
16
- type flowMapType [lastFlowType ][] typeCode
16
+ type flowMapType [lastFlowType ]typeCodes
17
17
18
18
type characterization struct {
19
19
name string
@@ -161,6 +161,9 @@ var (
161
161
)
162
162
163
163
var noAnonymousFuncs = predicate ("has an untyped functional argument" , func (a testArgs ) bool {
164
+ if _ , ok := a .fm .fn .(ReflectiveWrapper ); ok {
165
+ return false
166
+ }
164
167
return ! hasAnonymousFuncs (typesIn (a .t ), false ) &&
165
168
! hasAnonymousFuncs (typesOut (a .t ), false )
166
169
})
@@ -171,13 +174,30 @@ var noAnonymousExceptFirstInput = predicate("has extra untyped functional argume
171
174
})
172
175
173
176
var hasInner = predicate ("does not have an Inner function (untyped functional argument in the 1st position)" , func (a testArgs ) bool {
174
- t := a .t
175
- return t .Kind () == reflect .Func && t .NumIn () > 0 && t .In (0 ).Kind () == reflect .Func
177
+ return isWrapper (a .t , a .fm .fn )
176
178
})
177
179
180
+ func isWrapper (t reflectType , fn interface {}) bool {
181
+ if _ , ok := fn .(ReflectiveWrapper ); ok {
182
+ return true
183
+ }
184
+ return t .Kind () == reflect .Func && t .NumIn () > 0 && t .In (0 ).Kind () == reflect .Func
185
+ }
186
+
178
187
var isFuncPointer = predicate ("is not a pointer to a function" , func (a testArgs ) bool {
179
- t := a .t
180
- return t .Kind () == reflect .Ptr && t .Elem ().Kind () == reflect .Func
188
+ switch a .fm .fn .(type ) {
189
+ case ReflectiveInvoker :
190
+ return true
191
+ case Reflective , ReflectiveArgs :
192
+ return false
193
+ default :
194
+ t := a .t
195
+ return t .Kind () == reflect .Ptr && t .Elem ().Kind () == reflect .Func
196
+ }
197
+ })
198
+
199
+ var isNotFuncPointer = predicate ("is a pointer to a function" , func (a testArgs ) bool {
200
+ return ! isFuncPointer .test (a )
181
201
})
182
202
183
203
var invokeRegistry = typeRegistry {
@@ -191,8 +211,13 @@ var invokeRegistry = typeRegistry{
191
211
mutate : func (a testArgs ) {
192
212
a .fm .group = invokeGroup
193
213
a .fm .class = initFunc
194
- a .fm .flows [outputParams ] = toTypeCodes (typesIn (a .t .Elem ()))
195
- a .fm .flows [bypassParams ] = toTypeCodes (typesOut (a .t .Elem ()))
214
+ if _ , ok := a .fm .fn .(ReflectiveInvoker ); ok {
215
+ a .fm .flows [outputParams ] = toTypeCodes (typesIn (a .t ))
216
+ a .fm .flows [bypassParams ] = toTypeCodes (typesOut (a .t ))
217
+ } else {
218
+ a .fm .flows [outputParams ] = toTypeCodes (typesIn (a .t .Elem ()))
219
+ a .fm .flows [bypassParams ] = toTypeCodes (typesOut (a .t .Elem ()))
220
+ }
196
221
a .fm .required = true
197
222
a .fm .isSynthetic = true
198
223
},
@@ -207,8 +232,13 @@ var invokeRegistry = typeRegistry{
207
232
mutate : func (a testArgs ) {
208
233
a .fm .group = invokeGroup
209
234
a .fm .class = invokeFunc
210
- a .fm .flows [outputParams ] = toTypeCodes (typesIn (a .t .Elem ()))
211
- a .fm .flows [receviedParams ] = toTypeCodes (typesOut (a .t .Elem ()))
235
+ if _ , ok := a .fm .fn .(ReflectiveInvoker ); ok {
236
+ a .fm .flows [outputParams ] = toTypeCodes (typesIn (a .t ))
237
+ a .fm .flows [receviedParams ] = toTypeCodes (typesOut (a .t ))
238
+ } else {
239
+ a .fm .flows [outputParams ] = toTypeCodes (typesIn (a .t .Elem ()))
240
+ a .fm .flows [receviedParams ] = toTypeCodes (typesOut (a .t .Elem ()))
241
+ }
212
242
a .fm .required = true
213
243
a .fm .isSynthetic = true
214
244
},
@@ -246,6 +276,7 @@ var handlerRegistry = typeRegistry{
246
276
notMarkedNoCache ,
247
277
mustNotMemoize ,
248
278
notMarkedReorder ,
279
+ isNotFuncPointer ,
249
280
},
250
281
mutate : func (a testArgs ) {
251
282
a .fm .group = staticGroup
@@ -268,6 +299,7 @@ var handlerRegistry = typeRegistry{
268
299
notMarkedNoCache ,
269
300
mustNotMemoize ,
270
301
notMarkedReorder ,
302
+ isNotFuncPointer ,
271
303
},
272
304
mutate : func (a testArgs ) {
273
305
a .fm .group = staticGroup
@@ -292,6 +324,7 @@ var handlerRegistry = typeRegistry{
292
324
possibleMapKey ,
293
325
notMarkedSingleton ,
294
326
notMarkedReorder ,
327
+ isNotFuncPointer ,
295
328
},
296
329
mutate : func (a testArgs ) {
297
330
a .fm .group = staticGroup
@@ -318,6 +351,7 @@ var handlerRegistry = typeRegistry{
318
351
possibleMapKey ,
319
352
notMarkedSingleton ,
320
353
notMarkedReorder ,
354
+ isNotFuncPointer ,
321
355
},
322
356
mutate : func (a testArgs ) {
323
357
a .fm .group = staticGroup
@@ -342,6 +376,7 @@ var handlerRegistry = typeRegistry{
342
376
notMarkedNoCache ,
343
377
notMarkedSingleton ,
344
378
notMarkedReorder ,
379
+ isNotFuncPointer ,
345
380
},
346
381
mutate : func (a testArgs ) {
347
382
a .fm .group = staticGroup
@@ -362,6 +397,7 @@ var handlerRegistry = typeRegistry{
362
397
markedMemoized ,
363
398
unstaticOkay ,
364
399
notMarkedSingleton ,
400
+ isNotFuncPointer ,
365
401
},
366
402
mutate : func (a testArgs ) {
367
403
a .fm .group = runGroup
@@ -383,6 +419,7 @@ var handlerRegistry = typeRegistry{
383
419
mustNotMemoize ,
384
420
unstaticOkay ,
385
421
notMarkedSingleton ,
422
+ isNotFuncPointer ,
386
423
},
387
424
mutate : func (a testArgs ) {
388
425
a .fm .group = runGroup
@@ -405,6 +442,7 @@ var handlerRegistry = typeRegistry{
405
442
mustNotMemoize ,
406
443
notMarkedNoCache ,
407
444
notMarkedSingleton ,
445
+ isNotFuncPointer ,
408
446
},
409
447
mutate : func (a testArgs ) {
410
448
a .fm .group = staticGroup
@@ -423,6 +461,7 @@ var handlerRegistry = typeRegistry{
423
461
markedMemoized ,
424
462
unstaticOkay ,
425
463
notMarkedSingleton ,
464
+ isNotFuncPointer ,
426
465
},
427
466
mutate : func (a testArgs ) {
428
467
a .fm .group = runGroup
@@ -442,6 +481,7 @@ var handlerRegistry = typeRegistry{
442
481
mustNotMemoize ,
443
482
unstaticOkay ,
444
483
notMarkedSingleton ,
484
+ isNotFuncPointer ,
445
485
},
446
486
mutate : func (a testArgs ) {
447
487
a .fm .group = runGroup
@@ -461,16 +501,23 @@ var handlerRegistry = typeRegistry{
461
501
mustNotMemoize ,
462
502
unstaticOkay ,
463
503
notMarkedSingleton ,
504
+ isNotFuncPointer ,
464
505
},
465
506
mutate : func (a testArgs ) {
466
507
in := typesIn (a .t )
467
508
in [0 ] = reflect .TypeOf (noTypeExampleValue )
468
509
a .fm .group = runGroup
469
510
a .fm .class = wrapperFunc
470
511
a .fm .flows [inputParams ] = toTypeCodes (in )
471
- a .fm .flows [outputParams ] = toTypeCodes (typesIn (a .t .In (0 )))
472
512
a .fm .flows [returnParams ] = toTypeCodes (typesOut (a .t ))
473
- a .fm .flows [receviedParams ] = toTypeCodes (typesOut (a .t .In (0 )))
513
+ var inner reflectType
514
+ if w , ok := a .fm .fn .(ReflectiveWrapper ); ok {
515
+ inner = wrappedReflective {w .Inner ()}
516
+ } else {
517
+ inner = a .t .In (0 )
518
+ }
519
+ a .fm .flows [outputParams ] = toTypeCodes (typesIn (inner ))
520
+ a .fm .flows [receviedParams ] = toTypeCodes (typesOut (inner ))
474
521
},
475
522
},
476
523
@@ -483,6 +530,7 @@ var handlerRegistry = typeRegistry{
483
530
mustNotMemoize ,
484
531
unstaticOkay ,
485
532
notMarkedSingleton ,
533
+ isNotFuncPointer ,
486
534
},
487
535
mutate : func (a testArgs ) {
488
536
a .fm .group = finalGroup
@@ -498,10 +546,10 @@ var handlerRegistry = typeRegistry{
498
546
func (reg typeRegistry ) characterizeFuncDetails (fm * provider , cc charContext ) (* provider , error ) {
499
547
var rejectReasons []string
500
548
var a testArgs
501
- if r , ok := fm .fn .(Reflective ); ok {
549
+ if r , ok := fm .fn .(ReflectiveArgs ); ok {
502
550
a = testArgs {
503
551
fm : fm .copy (),
504
- t : reflectiveWrapper {r },
552
+ t : wrappedReflective {r },
505
553
isNil : false ,
506
554
cc : cc ,
507
555
}
@@ -533,7 +581,7 @@ Match:
533
581
}
534
582
a .fm .upRmap = make (map [typeCode ]typeCode )
535
583
a .fm .downRmap = make (map [typeCode ]typeCode )
536
- a .fm .flows = [lastFlowType ][] typeCode {}
584
+ a .fm .flows = [lastFlowType ]typeCodes {}
537
585
match .mutate (a )
538
586
return a .fm , nil
539
587
}
0 commit comments