Dotty Documentation

0.18.0-bin-SNAPSHOT

package scala

[-] Constructors

[-] Members

[+] package scala.annotation
[+] package scala.compiletime
[+] package scala.implicits
[+] package scala.internal
[+] package scala.quoted
[+] package scala.reflect
[+] package scala.runtime
[+] package scala.tasty
[+] package scala.util
[+] @showAsInfix sealed abstract class *:
[+] object *:
[+] @FunctionalInterface abstract class Conversion

A class for implicit values that can serve as implicit conversions The implicit resolution algorithm will act as if there existed the additional implicit definition:

def $implicitConversion[T, U](x: T)(c: Conversion[T, U]): U = c(x)

However, the presence of this definition would slow down implicit search since its outermost type matches any pair of types. Therefore, implicit search contains a special case in Implicits#discardForView which emulates the conversion in a more efficient way.

Note that this is a SAM class - function literals are automatically converted to the Conversion values.

Also note that in bootstrapped dotty, Predef.<:< should inherit from Conversion. This would cut the number of special cases in discardForView from two to one.

[+] trait Enum

A base trait of all enum classes

[+] object Eql

Companion object containing a few universally known Eql instances. Eql instances involving primitive types or the Null type are handled directly in the compiler (see Implicits.synthesizedEq), so they are not included here.

[+] @Child @implicitNotFound sealed trait Eql

A marker trait indicating that values of type L can be compared to values of type R.

[+] trait FunctionXXL

A function with all parameters grouped in an array.

[+] @Child sealed trait NonEmptyTuple

Tuple of arbitrary non-zero arity

[+] trait PolyFunction

Marker trait for polymorphic function types.

This is the only trait that can be refined with a polymorphic method, as long as that method is called apply, e.g.: PolyFunction { def apply[T_1, ..., T_M](x_1: P_1, ..., x_N: P_N): R } This type will be erased to FunctionN.

[+] object Product0

A class for Product0 which was missing from the scala distribution.

[+] trait Product0
[+] trait Selectable
[+] object Tuple
[+] @Child sealed trait Tuple

Tuple of arbitrary arity

[+] final class TupleXXL
[+] object TupleXXL
[+] @Child @implicitNotFound sealed trait TupledFunction

Type class relating a FunctionN[..., R] with an equivalent tupled function Function1[TupleN[...], R]

[+] @implicitNotFound final class ValueOf

ValueOf[T] provides the unique value of the type T where T is a type which has a single inhabitant. Eligible types are singleton types of the form stablePath.type, Unit and singleton types corresponding to value literals.

Instances of ValueOf[T] are provided implicitly for all eligible types. Typically an instance would be required where a runtime value corresponding to a type level computation is needed.

For example, we might define a type Residue[M <: Int] corresponding to the group of integers modulo M. We could then mandate that residues can be summed only when they are parameterized by the same modulus,

{{{ case class Residue[M <: Int](n: Int) extends AnyVal { def +(rhs: Residue[M])(implicit m: ValueOf[M]): Residue[M] = Residue((this.n + rhs.n) % valueOf[M]) }

val fiveModTen = Residue10 val nineModTen = Residue10

fiveModTen + nineModTen // OK == Residue10

val fourModEleven = Residue11

fiveModTen + fourModEleven // compiler error: type mismatch; // found : Residue[11] // required: Residue[10] }}}

Notice that here the modulus is encoded in the type of the values and so does not incur any additional per-value storage cost. When a runtime value of the modulus is required in the implementation of + it is provided at the call site via the implicit argument m of type ValueOf[M].

[+] @implicitNotFound object ValueOf

ValueOf[T] provides the unique value of the type T where T is a type which has a single inhabitant. Eligible types are singleton types of the form stablePath.type, Unit and singleton types corresponding to value literals.

Instances of ValueOf[T] are provided implicitly for all eligible types. Typically an instance would be required where a runtime value corresponding to a type level computation is needed.

For example, we might define a type Residue[M <: Int] corresponding to the group of integers modulo M. We could then mandate that residues can be summed only when they are parameterized by the same modulus,

{{{ case class Residue[M <: Int](n: Int) extends AnyVal { def +(rhs: Residue[M])(implicit m: ValueOf[M]): Residue[M] = Residue((this.n + rhs.n) % valueOf[M]) }

val fiveModTen = Residue10 val nineModTen = Residue10

fiveModTen + nineModTen // OK == Residue10

val fourModEleven = Residue11

fiveModTen + fourModEleven // compiler error: type mismatch; // found : Residue[11] // required: Residue[10] }}}

Notice that here the modulus is encoded in the type of the values and so does not incur any additional per-value storage cost. When a runtime value of the modulus is required in the implementation of + it is provided at the call site via the implicit argument m of type ValueOf[M].

[+] object deriving
[+] class forceInline

An annotation on methods that is equivalent to Dotty inline modifier, except that it does not imply erased.

The annotation should be used instead of the inline modifier in code that needs to cross compile between Scala 2 and Dotty.

Note that Scala 2 ignores the @forceInLine annotation, and one must use both the @inline and @forceInline annotation to inline across the two compilers. E.g.

[+] class main

An annotation that designates a main function