Skip to content

Commit

Permalink
Deprecate unsafeGet(), it will be removed in Fruit 3.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
poletti-marco committed Jul 30, 2017
1 parent 28894a1 commit 30db886
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion include/fruit/impl/injector.defn.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ inline Injector<P...>::RemoveAnnotations<T> Injector<P...>::get() {

template <typename... P>
template <typename C>
inline Injector<P...>::RemoveAnnotations<C>* Injector<P...>::unsafeGet() {
inline
FRUIT_DEPRECATED_DEFINITION(Injector<P...>::RemoveAnnotations<C>* Injector<P...>::unsafeGet()) {
return storage->template unsafeGet<C>();
}

Expand Down
4 changes: 3 additions & 1 deletion include/fruit/injector.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ class Injector {
* notes, and if you used this method you'll have to check that the existing uses still work.
*/
template <typename C>
RemoveAnnotations<C>* unsafeGet();
FRUIT_DEPRECATED_DECLARATION(
RemoveAnnotations<C>* unsafeGet()
);

/**
* This is a convenient way to call get(). E.g.:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_binding_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ def test_compression_undone():
'''
expect_success(
COMMON_DEFINITIONS,
source)
source,
ignore_deprecation_warnings=True)

if __name__== '__main__':
main(__file__)
13 changes: 12 additions & 1 deletion tests/test_injector_unsafe_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,18 @@ def test_success(XAnnot, YAnnot, ZAnnot):
expect_success(
COMMON_DEFINITIONS,
source,
locals())
locals(),
ignore_deprecation_warnings=True)

def test_unsafe_get_deprecated():
source = '''
struct X {};
void f(fruit::Injector<> injector) {
injector.unsafeGet<X>();
}
'''
expect_generic_compile_error('deprecation|deprecated', COMMON_DEFINITIONS, source)

if __name__== '__main__':
main(__file__)

0 comments on commit 30db886

Please sign in to comment.