scala.compiletime
extends ObjectSupertypes
ObjectMembers
S
= Nothing <: IntSuccesor of a natural number where zero is the type 0 and successors are reduced as if the definition was
type S[N <: Int] <: Int = N match { case 0 => 1 c...
Succesor of a natural number where zero is the type 0 and successors are reduced as if the definition was
type S[N <: Int] <: Int = N match { case 0 => 1 case 1 => 2 case 2 => 3 ... case 2147483646 => 2147483647 }
byName
[T] ( x: => T ) : TAssertion that an argument is by-name. Used for nullability checking.
Assertion that an argument is by-name. Used for nullability checking.
constValue
[T] : TGiven a constant, singleton type T
, convert it to a value
of the same singleton type. For example: assert(constValue[1] == 1)
.
Given a constant, singleton type T
, convert it to a value
of the same singleton type. For example: assert(constValue[1] == 1)
.
constValueOpt
[T] : Option[T]Same as constValue
but returns a None
if a constant value
cannot be constructed from the provided type. Otherwise returns
that value wrapped in Some
.
Same as constValue
but returns a None
if a constant value
cannot be constructed from the provided type. Otherwise returns
that value wrapped in Some
.
constValueTuple
[T] : Widen[T]Given a tuple type (X1, ..., Xn)
, returns a tuple value
(constValue[X1], ..., constValue[Xn])
.
Given a tuple type (X1, ..., Xn)
, returns a tuple value
(constValue[X1], ..., constValue[Xn])
.
erasedValue
[T] : TUse this method when you have a type, do not have a value for it but want to
pattern match on it. For example, given a type Tup <: Tuple
, one can
patter...
Use this method when you have a type, do not have a value for it but want to
pattern match on it. For example, given a type Tup <: Tuple
, one can
pattern-match on it as follows:
erasedValue[Tup] match {
case _: EmptyTuple => ...
case _: h *: t => ...
}
error
( msg: String ) : NothingThe error method is used to produce user-defined compile errors during inline expansion. If an inline expansion results in a call error(msgStr) the com...
The error method is used to produce user-defined compile errors during inline expansion. If an inline expansion results in a call error(msgStr) the compiler produces an error message containing the given msgStr.
error("My error message")
or
error(code"My error of this code: ${println("foo")}")
extension_code
( self: StringContext ) ( args:Returns the string representation of interpolated elaborated code:
Returns the string representation of interpolated elaborated code:
inline def logged(p1: => Any) = {
val c = code"code: $p1"
val res = p1
(c, p1)
}
logged(identity("foo"))
// above is equivalent to:
// ("code: scala.Predef.identity("foo")", identity("foo"))
summonAll
[T] : Widen[T]Given a tuple T, summons each of its member types and returns them in a Tuple.
Given a tuple T, summons each of its member types and returns them in a Tuple.
summonFrom
[T] ( f: Nothing => T ) : TSummons first given matching one of the listed cases. E.g. in
given B { ... }
summonFrom { case given A => 1 case given B => 2 case given C => 3 case _ => 4
Summons first given matching one of the listed cases. E.g. in
given B { ... }
summonFrom { case given A => 1 case given B => 2 case given C => 3 case _ => 4 }
the returned value would be 2
.
summonInline
[T] : TSummon a given value of type T
. Usually, the argument is not passed explicitly.
The summoning is delayed until the call has been fully inlined.
Summon a given value of type T
. Usually, the argument is not passed explicitly.
The summoning is delayed until the call has been fully inlined.