@@ -14,7 +14,7 @@ tls_world_age() = ccall(:jl_get_tls_world_age, UInt, ())
14
14
export methodinstance
15
15
16
16
@inline function signature_type_by_tt (ft:: Type , tt:: Type )
17
- u = Base. unwrap_unionall (tt)
17
+ u = Base. unwrap_unionall (tt):: DataType
18
18
return Base. rewrap_unionall (Tuple{ft, u. parameters... }, tt)
19
19
end
20
20
@@ -62,15 +62,21 @@ methodinstance
62
62
if VERSION >= v " 1.11.0-DEV.1552"
63
63
64
64
# XXX : version of Base.method_instance that uses a function type
65
- function methodinstance (ft, tt , world= tls_world_age ())
65
+ @inline function methodinstance (@nospecialize (ft :: Type ), @nospecialize (tt :: Type ) , world:: Integer = tls_world_age ())
66
66
sig = signature_type_by_tt (ft, tt)
67
67
68
68
mi = ccall (:jl_method_lookup_by_tt , Any,
69
69
(Any, Csize_t, Any),
70
70
sig, world, #= method_table=# nothing )
71
71
mi === nothing && throw (MethodError (ft, tt, world))
72
+ mi = mi:: MethodInstance
72
73
73
- return mi:: MethodInstance
74
+ # `jl_method_lookup_by_tt` and `jl_method_lookup` can return a unspecialized mi
75
+ if ! Base. isdispatchtuple (mi. specTypes)
76
+ mi = CC. specialize_method (mi. def, sig, mi. sparam_vals):: MethodInstance
77
+ end
78
+
79
+ return mi
74
80
end
75
81
76
82
# on older versions of Julia, the run-time lookup is much slower, so we'll need to cache it
0 commit comments