Types

tastyquery.Types$
object Types

Types in the Scala type system.

Every type from the Scala type system is represented in tasty-query as an instance of Type. That abstract class has a number of subtypes for all the possible "shapes" of types.

For example, a reference to the class scala.Int is represented as

TypeRef(PackageRef("scala"), TypeName("Int"))

Type applications of the form C[T1, ..., Tn] are represented as

AppliedType(typeForC, List(typeForT1, ..., typeForTn))

etc.

The full hierarchy is organized as follows:

Type
|
+- WildcardTypeBounds         `? >: L <: H`
|
+- TermType                   a type that can be the type of a term tree
   |
   +- PackageRef              a reference to a package (typically used as `prefix` of `NamedType`s)
   |
   +- MethodicType            types of methods
   |  +- MethodType           `(termParams): resultType`
   |  +- PolyType             `[TypeParams]: resultType`
   |
   +- ValueType               a type that can be the type of a run-time value or type lambda,
      |                       i.e., what the spec calls a regular *type*
      +- NamedType
      |  +- TypeRef           type selection of the form `prefix.T`
      |  +- TermRef           term selection of the form `prefix.t`
      +- AppliedType          `C[T1, ..., Tn]`
      +- ByNameType            type of a by-name parameter `=> T`
      +- ThisType             `C.this`
      +- OrType               `A | B`
      +- AndType              `A & B`
      +- TypeLambda           `[T1, ..., Tn] => R`
      +- TypeParamRef         reference to a type parameter of an enclosing `TypeLambda` or `PolyType`
      +- TermParamRef         reference to a term parameter of an enclosing `MethodType`
      +- AnnotatedType        `T @annotation`
      +- ConstantType         literal singleton type, such as `42` or `"foo"`
      +- MatchType            `T match { case ... }`
      +- RefinedType
      |  +- TypeRefinement    `P { type T >: L <: H }`
      |  +- TermRefinement    `P { val/def t: T }`
      +- RecType              recursive type that introduces a recursive `this` binding
      +- RecThis              recursive reference to the `this` of a `RecType`
      +- SuperType            `super[mix]` (typically used as `prefix` of `NamedType`s)

Common shapes of types can be constructed with properties of Symbols.Symbol and with combinator methods on Type:

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Types.type

Members list

Type members

Classlikes

final class AndType(val first: Type, val second: Type) extends GroundType, ValueType

Attributes

Companion
object
Supertypes
trait ValueType
trait TermType
class GroundType
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
object AndType

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
AndType.type
final class AnnotatedType(val typ: Type, val annotation: Annotation) extends TypeProxy, ValueType

typ @ annot

typ @ annot

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
final class AppliedType(val tycon: Type, val args: List[Type]) extends TypeProxy, ValueType

A type application C[T_1, ..., T_n] Typebounds for wildcard application: C[_], C[?]

A type application C[T_1, ..., T_n] Typebounds for wildcard application: C[_], C[?]

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
sealed trait Binders

Encapsulates the binders associated with a ParamRef.

Encapsulates the binders associated with a ParamRef.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait LambdaType
class MethodType
class PolyType
class TypeLambda
trait TypeBinders
class RecType
Show all
sealed trait BoundType extends Type

Attributes

Supertypes
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
trait ParamRef
class TermParamRef
class TypeParamRef
class RecThis
final class ByNameType(val resultType: Type) extends TypeProxy, ValueType

A by-name parameter type of the form => T.

A by-name parameter type of the form => T.

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
final class ConstantType(val value: Constant) extends TypeProxy, SingletonType

A constant type with single value.

A constant type with single value.

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
abstract class CustomTransientGroundType extends GroundType

Superclass for custom transient ground types used by custom algorithms.

Superclass for custom transient ground types used by custom algorithms.

When writing algorithms that manipulate Types, it is sometimes useful to temporarily store custom data in place of Types. This can be done by defining a subclass of CustomTransientGroundType. At the end of the day, all CustomTransientGroundTypes should have been replaced by proper Types.

The methods of tasty-query never expose instances of CustomTransientGroundType, but you may use it for your own purposes.

