1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23

base / functional / overloaded_nocompile.nc [blame]

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This is a "No Compile Test" suite.
// http://dev.chromium.org/developers/testing/no-compile-tests

#include "base/functional/overloaded.h"

#include "third_party/abseil-cpp/absl/types/variant.h"

namespace base {

void LambdaMissingForVariantElement() {
  // `absl::visit()` may only be called on an `Overloaded` that can actually
  // handle all potential input variant types.
  struct A {};
  struct B {};
  absl::variant<A, B> var = A{};
  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 &)>'}}
}

}  // namespace base