File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -470,6 +470,20 @@ function hom end
470470#
471471_implements (:: Type{T} , f:: Any ) where {T} = hasmethod (f, Tuple{T})
472472
473+ # Alternatively, the first argument can be a concrete object. By default we
474+ # then redispatch to the type based version. But one may also choose to
475+ # implement custom methods for this: certain operations will only work for
476+ # *some* instances. E.g. for `Z/nZ` it may happen that for `n` a prime we can
477+ # perform a certain operation, but not if `n` is composite.
478+ #
479+ # In that case the recommendation is that `_implements` invoked on the type
480+ # returns `false`, but invoked on a concrete instance of a type, it may use
481+ # specifics of the instance to also return `true` if appropriate.
482+ function _implements (x:: T , f:: Any ) where {T}
483+ @assert ! (x isa Type) # paranoia
484+ return _implements (T, f)
485+ end
486+
473487# helper for `_implements` which checks if `f` has a method explicitly for
474488# a concrete type `T` (i.e. not a generic method that can be specialized to `T`
475489# but really one that is implement for `T` and `T` only).
You can’t perform that action at this time.
0 commit comments