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.
Is this context in all modes in the given mask
?
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
.
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
A bitmask containing all the boolean flags in a context, e.g.
A bitmask containing all the boolean flags in a context, e.g. are implicit views enabled
To enrich error messages involving default arguments.
To enrich error messages involving default arguments. When extending the notion, group diagnostics in an object.
The next outer context whose tree is a template or package definition
The next enclosing context (potentially this
) that is owned by a class or method
The next outer context whose tree is a method
...or an Apply.
The next enclosing context (potentially this
) that has a CaseDef
as a tree
Return the closest enclosing context that defines a subclass of clazz
or a companion object thereof, or NoContext
if no such context exists.
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.
Issue/throw the given error message according to the current mode for error reporting.
Return and clear the undetermined type parameters
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
Equivalent to imports.headOption
, but more efficient
Returns the runtime class representation of the object.
Returns the runtime class representation of the object.
a class object corresponding to the runtime type of the receiver.
The hashCode method for reference types.
The currently visible imports
Use reporter (possibly buffered) for errors/warnings and enable implicit conversion *
Is sym
accessible as a member of pre
in current context?
Must sym
defined in package object of package pkg
, if
it selected from a prefix with pkg
as its type symbol?
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.
Find a symbol in this context or one of its outers.
Find a symbol in this context or one of its outers.
Used to find symbols are owned by methods (or fields), they can't be found in some scope.
Examples: companion module of classes owned by a method, default getter methods of nested methods. See NamesDefaults.scala
Find the symbol of a simple name starting from this context.
Find the symbol of a simple name starting from this context. All names are filtered through the "qualifies" predicate, the search continuing as long as no qualifying name is found.
Construct a child context.
Construct a child context. The parent and child will share the report buffer.
Compare with makeSilent
, in which the child has a fresh report buffer.
If tree
is an Import
, that import will be avaiable at the head of
Context#imports
.
A context for typing constructor parameter ValDefs, super or self invocation arguments and default getters of constructors.
A context for typing constructor parameter ValDefs, super or self invocation arguments and default getters of constructors. These expressions need to be type checked in a scope outside the class, cf. spec 5.3.1.
This method is called by namer / typer where this
is the context for the constructor DefDef. The
owner of the resulting (new) context is the outer context for the Template, i.e. the context for the
ClassDef. This means that class type parameters will be in scope. The value parameters of the current
constructor are also entered into the new constructor scope. Members of the class however will not be
accessible.
Make a silent child context does not allow implicits.
Make a silent child context does not allow implicits. Used to prevent chaining of implicit views.
Make a child context that represents a new nested scope
Make a child context that buffers errors and warnings into a fresh report buffer.
Equivalent to !(this eq that)
.
Equivalent to !(this eq that)
.
true
if the argument is not a reference to the receiver object; false
otherwise.
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
Types for which implicit arguments are currently searched
The current owner
Saved type bounds for type parameters which are narrowed in a GADT.
Run body
with this context with no undetermined type parameters, restore the original
the original list afterwards.
Run body
with this context with no undetermined type parameters, restore the original
the original list afterwards.
Should ambiguous errors be reported during evaluation of body
?
The current scope
Set all modes in the mask enable
to true, and all in disable
to false.
Creates a String representation of this object.
Tree associated with this context
Undetermined type parameters.
Undetermined type parameters. See Infer#{inferExprInstance, adjustTypeArgs}
. Not inherited to child contexts
Update all modes in mask
to value
Variance relative to enclosing class
Issue/throw the given error message according to the current mode for error reporting.
TypeConstructorAllowed is enabled when we are typing a higher-kinded type.
TypeConstructorAllowed is enabled when we are typing a higher-kinded type. adapt should then check kind-arity based on the prototypical type's kind arity. Type arguments should not be inferred.
A motley collection of the state and loosely associated behaviour of the type checker. Each
Typer
has an associated context, and as it descends into the tree new(Typer, Context)
pairs are spawned.Meet the crew; first the state:
outer
.contextMode
.And behaviour:
Context
is something of a Zipper for the tree were are typechecking: itenclosingContextChain
is the path back to the root. This is exactly what we need to resolve names (lookupSymbol
) and to collect in-scope implicit definitions (implicitss
) Supporting these areimports
, which represents allImport
trees in in the enclosing context chain.isAccessible
.)More on error buffering: When are type errors recoverable? In quite a few places, it turns out. Some examples: trying to type an application with/without the expected type, or with/without implicit views enabled. This is usually mediated by
Typer.silent
,Inferencer#tryTwice
.Initially, starting from the
typer
phase, the contexts either buffer or report errors; afterwards errors are thrown. This is configured inrootContext
. Additionally, more fine grained control is needed based on the kind of error; ambiguity errors are often suppressed during exploratory typing, such as determining whethera == b
in an argument position is an assignment or a named argument, whenInferencer#isApplicableSafe
type checks applications with and without an expected type, or whenTyper#tryTypedApply
tries to fit arguments to a function type with/without implicit views.When the error policies entail error/warning buffering, the mutable ReportBuffer records everything that is issued. It is important to note, that child Contexts created with
make
"inherit" the very sameReportBuffer
instance, whereas children spawned throughmakeSilent
receive a separate, fresh buffer.