Skip to content

Support return type assertions #8

Description

@Seelengrab

@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions