diff --git a/mlir/unittests/Support/CyclicReplacerCacheTest.cpp b/mlir/unittests/Support/CyclicReplacerCacheTest.cpp index ca2eb6ce4171f79..64a8ab72b69b7dc 100644 --- a/mlir/unittests/Support/CyclicReplacerCacheTest.cpp +++ b/mlir/unittests/Support/CyclicReplacerCacheTest.cpp @@ -26,14 +26,15 @@ TEST(CachedCyclicReplacerTest, testNoRecursion) { TEST(CachedCyclicReplacerTest, testInPlaceRecursionPruneAnywhere) { // Replacer cycles through ints 0 -> 1 -> 2 -> 0 -> ... - CachedCyclicReplacer replacer( - /*replacer=*/[&](int n) { return replacer((n + 1) % 3); }, + std::optional> replacer; + replacer.emplace( + /*replacer=*/[&](int n) { return (*replacer)((n + 1) % 3); }, /*cycleBreaker=*/[&](int n) { return -1; }); // Starting at 0. - EXPECT_EQ(replacer(0), -1); + EXPECT_EQ((*replacer)(0), -1); // Starting at 2. - EXPECT_EQ(replacer(2), -1); + EXPECT_EQ((*replacer)(2), -1); } //===----------------------------------------------------------------------===//