Packages

p

scala.tools.nsc

typechecker

package typechecker

Content Hierarchy
Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Type Members

  1. trait Adaptations extends AnyRef

    A provider of the logic for assessing the validity of argument adaptations, such as tupling, unit-insertion, widening, etc.

    A provider of the 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.

  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 MacroAnnotationAttachments with AnalyzerPlugins

    Defines the sub-components for the namer, packageobjects, and typer phases.

  3. trait AnalyzerPlugins extends AnyRef

  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 scala/bug#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 ...

  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

  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.

  11. trait EtaExpansion extends AnyRef

    This trait ...

  12. final class Fingerprint extends AnyVal
  13. trait Implicits extends AnyRef

    This trait provides methods to find various kinds of implicits.

  14. trait ImplicitsStats extends AnyRef
  15. trait Infer extends Checkable

    This trait contains methods related to type parameter inference.

  16. trait MacroAnnotationAttachments extends AnyRef
  17. trait MacroAnnotationNamers extends AnyRef
  18. 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))

  19. trait MacrosStats extends AnyRef
  20. trait MethodSynthesis extends AnyRef

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

  21. trait Namers extends MethodSynthesis

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

  22. trait NamesDefaults extends AnyRef

  23. 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])] }
  24. abstract class RefChecks extends SubComponent with Transform

    Post-attribution checking and transformation.

    Post-attribution checking and transformation.

    This phase checks the following postconditions:

    • All overrides conform to rules.
    • All type arguments conform to bounds.
    • Every use of a type variable conforms to the variance annotation of that variable.
    • 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.
  25. trait StdAttachments extends AnyRef
  26. trait StructuredTypeStrings extends DestructureTypes

    A more principled system for turning types into strings.

  27. abstract class SuperAccessors extends SubComponent with Transform with TypingTransformers

    This phase performs the following functions, each of which could be split out into its own mini-phase:

    This phase performs the following functions, each of which could be split out into its own 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 scala/bug#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.

    Should've really been called "Accessors" as it handles more than just super accessors.

  28. 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 writeReplace(): AnyRef

  29. trait Tags extends AnyRef
  30. abstract class TreeCheckers extends Analyzer
  31. 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.

  32. 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

  33. trait Typers extends Adaptations with Tags with TypersTracking with PatternTypers

    A provider of methods to assign types to trees.

  34. trait TypersStats extends AnyRef
  35. trait TypersTracking extends AnyRef
  36. trait Unapplies extends TreeDSL

Value Members

  1. object ContextMode
  2. object Fingerprint
  3. object Macros
  4. object TypeStrings extends TypeStrings

Ungrouped