summaryrefslogtreecommitdiff
path: root/src/library/scala/Dynamic.scala
blob: 2d8dbc99772db5ce53e7b47d406ccf5a831d0df7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 {

  /** 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

  /** Returns the underlying value typed as an instance of type T
   *  @param T  The target type
   */
  def typed[T]: T
}