diff --git a/src/models/ModelInterface.jl b/src/models/ModelInterface.jl index d1b2d6e..4e9e0ec 100644 --- a/src/models/ModelInterface.jl +++ b/src/models/ModelInterface.jl @@ -387,11 +387,7 @@ function typecheck_instance( overload_errormsg = "the types for this model declaration do not permit Julia overloading to distinguish between GAT overloads" - for (decl, resolver) in theory.resolvers - if nameof(decl) ∈ ext_functions - continue - end for (_, x) in allmethods(resolver) if getvalue(theory[x]) isa AlgStruct continue @@ -455,6 +451,7 @@ function typecheck_instance( end for (sig, (decl, method)) in undefined_signatures + nameof(decl) ∈ ext_functions && continue # assume it has been impl'd already judgment = getvalue(theory[method]) if judgment isa AlgTermConstructor error("Failed to implement $decl: $(toexpr(sig))") diff --git a/test/models/ModelInterface.jl b/test/models/ModelInterface.jl index 5518164..e6fe937 100644 --- a/test/models/ModelInterface.jl +++ b/test/models/ModelInterface.jl @@ -170,4 +170,30 @@ end munit() = 0 end +# Test scenario where we @import a method but then extend it +############################################################ +@theory T1 begin + X::TYPE; + h(a::X)::X +end + +@theory T2<:T1 begin + Y::TYPE; + h(b::Y)::Y +end + +@instance T1{Int} begin + h(a::Int) = 1 +end + +@instance T2{Int,Bool} begin + @import X, h + h(b::Bool) = false +end + +@test h(2) == 1 + +@test h(false) == false + + end # module