Test two objects for inequality.
Test two objects for inequality.
true
if !(this == that), false otherwise.
Equivalent to x.hashCode
except for boxed numeric types and null
.
Equivalent to x.hashCode
except for boxed numeric types and null
.
For numerics, it returns a hash value which is consistent
with value equality: if two value type instances compare
as true, then ## will produce the same hash value for each
of them.
For null
returns a hashcode where null.hashCode
throws a
NullPointerException
.
a hash value consistent with ==
The expression x == that
is equivalent to if (x eq null) that eq null else x.equals(that)
.
The expression x == that
is equivalent to if (x eq null) that eq null else x.equals(that)
.
true
if the receiver object is equivalent to the argument; false
otherwise.
A replacement for the standard typer's adapt method.
Try to apply an implicit conversion to qual
to that it contains
a method name
which can be applied to arguments args
with expected type pt
.
Try to apply an implicit conversion to qual
to that it contains
a method name
which can be applied to arguments args
with expected type pt
.
If pt
is defined, there is a fallback to try again with pt = ?.
This helps avoiding propagating result information too far and solves
#1756.
If no conversion is found, return qual
unchanged.
Try to apply an implicit conversion to qual
so that it contains
a method name
.
Try to apply an implicit conversion to qual
so that it contains
a method name
. If that's ambiguous try taking arguments into
account using adaptToArguments
.
Try to apply an implicit conversion to qual
to that it contains a
member name
of arbitrary type.
Try to apply an implicit conversion to qual
to that it contains a
member name
of arbitrary type.
If no conversion is found, return qual
unchanged.
Adapt tree
to expected type pt
.
Adapt tree
to expected type pt
.
the given tree
the expected type
the adapted tree
Find implicit arguments and pass them to given tree.
Find implicit arguments and pass them to given tree.
Cast the receiver object to be of type T0
.
Cast the receiver object to be of type T0
.
Note that the success of a cast at runtime is modulo Scala's erasure semantics.
Therefore the expression 1.asInstanceOf[String]
will throw a ClassCastException
at
runtime, while the expression List(1).asInstanceOf[List[String]]
will not.
In the latter example, because the type argument is erased as part of compilation it is
not possible to check whether the contents of the list are of the requested type.
the receiver object.
ClassCastException
if the receiver object is not an instance of the erasure of type T0
.
Overridden to false in scaladoc and/or interactive.
Overridden to false in scaladoc and/or interactive.
Generate a synthetic cast operation from tree.tpe to pt.
Generate a synthetic cast operation from tree.tpe to pt.
Check that tpt
refers to a non-refinement class type
Check that tpt
refers to a non-refinement class type
Check whether feature given by featureTrait
is enabled.
Check whether feature given by featureTrait
is enabled.
If it is not, issue an error or a warning depending on whether the feature is required.
A string expression that is substituted for "#" in the feature description string
When set, feature check is run immediately, otherwise it is run at the end of the typechecking run for the enclosing unit. This is done to avoid potential cyclic reference errors by implicits that are forced too early.
if feature check is run immediately: true if feature is enabled, false otherwise if feature check is delayed or suppressed because we are past typer: true
Check if a structurally defined method violates implementation restrictions.
Check if a structurally defined method violates implementation restrictions. A method cannot be called if it is a non-private member of a refinement type and if its parameter's types are any of:
Check that type of given tree does not contain local or private components.
Check that type of given tree does not contain local or private components.
Check that type tp
is not a subtype of itself.
Check that type tp
is not a subtype of itself.
Check that tpt
refers to a class type with a stable prefix.
Check that tpt
refers to a class type with a stable prefix.
Create a copy of the receiver object.
Create a copy of the receiver object.
The default implementation of the clone
method is platform dependent.
a copy of the receiver object.
not specified by SLS as a member of AnyRef
Enter all aliases of local parameter accessors.
Enter all aliases of local parameter accessors.
The typer for an expression, depending on where we are.
The typer for an expression, depending on where we are. If we are before a superclass call, this is a typer over a constructor context; otherwise it is the current typer.
Returns Some(msg) if the given tree is untyped apparently due to a cyclic reference, and None otherwise.
Returns Some(msg) if the given tree is untyped apparently due to a cyclic reference, and None otherwise.
Tests whether the argument (that
) is a reference to the receiver object (this
).
Tests whether the argument (that
) is a reference to the receiver object (this
).
The eq
method implements an equivalence relation on
non-null instances of AnyRef
, and has three additional properties:
x
and y
of type AnyRef
, multiple invocations of
x.eq(y)
consistently returns true
or consistently returns false
.x
of type AnyRef
, x.eq(null)
and null.eq(x)
returns false
.null.eq(null)
returns true
. When overriding the equals
or hashCode
methods, it is important to ensure that their behavior is
consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2
), they
should be equal to each other (o1 == o2
) and they should hash to the same value (o1.hashCode == o2.hashCode
).
true
if the argument is a reference to the receiver object; false
otherwise.
The equality method for reference types.
Called by the garbage collector on the receiver object when there are no more references to the object.
Called by the garbage collector on the receiver object when there are no more references to the object.
The details of when and if the finalize
method is invoked, as
well as the interaction between finalize
and non-local returns
and exceptions, are all platform dependent.
not specified by SLS as a member of AnyRef
In order to override this in the TreeCheckers Typer so synthetics aren't re-added all the time, it is exposed here the module/class typing methods go through it.
In order to override this in the TreeCheckers Typer so synthetics aren't re-added all the time, it is exposed here the module/class typing methods go through it. ...but it turns out it's also the ideal spot for namer/typer coordination for the tricky method synthesis scenarios, so we'll make it that.
A representation that corresponds to the dynamic class of the receiver object.
A representation that corresponds to the dynamic class of the receiver object.
The nature of the representation is platform dependent.
a representation that corresponds to the dynamic class of the receiver object.
not specified by SLS as a member of AnyRef
The hashCode method for reference types.
Infer an implicit conversion (view
) between two types.
Infer an implicit conversion (view
) between two types.
The tree which needs to be converted.
The source type of the conversion
The target type of the conversion
Should ambiguous implicit errors be reported? False iff we search for a view to find out whether one type is coercible to another.
Should ambiguous and divergent implicit errors that were buffered during the inference of a view be put into the original buffer. False iff we don't care about them.
If the expected type is Unit: try instantiating type arguments with expected type Unit, but if that fails, try again with pt = WildcardType and discard the expression.
If the expected type is Unit: try instantiating type arguments with expected type Unit, but if that fails, try again with pt = WildcardType and discard the expression.
Test whether the dynamic type of the receiver object is T0
.
Test whether the dynamic type of the receiver object is T0
.
Note that the result of the test is modulo Scala's erasure semantics.
Therefore the expression 1.isInstanceOf[String]
will return false
, while the
expression List(1).isInstanceOf[List[String]]
will return true
.
In the latter example, because the type argument is erased as part of compilation it is
not possible to check whether the contents of the list are of the specified type.
true
if the receiver object is an instance of erasure of type T0
; false
otherwise.
Is tree
a block created by a named application?
Is tree
a block created by a named application?
A symbol is stale if it is toplevel, to be loaded from a classfile, and the classfile is produced from a sourcefile which is compiled in the current run.
A symbol is stale if it is toplevel, to be loaded from a classfile, and the classfile is produced from a sourcefile which is compiled in the current run.
The typer for a label definition.
The typer for a label definition. If this is part of a template we first have to enter the label definition.
This file will be the death of me.
This file will be the death of me.
The member with given name of given qualifier tree
The member with given name of given qualifier tree
Equivalent to !(this eq that)
.
Equivalent to !(this eq that)
.
true
if the argument is not a reference to the receiver object; false
otherwise.
Does function need to be instantiated, because a missing parameter in an argument closure overlaps with an uninstantiated formal?
Does function need to be instantiated, because a missing parameter in an argument closure overlaps with an uninstantiated formal?
Wakes up a single thread that is waiting on the receiver object's monitor.
Wakes up a single thread that is waiting on the receiver object's monitor.
not specified by SLS as a member of AnyRef
Wakes up all threads that are waiting on the receiver object's monitor.
Wakes up all threads that are waiting on the receiver object's monitor.
not specified by SLS as a member of AnyRef
Compute an existential type from raw hidden symbols syms
and type tp
Compute an existential type from raw hidden symbols syms
and type tp
convert local symbols and skolems to existentials
convert local symbols and skolems to existentials
The qualifying class
of a this or super with prefix qual
.
The qualifying class
of a this or super with prefix qual
.
packageOk is equal false when qualifying class symbol
Is symbol defined and not stale?
Is symbol defined and not stale?
Report a type error.
Report a type error.
The position where to report the error
The exception that caused the error
Finds in scope or materializes a ClassTag.
Finds in scope or materializes a ClassTag. Should be used instead of ClassManifest every time compiler needs to persist an erasure.
Once upon a time, we had an ErasureTag
which was to ClassTag
the same that WeakTypeTag
is for TypeTag
.
However we found out that we don't really need this concept, so it got removed.
Position for error reporting. Please, provide meaningful value.
Type we're looking a ClassTag for, e.g. resolveClassTag(pos, IntTpe) will look for ClassTag[Int].
If true (default) then the resolver is allowed to launch materialization macros when there's no class tag in scope. If false then materialization macros are prohibited from running.
Tree that represents an scala.reflect.ClassTag
for tp
if everything is okay.
EmptyTree if the result contains unresolved (i.e. not spliced) type parameters and abstract type members.
EmptyTree if allowMaterialization
is false, and there is no class tag in scope.
Finds in scope or materializes an WeakTypeTag (if concrete
is false) or a TypeTag (if concrete
is true).
Finds in scope or materializes an WeakTypeTag (if concrete
is false) or a TypeTag (if concrete
is true).
Position for error reporting. Please, provide meaningful value.
Prefix that represents a universe this type tag will be bound to.
If pre
is set to NoType
, then any type tag in scope will do, regardless of its affiliation.
If pre
is set to NoType
, and tag resolution involves materialization, then mkRuntimeUniverseRef
will be used.
Type we're looking a TypeTag for, e.g. resolveTypeTag(pos, mkRuntimeUniverseRef, IntTpe, false) will look for scala.reflect.runtime.universe.TypeTag[Int].
If true then the result must not contain unresolved (i.e. not spliced) type parameters and abstract type members. If false then the function will always succeed (abstract types will be reified as free types).
If true (default) then the resolver is allowed to launch materialization macros when there's no type tag in scope. If false then materialization macros are prohibited from running.
Tree that represents a scala.reflect.TypeTag
for tp
if everything is okay.
EmptyTree if concrete
is true and the result contains unresolved (i.e. not spliced) type parameters and abstract type members.
EmptyTree if allowMaterialization
is false, and there is no array tag in scope.
For flatMapping a list of trees when you want the DocDefs and Annotated to be transparent.
For flatMapping a list of trees when you want the DocDefs and Annotated to be transparent.
Convert a SAM type to the corresponding FunctionType, extrapolating BoundedWildcardTypes in the process (no type precision is lost by the extrapolation, but this facilitates dealing with the types arising from Java's use-site variance).
Convert a SAM type to the corresponding FunctionType, extrapolating BoundedWildcardTypes in the process (no type precision is lost by the extrapolation, but this facilitates dealing with the types arising from Java's use-site variance).
Post-process an identifier or selection node, performing the following:
Post-process an identifier or selection node, performing the following:
synthesize and type check a PartialFunction implementation based on the match in tree
synthesize and type check a PartialFunction implementation based on the match in tree
param => sel match { cases }
becomes:
new AbstractPartialFunction[$argTp, $matchResTp] { def applyOrElse[A1 <: $argTp, B1 >: $matchResTp]($param: A1, default: A1 => B1): B1 = $selector match { $cases } def isDefinedAt(x: $argTp): Boolean = $selector match { $casesTrue } }
TODO: it would be nicer to generate the tree specified above at once and type it as a whole, there are two gotchas:
this
in cases
or sel
must resolve to the this of the class originally enclosing the match,
not of the anonymous partial function subclassan alternative TODO: add partial function AST node or equivalent and get rid of this synthesis --> do everything in uncurry (or later) however, note that pattern matching codegen is designed to run *before* uncurry
Synthesize and type check the implementation of a type with a Single Abstract Method
Synthesize and type check the implementation of a type with a Single Abstract Method
{ (p1: T1, ..., pN: TN) => body } : S
expands to (where S
is the expected type that defines a single abstract method named apply
)
{
def apply$body(p1: T1, ..., pN: TN): T = body
new S {
def apply(p1: T1', ..., pN: TN'): T' = apply$body(p1,..., pN)
}
}
If 'T' is not fully defined, it is inferred by type checking
apply$body
without a result type before type checking the block.
The method's inferred result type is used instead of T
. [See test/files/pos/sammy_poly.scala]
The apply
method is identified by the argument sam
; S
corresponds to the argument samClassTp
,
and resPt
is derived from samClassTp
-- it may be fully defined, or not...
If it is not fully defined, we derive samClassTpFullyDefined
by inferring any unknown type parameters.
The types T1' ... TN' and T' are derived from the method signature of the sam method,
as seen from the fully defined samClassTpFullyDefined
.
The function's body is put in a method outside of the class definition to enforce scoping.
S's members should not be in scope in body
.
The restriction on implicit arguments (neither S's constructor, nor sam may take an implicit argument list),
is largely to keep the implementation of type inference (the computation of samClassTpFullyDefined
) simple.
NOTE: it would be nicer to not have to type check apply$body
separately when T
is not fully defined.
However T must be fully defined before we type the instantiation, as it'll end up as a parent type,
which must be fully defined. Would be nice to have some kind of mechanism to insert type vars in a block of code,
and have the instantiation of the first occurrence propagate to the rest of the block.
TODO: by-name params scala> trait LazySink { def accept(a: => Any): Unit } defined trait LazySink
scala> val f: LazySink = (a) => (a, a) f: LazySink = $anonfun$1@1fb26910
scala> f(println("!")) <console>:10: error: LazySink does not take parameters f(println("!")) ^
scala> f.accept(println("!")) ! !
Creates a String representation of this object.
Creates a String representation of this object. The default representation is platform dependent. On the java platform it is the concatenation of the class name, "@", and the object's hashcode in hexadecimal.
a String representation of the object.
Types expression tree
with given prototype pt
.
Types expression tree
with given prototype pt
.
Types expression or definition tree
.
Types expression or definition tree
.
A replacement for the standard typer's typed1
method.
Convert an annotation constructor call into an AnnotationInfo.
Convert an annotation constructor call into an AnnotationInfo.
Types a higher-kinded type tree -- pt denotes the expected kind and must be one of Kind.WildCard
and Kind.FromParams
Types a higher-kinded type tree -- pt denotes the expected kind and must be one of Kind.WildCard
and Kind.FromParams
Remove definition annotations from modifiers (they have been saved
into the symbol's annotations
in the type completer / namer)
Remove definition annotations from modifiers (they have been saved
into the symbol's annotations
in the type completer / namer)
However reification does need annotation definitions to proceed. Unfortunately, AnnotationInfo doesn't provide enough info to reify it in general case. The biggest problem is with the "atp: Type" field, which cannot be reified in some situations that involve locally defined annotations. See more about that in Reifiers.scala.
That's why the original tree gets saved into original
field of AnnotationInfo (happens elsewhere).
The field doesn't get pickled/unpickled and exists only during a single compilation run.
This simultaneously allows us to reify annotations and to preserve backward compatibility.
Types function part of an application
Types function part of an application
Types a pattern with prototype pt
Types a pattern with prototype pt
Types qualifier tree
of a select node.
Types qualifier tree
of a select node.
E.g. is tree occurs in a context like tree.m
.
Types qualifier tree
of a select node.
Types qualifier tree
of a select node.
E.g. is tree occurs in a context like tree.m
.
Check that inner classes do not inherit from Annotation
Check that inner classes do not inherit from Annotation
Types a (fully parameterized) type tree
Types a (fully parameterized) type tree
Types a (fully parameterized) type tree
Types a (fully parameterized) type tree
Types a type constructor tree used in a new or supertype
Types a type constructor tree used in a new or supertype
Check that
Check that
- sealed classes are only inherited by classes which are nested within definition of base class, or that occur within same statement sequence,
The modifier typer which retypes with erased types.