diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h --- a/flang/include/flang/Evaluate/tools.h +++ b/flang/include/flang/Evaluate/tools.h @@ -219,16 +219,22 @@ } else if constexpr (std::is_same_v>) { return common::visit( [](auto &x) { return UnwrapConvertedExpr(x); }, x.u); - } else if constexpr (!common::HasMember) { - using Result = ResultType; - if constexpr (std::is_same_v> || - std::is_same_v>>) { + } else { + using DesiredResult = ResultType; + if constexpr (std::is_same_v> || + std::is_same_v>>) { return common::visit( [](auto &x) { return UnwrapConvertedExpr(x); }, x.u); - } else if constexpr (std::is_same_v> || - std::is_same_v>) { - return common::visit( - [](auto &x) { return UnwrapConvertedExpr(x); }, x.left().u); + } else { + using ThisResult = ResultType; + if constexpr (std::is_same_v>) { + return common::visit( + [](auto &x) { return UnwrapConvertedExpr(x); }, x.u); + } else if constexpr (std::is_same_v> || + std::is_same_v>) { + return common::visit( + [](auto &x) { return UnwrapConvertedExpr(x); }, x.left().u); + } } } return nullptr;