@@ -18,6 +18,33 @@ function implements end
18
18
implements (T:: Type{<:Interface} , obj) = implements (T, typeof (obj))
19
19
implements (:: Type{<:Interface} , obj:: Type ) = false
20
20
21
+ function test_objects (:: Type{T} ) where T<: Interface
22
+ methodlist = methods (Interfaces. test_objects, Tuple{Type{T},Any})
23
+ objects = Dict {Type,Any} ()
24
+ # Check that all found methods are either unrequired, or pass their tests
25
+ for m in (methodlist)
26
+ (m. module == Interfaces) && continue
27
+ # We define this signature in the @interface macro so we know it is this consistent.
28
+ # There may be some methods to help with these things?
29
+
30
+ # Handle either Type or UnionAll for the method signature parameters
31
+ b = m. sig isa UnionAll ? m. sig. body : m. sig
32
+
33
+ # Skip the fallback methods
34
+ b. parameters[2 ] == Type{<: Interface } && continue
35
+
36
+ # Skip the Type versions of implements and keep the UnionAll
37
+ t = b. parameters[2 ]. var. ub
38
+ t isa UnionAll || return nothing , true
39
+
40
+ interface = t. body. name. wrapper
41
+ implementation = b. parameters[3 ]. var. ub
42
+ implementation == Any && return continue
43
+ objects[implementation] = test_objects (interface, implementation)
44
+ end
45
+ return objects
46
+ end
47
+
21
48
"""
22
49
@implements(interface, objtype, test_objects)
23
50
0 commit comments