diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index f1c979d6..5cb10c09 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -2132,9 +2132,9 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 // second argument is an internal type derived from the method signature. The // failure to disambiguate two overloads of this method in the ON_CALL statement // is how we block callers from setting expectations on overloaded methods. -#define GMOCK_ON_CALL_IMPL_(mock_expr, Setter, call) \ - ((mock_expr).gmock_##call)(::testing::internal::GetWithoutMatchers(), \ - nullptr) \ +#define GMOCK_ON_CALL_IMPL_(mock_expr, Setter, call) \ + ((mock_expr).gmock_##call)(::testing::internal::WithoutMatchers::Get(), \ + nullptr) \ .Setter(__FILE__, __LINE__, #mock_expr, #call) #define ON_CALL(obj, call) \ diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index cf05d76f..2e746f82 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -299,15 +299,10 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message, class [[nodiscard]] WithoutMatchers { private: WithoutMatchers() = default; - friend -#ifdef GTEST_OS_WINDOWS - GTEST_API_ -#endif - WithoutMatchers GetWithoutMatchers(); -}; -// Internal use only: access the singleton instance of WithoutMatchers. -GTEST_API_ WithoutMatchers GetWithoutMatchers(); + public: + GTEST_API_ static WithoutMatchers Get(); +}; // Invalid() is usable as an expression of type T, but will terminate // the program with an assertion failure if actually run. This is useful diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc index ceee329a..c4aca256 100644 --- a/googlemock/src/gmock-internal-utils.cc +++ b/googlemock/src/gmock-internal-utils.cc @@ -188,7 +188,7 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message, std::cout << ::std::flush; } -GTEST_API_ WithoutMatchers GetWithoutMatchers() { return WithoutMatchers(); } +GTEST_API_ WithoutMatchers WithoutMatchers::Get() { return WithoutMatchers(); } GTEST_API_ void IllegalDoDefault(const char* file, int line) { internal::Assert(