When permorming an exhaustive match on all possible Types, you should cover CustomTransientGroundType in a case that always throws (unless you are actually using it for some purposes):

val tpe: Type = ...
tpe match
 case tpe: TypeRef => ...
 ...
 case tpe: CustomTransientGroundType =>
   throw AssertionError(s"Unexpected custom transient ground type $tpe")
end match

Attributes

Supertypes
class GroundType
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ErasedTypeRef

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed abstract class GroundType extends Type

Non-proxy types

Non-proxy types

Attributes

Supertypes
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
class AndType
trait MethodicType
class MethodType
class PolyType
class OrType
class PackageRef
class TypeLambda
Show all
sealed trait LambdaType extends ParamRefBinders, TermType

Attributes

Supertypes
trait TermType
trait Binders
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
sealed abstract class LambdaTypeCompanion[N <: Name, PInfo <: Type | TypeBounds, LT <: LambdaType]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object MethodType.type
object PolyType.type
object TypeLambda.type
final class MatchType(val bound: Type, val scrutinee: Type, val cases: List[MatchTypeCase]) extends TypeProxy, ValueType

selector match { cases }

selector match { cases }

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
final class MatchTypeCase(val paramNames: List[TypeName])(paramTypeBoundsExp: MatchTypeCase => List[TypeBounds], patternExp: MatchTypeCase => Type, resultTypeExp: MatchTypeCase => Type) extends TypeBinders

case pattern => result

case pattern => result

Attributes

Companion
object
Supertypes
trait TypeBinders
trait Binders
class Object
trait Matchable
class Any
Show all
object MatchTypeCase

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
final class MethodType(val paramNames: List[TermName])(paramTypesExp: MethodType => List[Type], resultTypeExp: MethodType => Type) extends MethodicType, TermLambdaType

Attributes

Companion
object
Supertypes
trait LambdaType
trait Binders
trait MethodicType
trait TermType
class GroundType
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
MethodType.type
sealed trait MethodicType extends GroundType, TermType

The type of a def that has at least one (term or type) parameter list.

The type of a def that has at least one (term or type) parameter list.

Partitioned into MethodType and PolyType.

Attributes

Supertypes
trait TermType
class GroundType
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
class MethodType
class PolyType
sealed abstract class NamedType extends TypeProxy, ValueType

Attributes

Companion
object
Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
class TermRef
class TypeRef
object NamedType

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
NamedType.type
object NoPrefix extends Prefix

Attributes

Supertypes
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Self type
NoPrefix.type
final class OrType(val first: Type, val second: Type) extends GroundType, ValueType

Attributes

Companion
object
Supertypes
trait ValueType
trait TermType
class GroundType
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
object OrType

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
OrType.type
final class PackageRef(val fullyQualifiedName: FullyQualifiedName) extends GroundType, TermType

Attributes

Supertypes
trait TermType
class GroundType
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
sealed trait ParamRef extends BoundType

Attributes

Supertypes
trait BoundType
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
sealed trait ParamRefBinders extends Binders

Attributes

Supertypes
trait Binders
class Object
trait Matchable
class Any
Known subtypes
trait LambdaType
class MethodType
class PolyType
class TypeLambda
trait TypeBinders
Show all

Attributes

Companion
object
Supertypes
trait TypeBinders
trait LambdaType
trait Binders
trait MethodicType
trait TermType
class GroundType
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
PolyType.type
sealed abstract class Prefix extends TypeMappable

Attributes

Supertypes
trait TypeMappable
class Object
trait Matchable
class Any
Known subtypes
object NoPrefix.type
class Type
trait BoundType
trait ParamRef
class TermParamRef
class TypeParamRef
class RecThis
class GroundType
class AndType
trait MethodicType
class MethodType
class PolyType
class OrType
class PackageRef
class TypeLambda
trait TermType
trait LambdaType
trait ValueType
class AppliedType
class ByNameType
class MatchType
class NamedType
class TermRef
class TypeRef
class RecType
class RefinedType
class ConstantType
class SkolemType
class SuperType
class ThisType
class TypeProxy
Show all
final case class RealTypeBounds(low: Type, high: Type) extends TypeBounds

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class TypeBounds
trait TypeMappable
class Object
trait Matchable
class Any
Show all
final class RecThis(binder: RecType) extends BoundType, SingletonType

