The TypeMap handling the asSeenFrom in more complicated cases
The TypeMap handling the asSeenFrom in more complicated cases
An argument bounds violation is a triple consisting of
An argument bounds violation is a triple consisting of
A map for "cycle safe substitutions" which do not force the denotation of a TypeRef unless the name matches up with one of the substituted symbols.
A map for "cycle safe substitutions" which do not force the denotation of a TypeRef unless the name matches up with one of the substituted symbols.
Factory method for SymDenotion creation.
Factory method for SymDenotion creation. All creations should be done via this method.
Add moduleClass or sourceModule functionality to completer for a module or module class
Add moduleClass or sourceModule functionality to completer for a module or module class
The type tp
as seen from prefix pre
and owner cls
.
The type tp
as seen from prefix pre
and owner cls
. See the spec
for what this means. Called very often, so the code is optimized heavily.
A tricky aspect is what to do with unstable prefixes. E.g. say we have a class
class C { type T; def f(x: T): T }
and an expression e
of type C
. Then computing the type of e.f
leads
to the query asSeenFrom(C
, (x: T)T
). What should its result be? The
naive answer (x: C#T)C#T
is incorrect given that we treat C#T
as the existential
exists(c: C)c.T
. What we need to do instead is to skolemize the existential. So
the answer would be (x: c.T)c.T
for some (unknown) value c
of type C
.
c.T
is expressed in the compiler as a skolem type Skolem(C)
.
Now, skolemization is messy and expensive, so we want to do it only if we absolutely must. Also, skolemizing immediately would mean that asSeenFrom was no longer idempotent - each call would return a type with a different skolem. Instead we produce an annotated type that marks the prefix as unsafe:
(x: (C @ UnsafeNonvariant)#T)C#T
We also set a global state flag unsafeNonvariant
to the current run.
When typing a Select node, typer will check that flag, and if it
points to the current run will scan the result type of the select for
Execute op
at given period
Execute op
at given period
Execute op
at given phase
Execute op
at given phase
Execute op
at given phase id
Execute op
at given phase id
The context base at the root
The list of violations where arguments are not within bounds.
The list of violations where arguments are not within bounds.
The arguments
The list of type bounds
A function that maps a bound type and the list of argument types to a resulting type. Needed to handle bounds that refer to other bounds.
Is auto-tupling enabled?
Is auto-tupling enabled?
Is the debug option set?
Is the debug option set?
Context where sym
is defined, assuming we are in a nested context.
Context where sym
is defined, assuming we are in a nested context.
The denotation with the given name in current context
The denotation with the given name in current context
Approximate a type tp
with a type that does not contain skolem types.
Approximate a type tp
with a type that does not contain skolem types.
Leave message in diagnostics buffer if it exists
Leave message in diagnostics buffer if it exists
The given type, unless sym
is a constructor, in which case the
type of the constructed instance is returned
The given type, unless sym
is a constructor, in which case the
type of the constructed instance is returned
Either the current scope, or, if the current context owner is a class, the declarations of the current class.
Either the current scope, or, if the current context owner is a class, the declarations of the current class.
The next outer context whose tree is a template or package definition
The next outer context whose tree is a template or package definition
Enter symbol into current class, if current class is owner of current context, or into current scope, if not.
Enter symbol into current class, if current class is owner of current context, or into current scope, if not. Should always be called instead of scope.enter in order to make sure that updates to class members are reflected in finger prints.
Does current phase use an erased types interpretation?
Does current phase use an erased types interpretation?
The context of expression expr
seen as a member of a statement sequence
The context of expression expr
seen as a member of a statement sequence
Is feature
enabled in class owner
?
This is the case if one of the following two alternatives holds:
Is feature
enabled in class owner
?
This is the case if one of the following two alternatives holds:
import owner.feature
(the feature may be bunched with others, or renamed, but wildcard imports don't count).
2. The feature is enabled by a compiler option
where <prefix> is the full name of the owner followed by a "." minus the prefix "dotty.language.".
If we have member definitions
If we have member definitions
type argSym v= from type from v= to
where the variances of both alias are the same, then enter a new definition
type argSym v= to
unless a definition for argSym
already exists in the current scope.
A fresh clone of this context.
A fresh clone of this context.
Get ClassSymbol if class is either defined in current compilation run or present on classpath.
Get ClassSymbol if class is either defined in current compilation run or present on classpath. Returns NoSymbol otherwise.
Given a disjunction T1 | ...
Given a disjunction T1 | ... | Tn of types with potentially embedded type variables, constrain type variables further if this eliminates some of the branches of the disjunction. Do this also for disjunctions embedded in intersections, as parents in refinements, and in recursive types.
For instance, if A
is an unconstrained type variable, then
ArrayBuffer[Int] | ArrayBuffer[A]
is approximated by constraining A
to be =:= to Int
and returning ArrayBuffer[Int]
instead of ArrayBuffer[_ >: Int | A <: Int & A]
For sending messages that are printed only if -verbose is set
For sending messages that are printed only if -verbose is set
A condensed context containing essential information of this but no outer contexts except the initial context.
A condensed context containing essential information of this but no outer contexts except the initial context. private var _condensed: CondensedContext = null def condensed: CondensedContext = { if (_condensed eq outer.condensed) _condensed = base.initialCtx.fresh .withPeriod(period) .withNewMode(mode) // typerState and its constraint is not preserved in condensed // reporter is always ThrowingReporter .withPrinterFn(printerFn) .withOwner(owner) .withSettings(sstate) // tree is not preserved in condensed .withRunInfo(runInfo) .withDiagnostics(diagnostics) .withMoreProperties(moreProperties) _condensed }
Is this a context for the members of a class definition?
Is this a context for the members of a class definition?
Is this a context that introduces an import clause?
Is this a context that introduces an import clause?
Is this a context that introduces a non-empty scope?
Is this a context that introduces a non-empty scope?
Log msg if settings.log contains the current phase.
Log msg if settings.log contains the current phase. See config.CompilerCommand#explainAdvanced for the exact meaning of "contains" here.
If tpe
is of the form p.x
where p
refers to a package
but x
is not owned by a package, expand it to
If tpe
is of the form p.x
where p
refers to a package
but x
is not owned by a package, expand it to
p.package.x
Map given symbols, subjecting their attributes to the mappings
defined in the given TreeTypeMap ttmap
.
Map given symbols, subjecting their attributes to the mappings
defined in the given TreeTypeMap ttmap
.
Cross symbol references are brought over from originals to copies.
Do not copy any symbols if all attributes of all symbols stay the same.
The method type corresponding to given parameters and result type
The method type corresponding to given parameters and result type
Create a class symbol from its non-info fields and a function producing its info (the produced info may be lazy).
Create a class symbol from its non-info fields and a function producing its info (the produced info may be lazy).
Create a class symbol from a function producing its denotation
Create a class symbol from a function producing its denotation
Create a class symbol from its non-info fields and the fields of its info.
Create a class symbol from its non-info fields and the fields of its info.
Create a module symbol with associated module class from its non-info fields and the fields of the module class info.
Create a module symbol with associated module class from its non-info fields and the fields of the module class info.
Create a package symbol with associated package class from its non-info fields its member scope.
Create a package symbol with associated package class from its non-info fields its member scope.
Create a class constructor symbol for given class cls
.
Create a class constructor symbol for given class cls
.
Create an empty default constructor symbol for given class cls
.
Create an empty default constructor symbol for given class cls
.
Create an import symbol pointing back to given qualifier expr
.
Create an import symbol pointing back to given qualifier expr
.
Create the local template dummy of given class cls
.
Create the local template dummy of given class cls
.
In a template
trait T { val fld: Int; { val x: int = 2 }; val fld2 = { val y = 2; y }}
the owner of x
is the local dummy of the template. The owner of the local
dummy is then the class of the template itself. By contrast, the owner of y
would be fld2
. There is a single local dummy per template.
Create a module symbol with associated module class from its non-info fields and a function producing the info of the module class (this info may be lazy).
Create a module symbol with associated module class from its non-info fields and a function producing the info of the module class (this info may be lazy).
Create a class symbol without a denotation.
Create a class symbol without a denotation.
Create a symbol without a denotation.
Create a symbol without a denotation. Note this uses a cast instead of a direct type refinement because it's debug-friendlier not to create an anonymous class here.
Same as newCompleteClassSymbol
except that parents
can be a list of arbitrary
types which get normalized into type refs and parameter bindings.
Same as newCompleteClassSymbol
except that parents
can be a list of arbitrary
types which get normalized into type refs and parameter bindings.
Create a package symbol with associated package class from its non-info fields and a lazy type for loading the package's members.
Create a package symbol with associated package class from its non-info fields and a lazy type for loading the package's members.
Create a symbol representing a selftype declaration for class cls
.
Create a symbol representing a selftype declaration for class cls
.
Create a new skolem symbol.
Create a new skolem symbol. This is not the same as SkolemType, even though the motivation (create a singleton referencing to a type) is similar.
Create a stub symbol that will issue a missing reference error when attempted to be completed.
Create a stub symbol that will issue a missing reference error when attempted to be completed.
Create a symbol from its fields (info may be lazy)
Create a symbol from its fields (info may be lazy)
Create new type parameters with given owner, names, and flags.
Create new type parameters with given owner, names, and flags.
A function that, given type refs to the newly created parameters returns a list of their bounds.
if isConstructor, make sure it has one non-implicit parameter list
if isConstructor, make sure it has one non-implicit parameter list
Normalize a list of parent types of class cls
that may contain refinements
to a list of typerefs referring to classes, by converting all refinements to member
definitions in scope decls
.
Normalize a list of parent types of class cls
that may contain refinements
to a list of typerefs referring to classes, by converting all refinements to member
definitions in scope decls
. Can add members to decls
as a side-effect.
Approximate union type by intersection of its dominators.
Approximate union type by intersection of its dominators. That is, replace a union type Tn | ... | Tn by the smallest intersection type of base-class instances of T1,...,Tn. Example: Given
trait C[+T] trait D class A extends C[A] with D class B extends C[B] with D with E
we approximate A | B
by C[A | B] with D
All outer contexts, ending in base.initialCtx
and then NoContext
All outer contexts, ending in base.initialCtx
and then NoContext
The current phase identifier
The current phase identifier
Print all enclosing context's creation stacktraces
Print all enclosing context's creation stacktraces
A function creating a printer
A function creating a printer
The current reporter
The current reporter
The current run identifier
The current run identifier
Implementation of Types#simplified
Implementation of Types#simplified
The current source file; will be derived from current compilation unit.
The current source file; will be derived from current compilation unit.
The period containing the current period where denotations do not change.
The period containing the current period where denotations do not change. We compute this by taking as first phase the first phase less or equal to the current phase that has the same "nextTransformerId". As last phase we take the next transformer id following the current phase.
The context for a supercall.
The context for a supercall. This context is used for elaborating the parents of a class and their arguments. The context is computed from the current class context. It has
The reasons for this peculiar choice of attributes are as follows:
The symbol (stored in some typer's symTree) of an enclosing context definition
The symbol (stored in some typer's symTree) of an enclosing context definition
The context for the arguments of a this(...) constructor call.
The context for the arguments of a this(...) constructor call. The context is computed from the local auxiliary constructor context. It has
Explain why symbol is invalid; used for debugging only
Explain why symbol is invalid; used for debugging only
Throws an UnsupportedOperationException
with the given method name.
Throws an UnsupportedOperationException
with the given method name.
Should use colors when printing?
Should use colors when printing?
Is the verbose option set?
Is the verbose option set?
Implements a fold that applies the function f
to the result of op
if
there are no new errors in the reporter
Implements a fold that applies the function f
to the result of op
if
there are no new errors in the reporter
operation checked for errors
function applied to result of op
either the result of op
if it had errors or the result of f
applied to it
This context at given phase.
This context at given phase. This method will always return a phase period equal to phaseId, thus will never return squashed phases