aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-04-23 15:20:43 +0200
committerBjörn Gustavsson <[email protected]>2018-04-25 12:51:21 +0200
commitbf84118febaae7857f12625584f33a649f79aeed (patch)
treecdfa4693c0c4484fc9c73bcee0da682ec4cdf6b1 /lib/compiler/test
parent381ab6129998cbd43216eaafabf7cef78c879c5d (diff)
downloadotp-bf84118febaae7857f12625584f33a649f79aeed.tar.gz
otp-bf84118febaae7857f12625584f33a649f79aeed.tar.bz2
otp-bf84118febaae7857f12625584f33a649f79aeed.zip
Rewrite a call of a literal external fun to a direct call
Rewrite calls such as: (fun erlang:abs/1)(-42) to: erlang:abs(-42) While we are at it, also add rewriting of apply/2 with a fixed number of arguments to a direct call of the fun. For example: apply(F, [A,B]) would be rewritten to: F(A, B) https://bugs.erlang.org/browse/ERL-614
Diffstat (limited to 'lib/compiler/test')
-rw-r--r--lib/compiler/test/fun_SUITE.erl11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/compiler/test/fun_SUITE.erl b/lib/compiler/test/fun_SUITE.erl
index 16474adf5b..3c272a35a6 100644
--- a/lib/compiler/test/fun_SUITE.erl
+++ b/lib/compiler/test/fun_SUITE.erl
@@ -194,6 +194,17 @@ external(Config) when is_list(Config) ->
?APPLY2(ListsMod, ListsMap, 2),
?APPLY2(ListsMod, ListsMap, ListsArity),
+ 42 = (fun erlang:abs/1)(-42),
+ 42 = (id(fun erlang:abs/1))(-42),
+ 42 = apply(fun erlang:abs/1, [-42]),
+ 42 = apply(id(fun erlang:abs/1), [-42]),
+ 6 = (fun lists:sum/1)([1,2,3]),
+ 6 = (id(fun lists:sum/1))([1,2,3]),
+
+ {'EXIT',{{badarity,_},_}} = (catch (fun lists:sum/1)(1, 2, 3)),
+ {'EXIT',{{badarity,_},_}} = (catch (id(fun lists:sum/1))(1, 2, 3)),
+ {'EXIT',{{badarity,_},_}} = (catch apply(fun lists:sum/1, [1,2,3])),
+
ok.
call_me(I) ->