scala.tools.nsc.typechecker.Implicits
Prune ImplicitInfos down to either all the eligible ones or the best one.
Perform the following adaptations of expression, pattern or type tree' wrt to
given mode
mode' and given prototype pt':
(-1) For expressions with annotated types, let AnnotationCheckers decide what to do
(0) Convert expressions with constant types to literals (unless in interactive/scaladoc mode)
(1) Resolve overloading, unless mode contains FUNmode
(2) Apply parameterless functions
(3) Apply polymorphic types to fresh instances of their type parameters and
store these instances in context.undetparams,
unless followed by explicit type application.
(4) Do the following to unapplied methods used as values:
(4.1) If the method has only implicit parameters pass implicit arguments
(4.2) otherwise, if
pt' is a function type and method is not a constructor,
convert to function by eta-expansion,
(4.
Perform the following adaptations of expression, pattern or type tree' wrt to
given mode
mode' and given prototype pt':
(-1) For expressions with annotated types, let AnnotationCheckers decide what to do
(0) Convert expressions with constant types to literals (unless in interactive/scaladoc mode)
(1) Resolve overloading, unless mode contains FUNmode
(2) Apply parameterless functions
(3) Apply polymorphic types to fresh instances of their type parameters and
store these instances in context.undetparams,
unless followed by explicit type application.
(4) Do the following to unapplied methods used as values:
(4.1) If the method has only implicit parameters pass implicit arguments
(4.2) otherwise, if
pt' is a function type and method is not a constructor,
convert to function by eta-expansion,
(4.3) otherwise, if the method is nullary with a result type compatible to pt'
and it is not a constructor, apply it to ()
otherwise issue an error
(5) Convert constructors in a pattern as follows:
(5.1) If constructor refers to a case class factory, set tree's type to the unique
instance of its primary constructor that is a subtype of the expected type.
(5.2) If constructor refers to an extractor, convert to application of
unapply or unapplySeq method.
(6) Convert all other types to TypeTree nodes.
(7) When in TYPEmode but not FUNmode or HKmode, check that types are fully parameterized
(7.1) In HKmode, higher-kinded types are allowed, but they must have the expected kind-arity
(8) When in both EXPRmode and FUNmode, add apply method calls to values of object type.
(9) If there are undetermined type variables and not POLYmode, infer expression instance
Then, if tree's type is not a subtype of expected type, try the following adaptations:
(10) If the expected type is Byte, Short or Char, and the expression
is an integer fitting in the range of that type, convert it to that type.
(11) Widen numeric literals to their expected type, if necessary
(12) When in mode EXPRmode, convert E to { E; () } if expected type is scala.Unit.
(13) When in mode EXPRmode, apply AnnotationChecker conversion if expected type is annotated.
(14) When in mode EXPRmode, apply a view
If all this fails, error
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 = ?.
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 o apply an implicit conversion to qual' to that it contains
a method
name. If that's ambiguous try taking arguments into account using
adaptToArguments.
Try o apply an implicit conversion to qual' to 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.
If no conversion is found, return
qual' unchanged.
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.
...
...
Computes from a list of lists of implicit infos a map which takes
infos which are applicable for given expected type pt
to their attributed trees.
Computes from a list of lists of implicit infos a map which takes
infos which are applicable for given expected type pt
to their attributed trees.
The given list of lists of implicit infos
Is implicit definition visible without prefix? If this is the case then symbols in preceding lists shadow symbols of the same name in succeeding lists.
map from infos to search results
Find implicit arguments and pass them to given tree.
Find implicit arguments and pass them to given tree.
The result of the implicit search: First search implicits visible in current context.
The result of the implicit search:
First search implicits visible in current context.
If that fails, search implicits in expected type pt
.
If that fails, and pt
is an instance of Manifest, try to construct a manifest.
If all fails return SearchFailure
Check that tpt' refers to a non-refinement class type
Check that tpt' refers to a non-refinement class type
Check if a method is defined in such a way that it can be called.
Check if a method is defined in such a way that it can be called. A method cannot be called if it is a non-private member of a structural type and if its parameter's types are not one of - this.type - a type member of the structural type - an abstract type declared outside of the structural type.
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.
...
...
true
if tp
is not a subtype of itself.
Check that tree
is a stable expression.
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.
Given a set rawSyms
of term- and type-symbols, and a type
tp
, produce a set of fresh type parameters and a type so that
it can be abstracted to an existential type.
Given a set rawSyms
of term- and type-symbols, and a type
tp
, produce a set of fresh type parameters and a type so that
it can be abstracted to an existential type. Every type symbol
T
in rawSyms
is mapped to a clone. Every term symbol x
of
type T
in rawSyms
is given an associated type symbol of the
following form:
type x.type <: T with Singleton
The name of the type parameter is x.type
, to produce nice
diagnostics. The Singleton parent ensures that the type
parameter is still seen as a stable type. Type symbols in
rawSyms are fully replaced by the new symbols. Term symbols are
also replaced, except for term symbols of an Ident tree, where
only the type of the Ident is changed.
Is implicit info info1
better than implicit info info2
?
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.
...
...
...
...
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.
Should implicit definition symbol sym' be considered for applicability testing?
This is the case if one of the following holds:
- the symbol's type is initialized
- the symbol comes from a classfile
- the symbol comes from a different sourcefile than the current one
- the symbol and the accessed symbol's definitions come before, and do not contain the closest enclosing definition, // see #3373
- the symbol's definition is a val, var, or def with an explicit result type
The aim of this method is to prevent premature cyclic reference errors
by computing the types of only those implicits for which one of these
conditions is true.
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.
The member with given name of given qualifier tree
The member with given name of given qualifier tree
The annotations amongst annots
that should go on a member of class
memberClass
(field, getter, setter, beanGetter, beanSetter, param)
If 'keepClean' is true, annotations without any meta-annotation are kept
The annotations amongst annots
that should go on a member of class
memberClass
(field, getter, setter, beanGetter, beanSetter, param)
If 'keepClean' is true, annotations without any meta-annotation are kept
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?
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 skolems to existentials
convert 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
.
Is symbol defined and not stale?
Is symbol defined and not stale?
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)
Report a type error.
Search list of implicit info lists for one matching prototype pt
.
Search list of implicit info lists for one matching prototype pt
.
If found return a search result with a tree from found implicit info
which is typed with expected type pt
. Otherwise return SearchFailure.
The given list of lists of implicit infos
Is implicit definition visible without prefix? If this is the case then symbols in preceding lists shadow symbols of the same name in succeeding lists.
...
...
...
...
Utility method: Try op1 on tree.
Utility method: Try op1 on tree. If that gives an error try op2 instead.
Types expression tree
with given prototype pt
.
Types expression or definition tree
.
...
...
...
...
Convert an annotation constructor call into an AnnotationInfo.
Convert an annotation constructor call into an AnnotationInfo.
the expected annotation class
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
Types a higher-kinded type tree -- pt denotes the expected kind
Types a higher-kinded type tree -- pt denotes the expected kind
...
...
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
...
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
...
...
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.
The type parameters to instantiate
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,
A class that sets up an implicit search. For more info, see comments for
inferImplicit
.