diff options
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Dynamic.scala | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/library/scala/Dynamic.scala b/src/library/scala/Dynamic.scala index 502084949a..2d8dbc9977 100644 --- a/src/library/scala/Dynamic.scala +++ b/src/library/scala/Dynamic.scala @@ -1,18 +1,22 @@ package scala +/** A trait that supports dynamic invocations. Instances `x` of this trait + * allow calls `x.meth(args)` for arbitrary method names `meth` and argument lists + * `args`. If a call is not natively supported by `x`, it is rewritten to + * `x.invokeDynamic("meth", args)`. + */ trait Dynamic { - def _select_ (name: String): Dynamic - def _invoke_ (name: String)(args: Any*): Dynamic - def _invoke_0(name: String)(): Dynamic = _invoke_ (name)() - def _invoke_1(name: String)(arg1: Any): Dynamic = _invoke_ (name) (arg1) - def _invoke_2(name: String)(arg1: Any, arg2: Any): Dynamic = _invoke_ (name)(arg1, arg2) - def _invoke_3(name: String)(arg1: Any, arg2: Any, arg3: Any): Dynamic = _invoke_ (name)(arg1, arg2, arg3) - def _invoke_4(name: String)(arg1: Any, arg2: Any, arg3: Any, arg4: Any): Dynamic = _invoke_ (name)(arg1, arg2, arg3, arg4) - def _invoke_5(name: String)(arg1: Any, arg2: Any, arg3: Any, arg4: Any, arg5: Any): Dynamic = _invoke_ (name)(arg1, arg2, arg3, arg4, arg5) - def _invoke_6(name: String)(arg1: Any, arg2: Any, arg3: Any, arg4: Any, arg5: Any, arg6: Any): Dynamic = _invoke_ (name)(arg1, arg2, arg3, arg4, arg5, arg6) - def _invoke_7(name: String)(arg1: Any, arg2: Any, arg3: Any, arg4: Any, arg5: Any, arg6: Any, arg7: Any): Dynamic = _invoke_ (name)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) + /** The dynamic invocation operation + * @param name The name of the invoked method + * @param args The arguments to the method + */ + def invokeDynamic(name: String, args: Any*): Any - def typed[T]: T = asInstanceOf[T] + /** Returns the underlying value typed as an instance of type T + * @param T The target type + */ + def typed[T]: T } + |