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

[framework] Fix deprecated AddIfSupported scalar conversion helper #15657

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion systems/framework/system_scalar_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class SystemScalarConverter {
DRAKE_DEPRECATED("2021-10-01",
"User-defined scalar types cannot be added.")
void AddIfSupported() {
AddIfSupported<S, T, U>(GuaranteedSubtypePreservation::kEnabled);
MaybeAddConstructor<true, S, T, U>();
}

/// Removes from this converter all pairs where `other.IsConvertible<T, U>`
Expand Down
12 changes: 12 additions & 0 deletions systems/framework/test/system_scalar_converter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,18 @@ GTEST_TEST(SystemScalarConverterTest, Remove) {
dut.Convert<AutoDiffXd, double>(system)));
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
GTEST_TEST(SystemScalarConverterTest, DeprecatedAddIfSupported) {
// The deprecated function AddIfSupported no longer serves any useful purpose,
// because there are no public functions that allow us to observe its effects,
// but we should ensure that it at least _compiles_ if someone does try to use
// it.
SystemScalarConverter dut(SystemTypeTag<FromDoubleSystem>{});
dut.AddIfSupported<FromDoubleSystem, double, float>();
}
#pragma GCC diagnostic pop

} // namespace
} // namespace systems
} // namespace drake