1// Copyright 2022 The Chromium Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// This is a "No Compile Test" suite. 6// http://dev.chromium.org/developers/testing/no-compile-tests 7 8#include "base/functional/overloaded.h" 9 10#include "third_party/abseil-cpp/absl/types/variant.h" 11 12namespace base { 13 14void LambdaMissingForVariantElement() { 15 // `absl::visit()` may only be called on an `Overloaded` that can actually 16 // handle all potential input variant types. 17 struct A {}; 18 struct B {}; 19 absl::variant<A, B> var = A{}; 20 absl::visit(Overloaded{[](A& pack) { return "A"; }}, var); // expected-error-re@*:* {{no type named 'type' in 'absl::type_traits_internal::result_of<base::Overloaded<(lambda at {{.*}})> (B &)>'}} 21} 22 23} // namespace base 24