Attributes

Supertypes
trait ValueType
trait TermType
trait BoundType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
final class RecType extends RefinedOrRecType, Binders

Attributes

Companion
object
Supertypes
trait Binders
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
object RecType

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
RecType.type
sealed abstract class RefinedOrRecType extends TypeProxy, ValueType

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
sealed abstract class RefinedType extends RefinedOrRecType

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
sealed trait SingletonType extends TypeProxy, ValueType

A marker trait for types that are guaranteed to contain only a single non-null value (they might contain null in addition).

A marker trait for types that are guaranteed to contain only a single non-null value (they might contain null in addition).

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
class ConstantType
class RecThis
class SkolemType
class SuperType
class TermParamRef
class TermRef
class ThisType
Show all
final class SkolemType(val tpe: Type) extends SingletonType

A skolem type reference with underlying type tpe.

A skolem type reference with underlying type tpe.

For tasty-query, a skolem type is a singleton type of some unknown value of type tpe.

Skolem types do not appear as the types of trees or symbols, but they may be used internally, notably for subtyping and member lookup purposes.

Note that care is needed when creating them, since not all types need to be inhabited.

A skolem is equal to itself and no other type.

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
final class SuperType(val thistpe: ThisType, val explicitSupertpe: Option[Type]) extends TypeProxy, SingletonType

The type of a super reference cls.super where thistpe is cls.this and supertpe is the type of the value referenced by super.

The type of a super reference cls.super where thistpe is cls.this and supertpe is the type of the value referenced by super.

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
sealed trait TermLambdaType extends LambdaType

Attributes

Supertypes
trait LambdaType
trait TermType
trait Binders
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
class MethodType
final class TermParamRef(val binders: TermLambdaType, val paramNum: Int) extends ParamRef, SingletonType

Attributes

Supertypes
trait ValueType
trait TermType
trait ParamRef
trait BoundType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
final class TermRef extends NamedType, SingletonType

The singleton type for path prefix#myDesignator.

The singleton type for path prefix#myDesignator.

Attributes

Companion
object
Supertypes
class NamedType
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
object TermRef

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
TermRef.type
final class TermRefinement(val parent: Type, val isStable: Boolean, val refinedName: TermName, val refinedType: Type) extends RefinedType

A term refinement parent { val/def refinedName: refinedType }.

A term refinement parent { val/def refinedName: refinedType }.

Value parameters

parent

The type being refined

refinedName

The name of the refined term member

refinedType

The refined type for the given term member

Attributes

Supertypes
class RefinedType
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
sealed trait TermType extends Type

A marker trait for types that can be the type of a Trees.TermTree.

A marker trait for types that can be the type of a Trees.TermTree.

The only standard Type that is not a TermType is WildcardTypeBounds.

Partitioned into ValueType, MethodicType and PackageRef.

Attributes

Supertypes
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
trait LambdaType
class MethodType
class PolyType
class TypeLambda
trait MethodicType
class PackageRef
trait ValueType
class AndType
class AppliedType
class ByNameType
class MatchType
class NamedType
class TermRef
class TypeRef
class OrType
class RecType
class RefinedType
class ConstantType
class RecThis
class SkolemType
class SuperType
class TermParamRef
class ThisType
class TypeParamRef
Show all
final class ThisType(val tref: TypeRef) extends SingletonType

Attributes

Supertypes
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
sealed abstract class Type extends Prefix

A type in the Scala type system.

A type in the Scala type system.

Partitioned into GroundType and TypeProxy.

Also partitioned into TermType, WildcardTypeBounds and CustomTransientGroundType.

Attributes

Supertypes
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Known subtypes
trait BoundType
trait ParamRef
class TermParamRef
class TypeParamRef
class RecThis
class GroundType
class AndType
trait MethodicType
class MethodType
class PolyType
class OrType
class PackageRef
class TypeLambda
trait TermType
trait LambdaType
trait ValueType
class AppliedType
class ByNameType
class MatchType
class NamedType
class TermRef
class TypeRef
class RecType
class RefinedType
class ConstantType
class SkolemType
class SuperType
class ThisType
class TypeProxy
Show all
final case class TypeAlias(alias: Type) extends TypeBounds

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class TypeBounds
trait TypeMappable
class Object
trait Matchable
class Any
Show all
sealed trait TypeBinders extends ParamRefBinders

