| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 | 8 |
| 9 namespace base { | 9 namespace base { |
| 10 | 10 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // This is likely not wanted behavior. We specifically check for it though | 160 // This is likely not wanted behavior. We specifically check for it though |
| 161 // because it is possible, depending on how you implement prebinding, to | 161 // because it is possible, depending on how you implement prebinding, to |
| 162 // implicitly convert an array type to a pointer type. | 162 // implicitly convert an array type to a pointer type. |
| 163 void WontCompile() { | 163 void WontCompile() { |
| 164 HasRef p[10]; | 164 HasRef p[10]; |
| 165 Callback<void(void)> method_bound_to_array_cb = | 165 Callback<void(void)> method_bound_to_array_cb = |
| 166 Bind(&HasRef::VoidMethod0, p); | 166 Bind(&HasRef::VoidMethod0, p); |
| 167 method_bound_to_array_cb.Run(); | 167 method_bound_to_array_cb.Run(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 #elif defined(NCTEST_NO_RAW_PTR_FOR_REFCOUNTED_TYPES) // [r"fatal error: static
_assert failed \"p1_is_refcounted_type_and_needs_scoped_refptr\""] | 170 #elif defined(NCTEST_NO_RAW_PTR_FOR_REFCOUNTED_TYPES) // [r"fatal error: static
_assert failed \"a_parameter_is_refcounted_type_and_needs_scoped_refptr\""] |
| 171 | 171 |
| 172 // Refcounted types should not be bound as a raw pointer. | 172 // Refcounted types should not be bound as a raw pointer. |
| 173 void WontCompile() { | 173 void WontCompile() { |
| 174 HasRef for_raw_ptr; | 174 HasRef for_raw_ptr; |
| 175 int a; | 175 int a; |
| 176 Callback<void(void)> ref_count_as_raw_ptr_a = | 176 Callback<void(void)> ref_count_as_raw_ptr_a = |
| 177 Bind(&VoidPolymorphic1<int*>, &a); | 177 Bind(&VoidPolymorphic1<int*>, &a); |
| 178 Callback<void(void)> ref_count_as_raw_ptr = | 178 Callback<void(void)> ref_count_as_raw_ptr = |
| 179 Bind(&VoidPolymorphic1<HasRef*>, &for_raw_ptr); | 179 Bind(&VoidPolymorphic1<HasRef*>, &for_raw_ptr); |
| 180 } | 180 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 193 #elif defined(NCTEST_DISALLOW_ASSIGN_DIFFERENT_TYPES) // [r"fatal error: no via
ble conversion from 'Callback<typename internal::BindState<typename internal::Fu
nctorTraits<void \(\*\)\(int\)>::RunnableType, typename internal::FunctorTraits<
void \(\*\)\(int\)>::RunType, void \(\)>::UnboundRunType>' to 'Callback<void \(\
)>'"] | 193 #elif defined(NCTEST_DISALLOW_ASSIGN_DIFFERENT_TYPES) // [r"fatal error: no via
ble conversion from 'Callback<typename internal::BindState<typename internal::Fu
nctorTraits<void \(\*\)\(int\)>::RunnableType, typename internal::FunctorTraits<
void \(\*\)\(int\)>::RunType, void \(\)>::UnboundRunType>' to 'Callback<void \(\
)>'"] |
| 194 | 194 |
| 195 // Bind result cannot be assigned to Callbacks with a mismatching type. | 195 // Bind result cannot be assigned to Callbacks with a mismatching type. |
| 196 void WontCompile() { | 196 void WontCompile() { |
| 197 Closure callback_mismatches_bind_type = Bind(&VoidPolymorphic1<int>); | 197 Closure callback_mismatches_bind_type = Bind(&VoidPolymorphic1<int>); |
| 198 } | 198 } |
| 199 | 199 |
| 200 #endif | 200 #endif |
| 201 | 201 |
| 202 } // namespace base | 202 } // namespace base |
| OLD | NEW |