~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to src/compiler/scala/tools/reflect/Invoked.scala

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* NSC -- new Scala compiler
2
 
 * Copyright 2005-2011 LAMP/EPFL
3
 
 * @author Paul Phillips
4
 
 */
5
 
 
6
 
package scala.tools
7
 
package reflect
8
 
 
9
 
import java.lang.reflect.{ Method, Proxy }
10
 
 
11
 
/** A class representing a single method call.  It is primarily for use
12
 
 *  in tandem with Mock.  If the invocation did not target an InvocationHandler,
13
 
 *  proxy will be null.
14
 
 */
15
 
class Invoked private (val proxy: AnyRef, val m: Method, val args: List[AnyRef]) {
16
 
  def name                 = m.getName
17
 
  def arity                = m.getParameterTypes.size
18
 
  def returnType           = m.getReturnType
19
 
  def returns[T: Manifest] = returnType == manifest[T].erasure
20
 
 
21
 
  def invokeOn(target: AnyRef) = m.invoke(target, args: _*)
22
 
  def isObjectMethod = Set("toString", "equals", "hashCode") contains name
23
 
 
24
 
  override def toString = "Invoked: %s called with %s".format(
25
 
    m.getName,
26
 
    if (args.isEmpty) "no args" else "args '%s'".format(args mkString ", ")
27
 
  )
28
 
}
29
 
 
30
 
object Invoked {
31
 
  def apply(m: Method, args: Seq[Any]): Invoked = apply(null, m, args)
32
 
  def apply(proxy: AnyRef, m: Method, args: Seq[Any]): Invoked = {
33
 
    val fixedArgs = if (args == null) Nil else args.toList map (_.asInstanceOf[AnyRef])
34
 
    new Invoked(proxy, m, fixedArgs)
35
 
  }
36
 
  def unapply(x: Any) = x match {
37
 
    case x: Invoked => Some(x.proxy, x.m, x.args)
38
 
    case _          => None
39
 
  }
40
 
  object NameAndArgs {
41
 
    def unapply(x: Any) = x match {
42
 
      case x: Invoked => Some(x.name, x.args)
43
 
      case _          => None
44
 
    }
45
 
  }
46
 
  object NameAndArity {
47
 
    def unapply(x: Any) = x match {
48
 
      case x: Invoked => Some(x.name, x.arity)
49
 
      case _          => None
50
 
    }
51
 
  }
52
 
}