Attributes

Supertypes
trait Binders
class Object
trait Matchable
class Any
Known subtypes
sealed abstract class TypeBounds(val low: Type, val high: Type) extends TypeMappable

Attributes

Supertypes
trait TypeMappable
class Object
trait Matchable
class Any
Known subtypes

A type parameter of a type constructor.

A type parameter of a type constructor.

Type parameters of polymorphic class types are Symbols.ClassTypeParamSymbols. For other type constructors, they are instances of an unspecified subclass.

See Type.typeParams.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
final class TypeLambda(val paramNames: List[TypeName])(paramTypeBoundsExp: TypeLambda => List[TypeBounds], resultTypeExp: TypeLambda => Type) extends GroundType, ValueType, TypeLambdaType

Attributes

Companion
object
Supertypes
trait TypeBinders
trait LambdaType
trait Binders
trait ValueType
trait TermType
class GroundType
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
TypeLambda.type
sealed trait TypeLambdaType extends LambdaType, TypeBinders

Attributes

Supertypes
trait TypeBinders
trait LambdaType
trait TermType
trait Binders
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
class PolyType
class TypeLambda

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object PolyType.type
object TypeLambda.type
sealed trait TypeMappable

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Prefix
object NoPrefix.type
class Type
trait BoundType
trait ParamRef
class TermParamRef
class TypeParamRef
class RecThis
class GroundType
class AndType
trait MethodicType
class MethodType
class PolyType
class OrType
class PackageRef
class TypeLambda
trait TermType
trait LambdaType
trait ValueType
class AppliedType
class ByNameType
class MatchType
class NamedType
class TermRef
class TypeRef
class RecType
class RefinedType
class ConstantType
class SkolemType
class SuperType
class ThisType
class TypeProxy
class TypeBounds
class TypeAlias
Show all
final class TypeParamRef(val binders: TypeBinders, val paramNum: Int) extends TypeProxy, ValueType, ParamRef

Attributes

Supertypes
trait ParamRef
trait BoundType
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
sealed abstract class TypeProxy extends Type

Type proxies. Each implementation is expected to redefine the underlying method.

Type proxies. Each implementation is expected to redefine the underlying method.

Attributes

Supertypes
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
class AppliedType
class ByNameType
class ConstantType
class MatchType
class NamedType
class TermRef
class TypeRef
class RecType
class RefinedType
class RecThis
class SkolemType
class SuperType
class TermParamRef
class ThisType
class TypeParamRef
Show all
final class TypeRef extends NamedType

Attributes

Companion
object
Supertypes
class NamedType
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
object TypeRef

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
TypeRef.type
final class TypeRefinement(val parent: Type, val refinedName: TypeName, val refinedBounds: TypeBounds) extends RefinedType

A type refinement parent { type refinedName <:> refinedBounds }.

A type refinement parent { type refinedName <:> refinedBounds }.

Value parameters

parent

The type being refined

refinedBounds

The refined bounds for the given type member

refinedName

The name of the refined type member

Attributes

Supertypes
class RefinedType
trait ValueType
trait TermType
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
sealed trait ValueType extends TermType

A marker trait for the type of values or type lambdas.

A marker trait for the type of values or type lambdas.

In other words, what the spec calls a regular type.

Most TermTypes are ValueType. The only exceptions are MethodicType and PackageRef.

Attributes

Supertypes
trait TermType
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all
Known subtypes
class AndType
class AppliedType
class ByNameType
class MatchType
class NamedType
class TermRef
class TypeRef
class OrType
class RecType
class RefinedType
class ConstantType
class RecThis
class SkolemType
class SuperType
class TermParamRef
class ThisType
class TypeLambda
class TypeParamRef
Show all
final class WildcardTypeBounds(val bounds: TypeBounds) extends TypeProxy

Attributes

Companion
object
Supertypes
class TypeProxy
class Type
class Prefix
trait TypeMappable
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type