Scala Library
|
|
scala/reflect/Invocation.scala
]
object
Invocation
extends
AnyRef
A more convenient syntax for reflective invocation.
Example usage:
class Obj { private def foo(x: Int, y: String): Long = x + y.length }
You can call it reflectively one of two ways:
import scala.reflect.Invocation._ (new Obj) o 'foo(5, "abc") // the 'o' method returns Any val x: Long = (new Obj) oo 'foo(5, "abc") // the 'oo' method casts to expected type.
If you call the oo
method and do not give the type inferencer
enough help, it will most likely infer Nothing
, which will
result in a ClassCastException
.
Method Summary | |
def
|
getAnyValClass
(x : AnyVal) : java.lang.Class[Any]
Obtain the class object for an
AnyVal . |
implicit def
|
makePreservedAnyRef [T <: AnyRef](x : T) : PreservedAnyRef[T] |
implicit def
|
makePreservedAnyVal [T <: AnyVal](x : T) : PreservedAnyVal[T] |
implicit def
|
makeReflectionOperators [T <: AnyRef](x : T) : ReflectionOperators[T] |
implicit def
|
makeRichSymbol (sym : Symbol) : RichSymbol |
Methods inherited from AnyRef | |
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Class Summary | |
case class
|
PreservedAnyRef
[T <: AnyRef](val value : T) extends PrimitivePreserver[T] with Product
|
case class
|
PreservedAnyVal
[T <: AnyVal](val value : T) extends PrimitivePreserver[T] with Product
|
trait
|
PrimitivePreserver
[T] extends AnyRef
|
class
|
ReflectionOperators
[T <: AnyRef](self : T) extends AnyRef
An implicit on AnyRef provides it with the 'o' method, which is supposed
to look like a giant '.' and present the feel of method invocation.
|
class
|
RichSymbol
(sym : Symbol) extends AnyRef
|
class
|
SymbolWithArguments
(val sym : Symbol, val args : PrimitivePreserver[Any]*) extends AnyRef
We also require an implicit on scala.Symbol so they appear to contain
an apply method, which packages the method arguments. The type parameter
is the method's expected result type.
|
Method Details |
implicit
def
makePreservedAnyRef[T <: AnyRef](x : T) : PreservedAnyRef[T]
implicit
def
makePreservedAnyVal[T <: AnyVal](x : T) : PreservedAnyVal[T]
implicit
def
makeRichSymbol(sym : Symbol) : RichSymbol
implicit
def
makeReflectionOperators[T <: AnyRef](x : T) : ReflectionOperators[T]
def
getAnyValClass(x : AnyVal) : java.lang.Class[Any]
AnyVal
.
Scala Library
|
|