typechecker - Scala Compiler 2.11.6 - scala.tools.nsc.typechecker
Keywords: typechecker Scala Compiler 2.11.6 scala.tools.nsc.typechecker

scala.tools.nsc

# typechecker

#### package typechecker

Content Hierarchy Learn more about scaladoc diagrams
Visibility

1. Public
2. All

### Type Members

1. #### trait Adaptations extends AnyRef

   This trait provides logic for assessing the validity of argument adaptations, such as tupling, unit-insertion, widening, etc.

   This trait provides logic for assessing the validity of argument adaptations, such as tupling, unit-insertion, widening, etc. Such logic is spread around the compiler, without much ability on the part of the user to tighten the potentially dangerous bits.

   TODO: unifying/consolidating said logic under consistent management.

2. #### trait Analyzer extends Contexts with Namers with Typers with Infer with Implicits with EtaExpansion with SyntheticMethods with Unapplies with Macros with NamesDefaults with TypeDiagnostics with ContextErrors with StdAttachments with AnalyzerPlugins

   The main attribution phase.

3. #### trait AnalyzerPlugins extends AnyRef

   Version

     1.0

4. #### trait Checkable extends AnyRef

   On pattern matcher checkability:

   On pattern matcher checkability:

   The spec says that case _: List[Int] should be always issue an unchecked warning:

   > Types which are not of one of the forms described above are > also accepted as type patterns. However, such type patterns > will be translated to their erasure (§3.7). The Scala compiler > will issue an “unchecked” warning for these patterns to flag > the possible loss of type-safety.

   But the implementation goes a little further to omit warnings based on the static type of the scrutinee. As a trivial example:

   def foo(s: Seq[Int]) = s match { case _: List[Int] => }

   need not issue this warning.

   Consider a pattern match of this form: (x: X) match { case _: P => }

   There are four possibilities to consider: [P1] X will always conform to P [P2] x will never conform to P [P3] X will conform to P if some runtime test is true [P4] X cannot be checked against P

   The first two cases correspond to those when there is enough static information to say X <: P or that (x ∈ X) ⇒ (x ∉ P). The fourth case includes unknown abstract types or structural refinements appearing within a pattern.

   The third case is the interesting one. We designate another type, XR, which is essentially the intersection of X and |P|, where |P| is the erasure of P. If XR <: P, then no warning is emitted.

   We evaluate "X with conform to P" by checking `X <: P_wild, where P_wild is the result of substituting wildcard types in place of pattern type variables. This is intentionally stricter than (X matchesPattern P), see SI-8597 for motivating test cases.`

   Examples of how this info is put to use: sealed trait A[T] ; class B[T] extends A[T] def f(x: B[Int]) = x match { case _: A[Int] if true => } def g(x: A[Int]) = x match { case _: B[Int] => }

   `f` requires no warning because X=B[Int], P=A[Int], and B[Int] <:< A[Int]. `g` requires no warning because X=A[Int], P=B[Int], XR=B[Int], and B[Int] <:< B[Int]. XR=B[Int] because a value of type A[Int] which is tested to be a B can only be a B[Int], due to the definition of B (B[T] extends A[T].)

   This is something like asSeenFrom, only rather than asking what a type looks like from the point of view of one of its base classes, we ask what it looks like from the point of view of one of its subclasses.

5. #### abstract class ConstantFolder extends AnyRef

   This class ...

   This class ...

   Version

     1.0

6. #### trait ContextErrors extends AnyRef

7. #### final class ContextMode extends AnyVal

   A value class to carry the boolean flags of a context, such as whether errors should be buffered or reported.

8. #### trait Contexts extends AnyRef

   Version

     1.0

9. #### trait DestructureTypes extends AnyRef

   A generic means of breaking down types into their subcomponents.

   A generic means of breaking down types into their subcomponents. Types are decomposed top down, and recognizable substructure is dispatched via self-apparently named methods. Those methods can be overridden for custom behavior, but only the abstract methods require implementations, each of which must create some unknown "Node" type from its inputs.

   - wrapProduct create Node from a product of Nodes
   - wrapSequence create Node from a sequence of Nodes
   - wrapAtom create Node from an arbitrary value

   This is a work in progress.

10. #### abstract class Duplicators extends Analyzer

    Duplicate trees and re-type check them, taking care to replace and create fresh symbols for new local definitions.

    Duplicate trees and re-type check them, taking care to replace and create fresh symbols for new local definitions.

    Version

      1.0

11. #### trait EtaExpansion extends AnyRef

    This trait ...

    This trait ...

    Version

      1.0

12. #### final class Fingerprint extends AnyVal

13. #### trait Implicits extends AnyRef

    This trait provides methods to find various kinds of implicits.

    This trait provides methods to find various kinds of implicits.

    Version

      1.0

14. #### trait Infer extends Checkable

    This trait contains methods related to type parameter inference.

    This trait contains methods related to type parameter inference.

    Version

      1.0

15. #### trait Macros extends MacroRuntimes with Traces with Helpers

    Code to deal with macros, namely with: * Compilation of macro definitions * Expansion of macro applications

    Code to deal with macros, namely with: * Compilation of macro definitions * Expansion of macro applications

    Say we have in a class C:

    def foo[T](xs: List[T]): T = macro fooBar

    Then fooBar needs to point to a static method of the following form:

    def fooBar[T: c.WeakTypeTag] // type tag annotation is optional (c: scala.reflect.macros.blackbox.Context) (xs: c.Expr[List[T]]) : c.Expr[T] = { ... }

    Then, if foo is called in qual.foo[Int](elems), where qual: D, the macro application is expanded to a reflective invocation of fooBar with parameters:

    (simpleMacroContext{ type PrefixType = D; val prefix = qual }) (Expr(elems)) (TypeTag(Int))

