diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2024-03-04 18:33:07 +0100 |
---|---|---|
committer | Rami Potinkara <rami.potinkara@qt.io> | 2024-03-06 13:00:19 +0000 |
commit | 10afa38aa44231b3617984fdbca66d9699e2825f (patch) | |
tree | b06218609e4eccde673013a01f703ca44a244a5d /src/corelib/kernel | |
parent | 8103d29e94f90131ee0ad69fc312c1e62e74a6a9 (diff) |
JNI: Fix error with overload resolution when passing string types
The variadic templates are supposed to be removed from the
overload set when any of the parameters is a literal string type,
as otherwise we get conflicts with the legacy overload taking
class names and signatures as const char *. The detection of
a literal string types was missing a few specializations, so that
we ended up with the wrong overload being called, and class
names getting interpreted as method names instead.
Add the missing specializations, and add more test coverage
for using the old overloads.
Task-number: QTBUG-122235
Pick-to: 6.7
Change-Id: I5488f2009c8f62d74fac6754844f57cf64011414
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Lauri Pohjanheimo <lauri.pohjanheimo@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qjnitypes_impl.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/kernel/qjnitypes_impl.h b/src/corelib/kernel/qjnitypes_impl.h index 16bf308dab..d963509023 100644 --- a/src/corelib/kernel/qjnitypes_impl.h +++ b/src/corelib/kernel/qjnitypes_impl.h @@ -134,9 +134,12 @@ struct CTString // Helper types that allow us to disable variadic overloads that would conflict // with overloads that take a const char*. template<typename T, size_t N = 0> struct IsStringType : std::false_type {}; -template<> struct IsStringType<const char*, 0> : std::true_type {}; +template<> struct IsStringType<const char *, 0> : std::true_type {}; +template<> struct IsStringType<const char *&, 0> : std::true_type {}; template<size_t N> struct IsStringType<CTString<N>> : std::true_type {}; template<size_t N> struct IsStringType<const char[N]> : std::true_type {}; +template<size_t N> struct IsStringType<const char(&)[N]> : std::true_type {}; +template<size_t N> struct IsStringType<char[N]> : std::true_type {}; template <typename T> struct Traits { |