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

« back to all changes in this revision

Viewing changes to src/library/scala/AnyVal.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
1
/*                     __                                               *\
2
2
**     ________ ___   / /  ___     Scala API                            **
3
 
**    / __/ __// _ | / /  / _ |    (c) 2002-2010, LAMP/EPFL             **
 
3
**    / __/ __// _ | / /  / _ |    (c) 2002-2013, LAMP/EPFL             **
4
4
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
5
5
** /____/\___/_/ |_/____/_/ | |                                         **
6
6
**                          |/                                          **
9
9
package scala
10
10
 
11
11
/** `AnyVal` is the root class of all ''value types'', which describe values
12
 
 *  not implemented as objects in the underlying host system.  The value classes
13
 
 *  are specified in SLS 12.2.
 
12
 *  not implemented as objects in the underlying host system. Value classes
 
13
 *  are specified in Scala Language Specification, section 12.2.
14
14
 *
15
15
 *  The standard implementation includes nine `AnyVal` subtypes:
16
16
 *
21
21
 *
22
22
 *  Other groupings:
23
23
 *
24
 
 *  The ''subrange types'' are [[scala.Byte]], [[scala.Short]], and [[scala.Char]].
25
 
 *  The ''integer types'' include the subrange types as well as [[scala.Int]] and [[scala.Long]].
26
 
 *  The ''floating point types'' are [[scala.Float]] and [[scala.Double]].
 
24
 *   - The ''subrange types'' are [[scala.Byte]], [[scala.Short]], and [[scala.Char]].
 
25
 *   - The ''integer types'' include the subrange types as well as [[scala.Int]] and [[scala.Long]].
 
26
 *   - The ''floating point types'' are [[scala.Float]] and [[scala.Double]].
 
27
 *
 
28
 * Prior to Scala 2.10, `AnyVal` was a sealed trait. Beginning with Scala 2.10,
 
29
 * however, it is possible to define a subclass of `AnyVal` called a ''user-defined value class''
 
30
 * which is treated specially by the compiler. Properly-defined user value classes provide a way
 
31
 * to improve performance on user-defined types by avoiding object allocation at runtime, and by
 
32
 * replacing virtual method invocations with static method invocations.
 
33
 *
 
34
 * User-defined value classes which avoid object allocation...
 
35
 *
 
36
 *   - must have a single, public `val` parameter that is the underlying runtime representation.
 
37
 *   - can define `def`s, but no `val`s, `var`s, or nested `traits`s, `class`es or `object`s.
 
38
 *   - typically extend no other trait apart from `AnyVal`.
 
39
 *   - cannot be used in type tests or pattern matching.
 
40
 *   - may not override `equals` or `hashCode` methods.
 
41
 *
 
42
 * A minimal example:
 
43
 * {{{
 
44
 *     class Wrapper(val underlying: Int) extends AnyVal {
 
45
 *       def foo: Wrapper = new Wrapper(underlying * 19)
 
46
 *     }
 
47
 * }}}
 
48
 *
 
49
 * It's important to note that user-defined value classes are limited, and in some circumstances,
 
50
 * still must allocate a value class instance at runtime. These limitations and circumstances are
 
51
 * explained in greater detail in the [[http://docs.scala-lang.org/overviews/core/value-classes.html Value Classes Guide]]
 
52
 * as well as in [[http://docs.scala-lang.org/sips/pending/value-classes.html SIP-15: Value Classes]],
 
53
 * the Scala Improvement Proposal.
27
54
 */
28
 
sealed trait AnyVal
 
55
abstract class AnyVal extends Any with NotNull {
 
56
  def getClass(): Class[_ <: AnyVal] = null
 
57
}