@timholy brought up a good point in JuliaLang/julia#49973 (comment), namely that sometimes return type assertions are useful. This would (optionally) be checked as well when checking for interface conformity. The syntax to use this would be (in the example of AbstractArrays):
@required AbstractArray begin
size(::AbstractArray{T,N})::NTuple{N, Int}
getindex(::AbstractArray{T}, ::Int)::T
end
where the T in getindex would be forced to match. This could potentially be implemented with Base.return_type. Though I do admit not liking relying on inference, there's no way around it in this case.
@timholy brought up a good point in JuliaLang/julia#49973 (comment), namely that sometimes return type assertions are useful. This would (optionally) be checked as well when checking for interface conformity. The syntax to use this would be (in the example of
AbstractArrays):where the
Tingetindexwould be forced to match. This could potentially be implemented withBase.return_type. Though I do admit not liking relying on inference, there's no way around it in this case.