Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interfaces failing when matching on supertype #18

Open
SBuercklin opened this issue Jun 24, 2024 · 1 comment
Open

Interfaces failing when matching on supertype #18

SBuercklin opened this issue Jun 24, 2024 · 1 comment

Comments

@SBuercklin
Copy link

The following fails because I define bar(::Foo, ::Any), which gives an ambiguity error when I try e.g. bar(::Foo, ::Int) with the default error fallback using the abstract type

using RequiredInterfaces

abstract type MyInterface end
@required MyInterface begin
    bar(::MyInterface, ::Number)
end

struct Foo <: MyInterface end
bar(::Foo, x) = x

RequiredInterfaces.check_implementations(MyInterface)
# Fails because of ambiguity with the erroring fallback
@Seelengrab
Copy link
Owner

Seelengrab commented Jun 25, 2024

Yes, this is a limitation of having to create actual methods to make the fallback work :( It wouldn't be a problem if the typesystem itself were aware of the interface, because then the error would come from having a distinction between an interface & a defined method to throw the NotImplementedError from. It would be the compiler/type checker that throws the error, not a fallback method.

I think it could be made to work in this particular case, at least in terms of having check_implementations report a "success", but you'd still get an ambiguity when actually trying to call this method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants