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:
- typeSymbol.staticRef constructs a
TypeRef
to the given statictypeSymbol
- termSymbol.staticRef constructs a
TermRef
to the given statictermSymbol
- tpe1.appliedTo(tpe2) constructs the application
tpe1[tpe2]
(there is an overload that accepts a list of type arguments) - tpe1 | tpe2 constructs a union type
- tpe1 & tpe2 constructs an intersection type
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Types.type
Members list
Type members
Classlikes
Attributes
- Companion
- object
- Supertypes
-
trait ValueTypetrait TermTypeclass GroundTypeclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
A type application C[T_1, ..., T_n]
Typebounds for wildcard application: C[_], C[?]
Encapsulates the binders associated with a ParamRef.
Encapsulates the binders associated with a ParamRef.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait ParamRefBinderstrait LambdaTypetrait TermLambdaTypeclass MethodTypetrait TypeLambdaTypeclass PolyTypeclass TypeLambdatrait TypeBindersclass MatchTypeCaseclass RecTypeShow all
Attributes
- Supertypes
- Known subtypes
A constant type with single value
.
A constant type with single value
.
Attributes
- Supertypes
-
trait SingletonTypetrait ValueTypetrait TermTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
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 Type
s, it is sometimes useful to temporarily store custom data in place of Type
s. This can be done by defining a subclass of CustomTransientGroundType
. At the end of the day, all CustomTransientGroundType
s should have been replaced by proper Type
s.
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 Type
s, 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 GroundTypeclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- object
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- enum
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
ErasedTypeRef.type
Non-proxy types
Non-proxy types
Attributes
- Supertypes
- Known subtypes
-
class AndTypetrait MethodicTypeclass MethodTypeclass PolyTypeclass OrTypeclass PackageRefclass TypeLambdaShow all
Attributes
- Supertypes
-
trait TermTypetrait ParamRefBinderstrait Bindersclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
- Known subtypes
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object MethodType.typeclass TypeLambdaTypeCompanion[LT]object PolyType.typeobject TypeLambda.type
case pattern
=> result
case pattern
=> result
Attributes
- Companion
- object
- Supertypes
-
trait TypeBinderstrait ParamRefBinderstrait Bindersclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
MatchTypeCase.type
Attributes
- Companion
- object
- Supertypes
-
trait TermLambdaTypetrait LambdaTypetrait ParamRefBinderstrait Binderstrait MethodicTypetrait TermTypeclass GroundTypeclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
- Self type
-
MethodType.type
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 TermTypeclass GroundTypeclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class MethodTypeclass PolyType
Attributes
- Supertypes
- Self type
-
NoPrefix.type
Attributes
- Companion
- object
- Supertypes
-
trait ValueTypetrait TermTypeclass GroundTypeclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait TermTypeclass GroundTypeclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait BoundTypeclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class TermParamRefclass TypeParamRef
Attributes
- Supertypes
- Known subtypes
-
trait LambdaTypetrait TermLambdaTypeclass MethodTypetrait TypeLambdaTypeclass PolyTypeclass TypeLambdatrait TypeBindersclass MatchTypeCaseShow all
Attributes
- Companion
- object
- Supertypes
-
trait TypeLambdaTypetrait TypeBinderstrait LambdaTypetrait ParamRefBinderstrait Binderstrait MethodicTypetrait TermTypeclass GroundTypeclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
Attributes
- Supertypes
- Known subtypes
-
object NoPrefix.typeclass Typetrait BoundTypetrait ParamRefclass TermParamRefclass TypeParamRefclass RecThisclass GroundTypeclass AndTypetrait MethodicTypeclass MethodTypeclass PolyTypeclass OrTypeclass PackageRefclass TypeLambdatrait TermTypetrait LambdaTypetrait TermLambdaTypetrait TypeLambdaTypetrait ValueTypeclass AnnotatedTypeclass AppliedTypeclass ByNameTypeclass MatchTypeclass NamedTypeclass TermRefclass TypeRefclass RefinedOrRecTypeclass RecTypeclass RefinedTypeclass TermRefinementclass TypeRefinementtrait SingletonTypeclass ConstantTypeclass SkolemTypeclass SuperTypeclass ThisTypeclass TypeProxyclass WildcardTypeBoundsShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass TypeBoundstrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait SingletonTypetrait ValueTypetrait TermTypetrait BoundTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- object
- Supertypes
-
trait Bindersclass RefinedOrRecTypetrait ValueTypetrait TermTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
- Known subtypes
Attributes
- Supertypes
-
class RefinedOrRecTypetrait ValueTypetrait TermTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class TermRefinementclass TypeRefinement
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
- Known subtypes
-
class ConstantTypeclass RecThisclass SkolemTypeclass SuperTypeclass TermParamRefclass TermRefclass ThisTypeShow all
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 SingletonTypetrait ValueTypetrait TermTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
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 SingletonTypetrait ValueTypetrait TermTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait LambdaTypetrait TermTypetrait ParamRefBinderstrait Bindersclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class MethodType
Attributes
- Supertypes
-
trait SingletonTypetrait ValueTypetrait TermTypetrait ParamReftrait BoundTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
The singleton type for path prefix#myDesignator.
The singleton type for path prefix#myDesignator.
Attributes
- Companion
- object
- Supertypes
-
trait SingletonTypeclass NamedTypetrait ValueTypetrait TermTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
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 RefinedTypeclass RefinedOrRecTypetrait ValueTypetrait TermTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
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
- Known subtypes
-
trait LambdaTypetrait TermLambdaTypeclass MethodTypetrait TypeLambdaTypeclass PolyTypeclass TypeLambdatrait MethodicTypeclass PackageReftrait ValueTypeclass AndTypeclass AnnotatedTypeclass AppliedTypeclass ByNameTypeclass MatchTypeclass NamedTypeclass TermRefclass TypeRefclass OrTypeclass RefinedOrRecTypeclass RecTypeclass RefinedTypeclass TermRefinementclass TypeRefinementtrait SingletonTypeclass ConstantTypeclass RecThisclass SkolemTypeclass SuperTypeclass TermParamRefclass ThisTypeclass TypeParamRefShow all
Attributes
- Supertypes
-
trait SingletonTypetrait ValueTypetrait TermTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
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
- Known subtypes
-
trait BoundTypetrait ParamRefclass TermParamRefclass TypeParamRefclass RecThisclass GroundTypeclass AndTypetrait MethodicTypeclass MethodTypeclass PolyTypeclass OrTypeclass PackageRefclass TypeLambdatrait TermTypetrait LambdaTypetrait TermLambdaTypetrait TypeLambdaTypetrait ValueTypeclass AnnotatedTypeclass AppliedTypeclass ByNameTypeclass MatchTypeclass NamedTypeclass TermRefclass TypeRefclass RefinedOrRecTypeclass RecTypeclass RefinedTypeclass TermRefinementclass TypeRefinementtrait SingletonTypeclass ConstantTypeclass SkolemTypeclass SuperTypeclass ThisTypeclass TypeProxyclass WildcardTypeBoundsShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass TypeBoundstrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
- Known subtypes
Attributes
- Supertypes
- Known subtypes
-
class RealTypeBoundsclass TypeAlias
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 Objecttrait Matchableclass Any
- Known subtypes
-
class ClassTypeParamSymbol
Attributes
- Companion
- object
- Supertypes
-
trait TypeLambdaTypetrait TypeBinderstrait LambdaTypetrait ParamRefBinderstrait Binderstrait ValueTypetrait TermTypeclass GroundTypeclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
TypeLambda.type
Attributes
- Supertypes
-
trait TypeBinderstrait LambdaTypetrait TermTypetrait ParamRefBinderstrait Bindersclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class PolyTypeclass TypeLambda
Attributes
- Supertypes
- Known subtypes
-
object PolyType.typeobject TypeLambda.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class Prefixobject NoPrefix.typeclass Typetrait BoundTypetrait ParamRefclass TermParamRefclass TypeParamRefclass RecThisclass GroundTypeclass AndTypetrait MethodicTypeclass MethodTypeclass PolyTypeclass OrTypeclass PackageRefclass TypeLambdatrait TermTypetrait LambdaTypetrait TermLambdaTypetrait TypeLambdaTypetrait ValueTypeclass AnnotatedTypeclass AppliedTypeclass ByNameTypeclass MatchTypeclass NamedTypeclass TermRefclass TypeRefclass RefinedOrRecTypeclass RecTypeclass RefinedTypeclass TermRefinementclass TypeRefinementtrait SingletonTypeclass ConstantTypeclass SkolemTypeclass SuperTypeclass ThisTypeclass TypeProxyclass WildcardTypeBoundsclass TypeBoundsclass RealTypeBoundsclass TypeAliasShow all
Type proxies. Each implementation is expected to redefine the underlying
method.
Type proxies. Each implementation is expected to redefine the underlying
method.
Attributes
- Supertypes
- Known subtypes
-
class AnnotatedTypeclass AppliedTypeclass ByNameTypeclass ConstantTypeclass MatchTypeclass NamedTypeclass TermRefclass TypeRefclass RefinedOrRecTypeclass RecTypeclass RefinedTypeclass TermRefinementclass TypeRefinementtrait SingletonTypeclass RecThisclass SkolemTypeclass SuperTypeclass TermParamRefclass ThisTypeclass TypeParamRefclass WildcardTypeBoundsShow all
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 RefinedTypeclass RefinedOrRecTypetrait ValueTypetrait TermTypeclass TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
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 TermTypeclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class AndTypeclass AnnotatedTypeclass AppliedTypeclass ByNameTypeclass MatchTypeclass NamedTypeclass TermRefclass TypeRefclass OrTypeclass RefinedOrRecTypeclass RecTypeclass RefinedTypeclass TermRefinementclass TypeRefinementtrait SingletonTypeclass ConstantTypeclass RecThisclass SkolemTypeclass SuperTypeclass TermParamRefclass ThisTypeclass TypeLambdaclass TypeParamRefShow all
Attributes
- Companion
- object
- Supertypes
-
class TypeProxyclass Typeclass Prefixtrait TypeMappableclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
WildcardTypeBounds.type