16. #### trait MethodSynthesis extends AnyRef

    Logic related to method synthesis which involves cooperation between Namer and Typer.

17. #### trait Namers extends MethodSynthesis

    This trait declares methods to create symbols and to enter them into scopes.

    This trait declares methods to create symbols and to enter them into scopes.

    Version

      1.0

18. #### trait NamesDefaults extends AnyRef

    Version

      1.0

19. #### trait PatternTypers extends AnyRef

    A pattern match such as

    A pattern match such as

    x match { case Foo(a, b) => ...}

    Might match an instance of any of the following definitions of Foo. Note the analogous treatment between case classes and unapplies.

    case class Foo(xs: Int*) case class Foo(a: Int, xs: Int*) case class Foo(a: Int, b: Int) case class Foo(a: Int, b: Int, xs: Int*)

    object Foo { def unapplySeq(x: Any): Option[Seq[Int]] } object Foo { def unapplySeq(x: Any): Option[(Int, Seq[Int])] } object Foo { def unapply(x: Any): Option[(Int, Int)] } object Foo { def unapplySeq(x: Any): Option[(Int, Int, Seq[Int])] }

20. #### abstract class RefChecks extends SubComponent with InfoTransform with reflect.internal.transform.RefChecks

    Post-attribution checking and transformation.

    Post-attribution checking and transformation.

    This phase performs the following checks.

    - All overrides conform to rules.
    - All type arguments conform to bounds.
    - All type variable uses conform to variance annotations.
    - No forward reference to a term symbol extends beyond a value definition.

    It performs the following transformations.

    - Local modules are replaced by variables and classes
    - Calls to case factory methods are replaced by new's.
    - Eliminate branches in a conditional if the condition is a constant
    Version

      1.0

    To do

      Check whether we always check type parameter bounds.

21. #### trait StdAttachments extends AnyRef

22. #### trait StructuredTypeStrings extends DestructureTypes

    A more principled system for turning types into strings.

23. #### abstract class SuperAccessors extends SubComponent with Transform with TypingTransformers

    This phase performs the following functions, each of which could be split out in a mini-phase:

    This phase performs the following functions, each of which could be split out in a mini-phase:

    (1) Adds super accessors for all super calls that either appear in a trait or have as a target a member of some outer class.

    (2) Converts references to parameter fields that have the same name as a corresponding public parameter field in a superclass to a reference to the superclass field (corresponding = super class field is initialized with subclass field). This info is pre-computed by the `alias` field in Typer. `dotc` follows a different route; it computes everything in SuperAccessors and changes the subclass field to a forwarder instead of manipulating references. This is more modular.

    (3) Adds protected accessors if the access to the protected member happens in a class which is not a subclass of the member's owner.

    (4) Mangles the names of class-members which are private up to an enclosing non-package class, in order to avoid overriding conflicts. This is a dubious, and it would be better to deprecate class-qualified privates.

    (5) This phase also sets SPECIALIZED flag on type parameters with `@specialized` annotation. We put this logic here because the flag must be set before pickling.

    It also checks that:

    (1) Symbols accessed from super are not abstract, or are overridden by an abstract override.

    (2) If a symbol accessed accessed from super is defined in a real class (not a trait), there are no abstract members which override this member in Java's rules (see SI-4989; such an access would lead to illegal bytecode)

    (3) Super calls do not go to some synthetic members of Any (see isDisallowed)

    (4) Super calls do not go to synthetic field accessors

    (5) A class and its companion object do not both define a class or module with the same name.

    TODO: Rename phase to "Accessors" because it handles more than just super accessors

24. #### trait SyntheticMethods extends TreeDSL

    Synthetic method implementations for case classes and case objects.

    Synthetic method implementations for case classes and case objects.

    Added to all case classes/objects: def productArity: Int def productElement(n: Int): Any def productPrefix: String def productIterator: Iterator[Any]

    Selectively added to case classes/objects, unless a non-default implementation already exists: def equals(other: Any): Boolean def hashCode(): Int def canEqual(other: Any): Boolean def toString(): String

    Special handling: protected def readResolve(): AnyRef

25. #### trait Tags extends AnyRef

26. #### abstract class TreeCheckers extends Analyzer

27. #### trait TypeDiagnostics extends AnyRef

    An interface to enable higher configurability of diagnostic messages regarding type errors.

    An interface to enable higher configurability of diagnostic messages regarding type errors. This is barely a beginning as error messages are distributed far and wide across the codebase. The plan is to partition error messages into some broad groups and provide some mechanism for being more or less verbose on a selective basis. Possible groups include such examples as

    arity errors kind errors variance errors ambiguity errors volatility/stability errors implementation restrictions

    And more, and there is plenty of overlap, so it'll be a process.

    Version

      1.0

28. #### trait TypeStrings extends AnyRef

    Logic for turning a type into a String.

    Logic for turning a type into a String. The goal is to be able to take some arbitrary object 'x' and obtain the most precise String for which an injection of x.asInstanceOf[String] will be valid from both the JVM's and scala's perspectives.

    "definition" is when you want strings like

29. #### trait Typers extends Adaptations with Tags with TypersTracking with PatternTypers

    This trait provides methods to assign types to trees.

    This trait provides methods to assign types to trees.

    Version

      1.0

30. #### trait TypersTracking extends AnyRef

31. #### trait Unapplies extends TreeDSL

### Value Members

1. #### object ContextMode

2. #### object Fingerprint

3. #### object ImplicitsStats

4. #### object MacrosStats

5. #### object TypeStrings extends TypeStrings

6. #### object TypersStats

### Ungrouped