-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
System::type_id
Consistency
#11728
System::type_id
Consistency
#11728
Conversation
…em>` Added `IntoSystem::system_type_id` with a default implementation which matches `System::type_id`, which now also has a default implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a small test to validate this behavior, ideally for all of our different flavors of systems.
I've added some unit tests which cover exclusive function systems, and function systems. They ensure that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd actually have preferred that we hard-break the existing use cases, since this change is otherwise silent. It's cases like these where I wish we had something similar to Crater to find the affected ecosystem crates. Otherwise though, LGTM.
…_id` (#12030) ## Objective Always have `some_system.into_system().type_id() == some_system.into_system_set().system_type().unwrap()`. System sets have a `fn system_type() -> Option<TypeId>` that is implemented by `SystemTypeSet` to returning the TypeId of the system's function type. This was implemented in #7715 and is used in `bevy_mod_debugdump` to handle `.after(function)` constraints. Back then, `System::type_id` always also returned the type id of the function item, not of `FunctionSystem<M, F>`. #11728 changes the behaviour of `System::type_id` so that it returns the id of the `FunctionSystem`/`ExclusiveFunctionSystem` wrapper, but it did not change `SystemTypeSet::system_type`, so doing the lookup breaks in `bevy_mod_debugdump`. ## Solution Change `IntoSystemSet` for functions to return a `SystemTypeSet<FunctionSystem>` / `SystemTypeSet<ExclusiveFunctionSystem>` instead of `SystemTypeSet<F>`.
…_id` (bevyengine#12030) ## Objective Always have `some_system.into_system().type_id() == some_system.into_system_set().system_type().unwrap()`. System sets have a `fn system_type() -> Option<TypeId>` that is implemented by `SystemTypeSet` to returning the TypeId of the system's function type. This was implemented in bevyengine#7715 and is used in `bevy_mod_debugdump` to handle `.after(function)` constraints. Back then, `System::type_id` always also returned the type id of the function item, not of `FunctionSystem<M, F>`. bevyengine#11728 changes the behaviour of `System::type_id` so that it returns the id of the `FunctionSystem`/`ExclusiveFunctionSystem` wrapper, but it did not change `SystemTypeSet::system_type`, so doing the lookup breaks in `bevy_mod_debugdump`. ## Solution Change `IntoSystemSet` for functions to return a `SystemTypeSet<FunctionSystem>` / `SystemTypeSet<ExclusiveFunctionSystem>` instead of `SystemTypeSet<F>`.
…_id` (bevyengine#12030) ## Objective Always have `some_system.into_system().type_id() == some_system.into_system_set().system_type().unwrap()`. System sets have a `fn system_type() -> Option<TypeId>` that is implemented by `SystemTypeSet` to returning the TypeId of the system's function type. This was implemented in bevyengine#7715 and is used in `bevy_mod_debugdump` to handle `.after(function)` constraints. Back then, `System::type_id` always also returned the type id of the function item, not of `FunctionSystem<M, F>`. bevyengine#11728 changes the behaviour of `System::type_id` so that it returns the id of the `FunctionSystem`/`ExclusiveFunctionSystem` wrapper, but it did not change `SystemTypeSet::system_type`, so doing the lookup breaks in `bevy_mod_debugdump`. ## Solution Change `IntoSystemSet` for functions to return a `SystemTypeSet<FunctionSystem>` / `SystemTypeSet<ExclusiveFunctionSystem>` instead of `SystemTypeSet<F>`.
…_id` (bevyengine#12030) ## Objective Always have `some_system.into_system().type_id() == some_system.into_system_set().system_type().unwrap()`. System sets have a `fn system_type() -> Option<TypeId>` that is implemented by `SystemTypeSet` to returning the TypeId of the system's function type. This was implemented in bevyengine#7715 and is used in `bevy_mod_debugdump` to handle `.after(function)` constraints. Back then, `System::type_id` always also returned the type id of the function item, not of `FunctionSystem<M, F>`. bevyengine#11728 changes the behaviour of `System::type_id` so that it returns the id of the `FunctionSystem`/`ExclusiveFunctionSystem` wrapper, but it did not change `SystemTypeSet::system_type`, so doing the lookup breaks in `bevy_mod_debugdump`. ## Solution Change `IntoSystemSet` for functions to return a `SystemTypeSet<FunctionSystem>` / `SystemTypeSet<ExclusiveFunctionSystem>` instead of `SystemTypeSet<F>`.
…_id` (#12030) ## Objective Always have `some_system.into_system().type_id() == some_system.into_system_set().system_type().unwrap()`. System sets have a `fn system_type() -> Option<TypeId>` that is implemented by `SystemTypeSet` to returning the TypeId of the system's function type. This was implemented in #7715 and is used in `bevy_mod_debugdump` to handle `.after(function)` constraints. Back then, `System::type_id` always also returned the type id of the function item, not of `FunctionSystem<M, F>`. #11728 changes the behaviour of `System::type_id` so that it returns the id of the `FunctionSystem`/`ExclusiveFunctionSystem` wrapper, but it did not change `SystemTypeSet::system_type`, so doing the lookup breaks in `bevy_mod_debugdump`. ## Solution Change `IntoSystemSet` for functions to return a `SystemTypeSet<FunctionSystem>` / `SystemTypeSet<ExclusiveFunctionSystem>` instead of `SystemTypeSet<F>`.
Objective
TypeId
of systems have an unexpected value #11679Solution
IntoSystem::system_type_id
which returns the equivalent ofsystem.into_system().type_id()
without construction. This allows for getting theTypeId
of functions (a function is an unnamed type and therefore you cannot callTypeId::of::<apply_deferred::System>()
)System::type_id
to ensure consistency between implementations. Some returnedSelf
, while others were returning an inner value instead. This ensures consistency withIntoSystem::system_type_id
.Migration Guide
If you use
System::type_id()
on function systems (exclusive or not), ensure you are comparing its value to otherSystem::type_id()
calls, orIntoSystem::system_type_id()
.This code wont require any changes, because
IntoSystem
's are directly compared to each other.Likewise, this code wont, because
System
's are directly compared.The below does require a change, since you're comparing a
System
type to aIntoSystem
type.