diff --git a/src/ModelingToolkit.jl b/src/ModelingToolkit.jl index d23d173b9a..46c6892607 100644 --- a/src/ModelingToolkit.jl +++ b/src/ModelingToolkit.jl @@ -138,6 +138,9 @@ $(TYPEDEF) TODO """ abstract type AbstractSystem end +# Solely so that `ODESystem` can be deprecated and still act as a valid type. +# See `deprecations.jl`. +abstract type IntermediateDeprecationSystem <: AbstractSystem end function independent_variable end @@ -275,7 +278,7 @@ PrecompileTools.@compile_workload begin end export ODEFunction, convert_system_indepvar, - System, OptimizationSystem, JumpSystem, SDESystem, NonlinearSystem + System, OptimizationSystem, JumpSystem, SDESystem, NonlinearSystem, ODESystem export SDEFunction export SystemStructure export DiscreteProblem, DiscreteFunction diff --git a/src/deprecations.jl b/src/deprecations.jl index bbd266fa0c..3735d8f6f4 100644 --- a/src/deprecations.jl +++ b/src/deprecations.jl @@ -9,7 +9,15 @@ macro mtkbuild(exprs...) end |> esc end -for T in [:ODESystem, :NonlinearSystem, :DiscreteSystem, :ImplicitDiscreteSystem] +const ODESystem = IntermediateDeprecationSystem + +function IntermediateDeprecationSystem(args...; kwargs...) + Base.depwarn("`ODESystem(args...; kwargs...)` is deprecated. Use `System(args...; kwargs...) instead`.", :ODESystem) + + return System(args...; kwargs...) +end + +for T in [:NonlinearSystem, :DiscreteSystem, :ImplicitDiscreteSystem] @eval @deprecate $T(args...; kwargs...) System(args...; kwargs...) end diff --git a/src/systems/system.jl b/src/systems/system.jl index a43e4f5c65..61c3821b9f 100644 --- a/src/systems/system.jl +++ b/src/systems/system.jl @@ -24,7 +24,7 @@ structure. $(TYPEDFIELDS) """ -struct System <: AbstractSystem +struct System <: IntermediateDeprecationSystem """ $INTERNAL_FIELD_WARNING A unique integer tag for the system. diff --git a/test/odesystem.jl b/test/odesystem.jl index 3f00120487..9d1b2fc1e8 100644 --- a/test/odesystem.jl +++ b/test/odesystem.jl @@ -1600,3 +1600,17 @@ end @test getmetadata(sys, TestMeta, nothing) == "test" @test getmetadata(sys2, TestMeta, nothing) == "test" end + +struct TestWrapper + sys::ODESystem +end + +@testset "`ODESystem` is a type" begin + @variables x(t) + @named sys = ODESystem(D(x) ~ x, t) + @test sys isa ODESystem + @test sys isa System + arr = ODESystem[] + @test_nowarn push!(arr, sys) + @test_nowarn TestWrapper(sys) +end