Scala Reflection Library 2.13.16 - scala.reflect.api.Exprs.Expr
Keywords: Scala Reflection Library 2.13.16 scala.reflect.api.Exprs.Expr

Scala Reflection Library2.13.16 < Back


# Packages

-  package root
  Definition Classes
    root
-  package scala
  Definition Classes
    root
-  package reflect
  Definition Classes
    scala
-  package api

  EXPERIMENTAL

  EXPERIMENTAL

  The Scala Reflection API (located in scala-reflect.jar).

  In Scala 2.10.0, the Scala Reflection API and its implementation have an "experimental" status. This means that the API and the docs are not complete and can be changed in binary- and source-incompatible manner in 2.10.1. This also means that the implementation has some known issues.

  The following types are the backbone of the Scala Reflection API, and serve as a good starting point for information about Scala Reflection:

  - scala.reflect.api.Symbols
  - scala.reflect.api.Types
  - scala.reflect.api.Mirrors
  - scala.reflect.api.Universe

  For more information about Scala Reflection, see the Reflection Guide

  Definition Classes
    reflect
-  trait Exprs extends AnyRef

  EXPERIMENTAL

  EXPERIMENTAL

  A trait that defines strongly-typed tree wrappers and operations on them for use in Scala Reflection.

  `Expr` wraps an abstract syntax tree (scala.reflect.api.Trees#Tree) and tags it with its type (scala.reflect.api.Types#Type).

  Usually `Expr`s are created via scala.reflect.api.Universe#reify, in which case a compiler produces a scala.reflect.api.TreeCreator for the provided expression and also creates a complementary scala.reflect.api.TypeTags#WeakTypeTag that corresponds to the type of that expression.

  `Expr`s can also be created manually via the `Expr` companion object, but then the burden of providing a `TreeCreator` lies on the programmer. Compile-time reflection via macros, as described in scala.reflect.macros.Aliases, provides an easier way to instantiate exprs manually. Manual creation, however, is very rarely needed when working with runtime reflection.

  `Expr` can be migrated from one mirror to another by using the `in` method. Migration means that all symbolic references to classes/objects/packages in the expression are re-resolved within the new mirror (typically using that mirror's classloader). The default universe of an `Expr` is typically scala.reflect.runtime#universe, the default mirror is typically scala.reflect.runtime#currentMirror.

  Definition Classes
    api
- Expr

t

scala.reflect.api.Exprs

# Expr

###
Companion object Expr

#### trait Expr[+T] extends Equals with Serializable

Expr wraps an abstract syntax tree and tags it with its type. The main source of information about exprs is the scala.reflect.api.Exprs page.

Source
  Exprs.scala

Linear Supertypes
java.io.Serializable, Equals, AnyRef, Any
Type Hierarchy

Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. Expr
2. Serializable
3. Equals
4. AnyRef
5. Any

Implicitly

1. by any2stringadd
2. by StringFormat
3. by Ensuring
4. by ArrowAssoc

1. Hide All
2. Show All

Visibility

1. Public
2. Protected

### Abstract Value Members

1.  abstract def actualType: Universe.Type

   Type of the wrapped expression tree as found in the underlying tree.

2.  abstract def in[U <: Universe with Singleton](otherMirror: Mirror[U]): in.U.Expr[T]

   Migrates the expression into another mirror, jumping into a different universe if necessary.

3.  abstract val mirror: Universe.Mirror

   Underlying mirror of this expr.

4.  abstract def splice: T

   A dummy method to mark expression splicing in reification.

   A dummy method to mark expression splicing in reification.

   It should only be used within a `reify` call, which eliminates the `splice` call and embeds the wrapped tree into the reified surrounding expression. If used alone `splice` throws an exception when called at runtime.

   If you want to use an Expr in reification of some Scala code, you need to splice it in. For an expr of type `Expr[T]`, where `T` has a method `foo`, the following code

       reify{ expr.splice.foo }

   uses splice to turn an expr of type Expr[T] into a value of type T in the context of `reify`.

   It is equivalent to

       Select( expr.tree, TermName("foo") )

   The following example code however does not compile

       reify{ expr.foo }

   because expr of type Expr[T] itself does not have a method foo.

   Annotations
     @compileTimeOnly("splice must be enclosed within a reify {} block")
5.  abstract def staticType: Universe.Type

   Type of the wrapped expression tree as provided during creation.

   Type of the wrapped expression tree as provided during creation.

   When exprs are created by the compiler, `staticType` represents a statically known type of the tree as calculated at that point by the compiler.

6.  abstract def tree: Universe.Tree

   The Scala abstract syntax tree representing the wrapped expression.

7.  abstract val value: T

   A dummy value to denote cross-stage path-dependent type dependencies.

   A dummy value to denote cross-stage path-dependent type dependencies.

   For example for the following macro definition:

       class X { type T }
       object Macros { def foo(x: X): x.T = macro Impls.foo_impl }

   The corresponding macro implementation should have the following signature (note how the return type denotes path-dependency on x):

       object Impls { def foo_impl(c: Context)(x: c.Expr[X]): c.Expr[x.value.T] = ... }

   Annotations
     @compileTimeOnly("cannot use value except for signatures of macro implementations")

### Concrete Value Members

1.  final def !=(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
2.  final def ##: Int
   Definition Classes
     AnyRef → Any
3.  def +(other: String): String
   Implicit
     This member is added by an implicit conversion from Universe.Expr[T] toany2stringadd[Universe.Expr[T]] performed by method any2stringadd in scala.Predef.
   Definition Classes
     any2stringadd
4.  def ->[B](y: B): (Universe.Expr[T], B)
   Implicit
     This member is added by an implicit conversion from Universe.Expr[T] toArrowAssoc[Universe.Expr[T]] performed by method ArrowAssoc in scala.Predef.
   Definition Classes
     ArrowAssoc
   Annotations
     @inline()
5.  final def ==(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
6.  final def asInstanceOf[T0]: T0
   Definition Classes
     Any
7.  def canEqual(x: Any): Boolean
   Definition Classes
     Expr → Equals
8.  def clone(): AnyRef
   Attributes
     protected[lang]
   Definition Classes
     AnyRef
   Annotations
     @throws(classOf[java.lang.CloneNotSupportedException]) @native()
9.  def ensuring(cond: (Universe.Expr[T]) => Boolean, msg: => Any): Universe.Expr[T]
   Implicit
     This member is added by an implicit conversion from Universe.Expr[T] toEnsuring[Universe.Expr[T]] performed by method Ensuring in scala.Predef.
   Definition Classes
     Ensuring
10.  def ensuring(cond: (Universe.Expr[T]) => Boolean): Universe.Expr[T]
    Implicit
      This member is added by an implicit conversion from Universe.Expr[T] toEnsuring[Universe.Expr[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
      Ensuring
11.  def ensuring(cond: Boolean, msg: => Any): Universe.Expr[T]
    Implicit
      This member is added by an implicit conversion from Universe.Expr[T] toEnsuring[Universe.Expr[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
      Ensuring
12.  def ensuring(cond: Boolean): Universe.Expr[T]
    Implicit
      This member is added by an implicit conversion from Universe.Expr[T] toEnsuring[Universe.Expr[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
      Ensuring
13.  final def eq(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
14.  def equals(x: Any): Boolean
    Definition Classes
      Expr → Equals → AnyRef → Any
15.  def finalize(): Unit
    Attributes
      protected[lang]
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.Throwable])
16.  final def getClass(): Class[_ <: AnyRef]
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
17.  def hashCode(): Int
    Definition Classes
      Expr → AnyRef → Any
18.  final def isInstanceOf[T0]: Boolean
    Definition Classes
      Any
19.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
20.  final def notify(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
21.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
22.  final def synchronized[T0](arg0: => T0): T0
    Definition Classes
      AnyRef
23.  def toString(): String
    Definition Classes
      Expr → AnyRef → Any
24.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException])
25.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException])
26.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException]) @native()

### Deprecated Value Members

1.  def formatted(fmtstr: String): String
   Implicit
     This member is added by an implicit conversion from Universe.Expr[T] toStringFormat[Universe.Expr[T]] performed by method StringFormat in scala.Predef.
   Definition Classes
     StringFormat
   Annotations
     @deprecated @inline()
   Deprecated

     (Since version 2.12.16) Use `formatString.format(value)` instead of `value.formatted(formatString)`, or use the `f""` string interpolator. In Java 15 and later, `formatted` resolves to the new method in String which has reversed parameters.

2.  def →[B](y: B): (Universe.Expr[T], B)
   Implicit
     This member is added by an implicit conversion from Universe.Expr[T] toArrowAssoc[Universe.Expr[T]] performed by method ArrowAssoc in scala.Predef.
   Definition Classes
     ArrowAssoc
   Annotations
     @deprecated
   Deprecated

     (Since version 2.13.0) Use `->` instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

### Inherited from java.io.Serializable

### Inherited from Equals

### Inherited from AnyRef

### Inherited from Any

### Inherited by implicit conversion any2stringadd fromUniverse.Expr[T] to any2stringadd[Universe.Expr[T]]

### Inherited by implicit conversion StringFormat fromUniverse.Expr[T] to StringFormat[Universe.Expr[T]]

### Inherited by implicit conversion Ensuring fromUniverse.Expr[T] to Ensuring[Universe.Expr[T]]

### Inherited by implicit conversion ArrowAssoc fromUniverse.Expr[T] to ArrowAssoc[Universe.Expr[T]]

### Ungrouped