diff --git a/src/systems/model_parsing.jl b/src/systems/model_parsing.jl index d6868a94f2..961671b536 100644 --- a/src/systems/model_parsing.jl +++ b/src/systems/model_parsing.jl @@ -24,6 +24,8 @@ struct Model{F, S} end (m::Model)(args...; kw...) = m.f(args...; kw...) +Base.parentmodule(m::Model) = parentmodule(m.f) + for f in (:connector, :mtkmodel) isconnector = f == :connector ? true : false @eval begin diff --git a/test/model_parsing.jl b/test/model_parsing.jl index 71248c56da..a9468f314e 100644 --- a/test/model_parsing.jl +++ b/test/model_parsing.jl @@ -547,3 +547,15 @@ end @test getdefault(component.written_out_for_1.sc) == 2 @test getdefault(component.written_out_for_2.sc) == 3 end + +module GetParentModule + +using ModelingToolkit + +@mtkmodel Component begin end + +end + +@testset "Parent module of Models" begin + @test parentmodule(GetParentModule.Component) == GetParentModule +end