Constructors
Members
The TypeMap handling the asSeenFrom in more complicated cases
The TypeMap handling the asSeenFrom in more complicated cases
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.
An argument bounds violation is a triple consisting of - the argument tree - a string "upper" or "lower" indicating which bound is violated - the violate...
An argument bounds violation is a triple consisting of - the argument tree - a string "upper" or "lower" indicating which bound is violated - the violated bound
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 aspec...
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
Helper method, taking a map argument which is instantiated only for more complicated cases of asSeenFrom.
Helper method, taking a map argument which is instantiated only for more complicated cases of asSeenFrom.
The list of violations where arguments are not within bounds.
The list of violations where arguments are not within bounds.
Is auto-tupling enabled?
Is auto-tupling enabled?
Is feature
enabled in class owner
?
This is the case if one of the following two alternatives holds:
-
The feature is imported by a named import
import owner.feature
(the feature may be bunched with others, or rename...
Is feature
enabled in class owner
?
This is the case if one of the following two alternatives holds:
-
The feature is imported by a named import
import owner.feature
(the feature may be bunched with others, or renamed, but wildcard imports don't count).
-
The feature is enabled by a compiler option
- language:
feature
- language:
where
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...
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.
Given a disjunction T1 | ... | Tn of types with potentially embedded type variables, constrain type variables further if this eliminates some of the bra...
ArrayBuffer[Int] | ArrayBuffer[A]
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]
Under -language:Scala2: Replace or-types with their joins
Under -language:Scala2: Replace or-types with their joins
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
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
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...
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. That is, replace a union type Tn | ... | Tn by the smallest intersection type of base-class in...
trait C[+T]
trait D
class A extends C[A] with D
class B extends C[B] with D with E
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
Implementation of Types#simplified
Implementation of Types#simplified