1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This is a "No Compile Test" suite.
6 // http://dev.chromium.org/developers/testing/no-compile-tests
8 #include "base/callback.h"
15 class Child : Parent {
18 #if defined(NCTEST_EQUALS_REQUIRES_SAMETYPE) // [r"fatal error: no viable conversion from 'RepeatingCallback<int \(\)>' to 'const RepeatingCallback<void \(\)>'"]
20 // Attempting to call comparison function on two callbacks of different type.
22 // This should be a compile time failure because each callback type should be
23 // considered distinct.
30 #elif defined(NCTEST_CONSTRUCTION_FROM_SUBTYPE) // [r"fatal error: no viable conversion from 'Callback<base::Parent \(\)>' to 'Callback<base::Child \(\)>'"]
32 // Construction of Callback<A> from Callback<B> if A is supertype of B.
34 // While this is technically safe, most people aren't used to it when coding
35 // C++ so if this is happening, it is almost certainly an error.
37 Callback<Parent()> cb_a;
38 Callback<Child()> cb_b = cb_a;
41 #elif defined(NCTEST_ASSIGNMENT_FROM_SUBTYPE) // [r"fatal error: no viable overloaded '='"]
43 // Assignment of Callback<A> from Callback<B> if A is supertype of B.
44 // See explanation for NCTEST_CONSTRUCTION_FROM_SUBTYPE
46 Callback<Parent()> cb_a;
47 Callback<Child()> cb_b;