The code below is working for me on 0.53dev, and it probably works on 0.52 too.
The key is to generate a valid FunctionType instance. One way to do it is to start with the output type float64 and call it with the input arguments, float64(float64, float64). That produces a Signature object. The signature can be converted into a function type using .as_type(). Alternatively, the function type can be built more explicitly as FunctionType(float64(float64, float64)).
Once you have the function type, the empty list must be created with a an explicit signature pointing to a FunctionType instance. This is the first-class function type that allows two functions with the same signature to be appended to the same list. By default, when using typed.List automatic type inference, the functions f1 and f2 will be recognized as a CPUDispatcher(<function name>) which is a kind of singleton type. That’s why f2 cannot be appended to a list that contains f1, only objects of type CPUDispatcher(<function f1 at ...>) are allowed in that list.
import numba
from numba.core import types
@numba.njit()
def f1(x, y):
return x + y
@numba.njit()
def f2(x, y):
return x + y
f1(1., 2.)
f2(1., 2.)
f_list = numba.typed.List.empty_list(types.float64(types.float64, types.float64).as_type())
f_list.append(f1)
f_list.append(f2)
@numba.experimental.jitclass([('funcs', types.ListType(types.float64(types.float64, types.float64).as_type()))])
class Handler:
def __init__(self, funcs):
self.funcs = funcs