scala.tools.nsc.typechecker.Infer

Inferencer

class Inferencer extends Analyzer.InferencerContextErrors with Analyzer.InferCheckable

The context-dependent inferencer part

Source
Infer.scala
Linear Supertypes
Analyzer.InferCheckable, Analyzer.InferencerContextErrors, AnyRef, Any
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Inferencer
  2. InferCheckable
  3. InferencerContextErrors
  4. AnyRef
  5. Any
Implicitly
  1. by any2stringadd
  2. by any2stringfmt
  3. by any2ArrowAssoc
  4. by any2Ensuring
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Inferencer(context: Analyzer.Context)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to StringAdd performed by method any2stringadd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (Analyzer.Inferencer, B)

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to ArrowAssoc[Analyzer.Inferencer] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. object AdjustedTypeArgs

    [Martin] Can someone comment this please? I have no idea what it's for and the code is not exactly readable.

  9. object InferErrorGen

    Definition Classes
    InferencerContextErrors
  10. def adjustTypeArgs(tparams: List[Global.Symbol], tvars: List[Global.TypeVar], targs: List[Global.Type], restpe: Global.Type = WildcardType): Result

    Retract arguments that were inferred to Nothing because inference failed.

    Retract arguments that were inferred to Nothing because inference failed. Correct types for repeated params.

    We detect Nothing-due-to-failure by only retracting a parameter if either:

    • it occurs in an invariant/contravariant position in restpe
    • restpe == WildcardType

    Retracted parameters are mapped to None. TODO:

    • make sure the performance hit of storing these in a map is acceptable (it's going to be a small map in 90% of the cases, I think)
    • refactor further up the callstack so that we don't have to do this post-factum adjustment?

    Rewrite for repeated param types: Map T* entries to Seq[T].

    returns

    map from tparams to inferred arg, if inference was successful, tparams that map to None are considered left undetermined type parameters that are inferred as scala.Nothing and that are not covariant in restpe are taken to be undetermined

  11. object approximateAbstracts extends Global.TypeMap

  12. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  13. def checkAccessible(tree: Global.Tree, sym: Global.Symbol, pre: Global.Type, site: Global.Tree): Global.Tree

    Check that sym is defined and accessible as a member of tree site with type pre in current context.

    Check that sym is defined and accessible as a member of tree site with type pre in current context.

    Note: pre is not refchecked -- moreover, refchecking the resulting tree may not refcheck pre, since pre may not occur in its type (callers should wrap the result in a TypeTreeWithDeferredRefCheck)

  14. def checkBounds(tree: Global.Tree, pre: Global.Type, owner: Global.Symbol, tparams: List[Global.Symbol], targs: List[Global.Type], prefix: String): Boolean

    error if arguments not within bounds.

  15. def checkCheckable(tree: Global.Tree, P0: Global.Type, X0: Global.Type, inPattern: Boolean, canRemedy: Boolean = false): Unit

    TODO: much better error positions.

    TODO: much better error positions. Kind of stuck right now because they just pass us the one tree. TODO: Eliminate inPattern, canRemedy, which have no place here.

    Definition Classes
    InferCheckable
  16. def checkKindBounds(tparams: List[Global.Symbol], targs: List[Global.Type], pre: Global.Type, owner: Global.Symbol): List[String]

  17. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. def containsUnchecked(tp: Global.Type): Boolean

    Does tp contain any types that cannot be checked at run-time (i.

    Does tp contain any types that cannot be checked at run-time (i.e., after erasure, will isInstanceOf[erased(tp)] imply conceptualIsInstanceOf[tp]?) we should find a way to ask erasure: hey, is tp going to make it through you with all of its isInstanceOf resolving powers intact? TODO: at the very least, reduce duplication wrt checkCheckable

  19. def ensuring(cond: (Analyzer.Inferencer) ⇒ Boolean, msg: ⇒ Any): Analyzer.Inferencer

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to Ensuring[Analyzer.Inferencer] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  20. def ensuring(cond: (Analyzer.Inferencer) ⇒ Boolean): Analyzer.Inferencer

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to Ensuring[Analyzer.Inferencer] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  21. def ensuring(cond: Boolean, msg: ⇒ Any): Analyzer.Inferencer

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to Ensuring[Analyzer.Inferencer] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  22. def ensuring(cond: Boolean): Analyzer.Inferencer

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to Ensuring[Analyzer.Inferencer] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  23. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  24. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  25. def explainTypes(tp1: Global.Type, tp2: Global.Type): Unit

  26. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  27. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to StringFormat performed by method any2stringfmt in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  28. def freeTypeParamsOfTerms(tp: Global.Type): List[Global.Symbol]

    Collects type parameters referred to in a type.

  29. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  30. def getContext: Analyzer.Context

  31. def hasExactlyNumParams(tp: Global.Type, n: Int): Boolean

  32. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  33. def inferArgumentInstance(tree: Global.Tree, undetparams: List[Global.Symbol], strictPt: Global.Type, lenientPt: Global.Type): Unit

    Substitute free type variables undetparams of polymorphic argument expression tree, given two prototypes strictPt, and lenientPt.

    Substitute free type variables undetparams of polymorphic argument expression tree, given two prototypes strictPt, and lenientPt. strictPt is the first attempt prototype where type parameters are left unchanged. lenientPt is the fall-back prototype where type parameters are replaced by WildcardTypes. We try to instantiate first to strictPt and then, if this fails, to lenientPt. If both attempts fail, an error is produced.

  34. def inferConstructorInstance(tree: Global.Tree, undetparams: List[Global.Symbol], pt0: Global.Type): Unit

    Substitute free type variables undetparams of type constructor tree in pattern, given prototype pt.

    Substitute free type variables undetparams of type constructor tree in pattern, given prototype pt.

    tree

    the constuctor that needs to be instantiated

    undetparams

    the undetermined type parameters

  35. def inferExprAlternative(tree: Global.Tree, pt: Global.Type): Unit

    Assign tree the symbol and type of the alternative which matches prototype pt, if it exists.

    Assign tree the symbol and type of the alternative which matches prototype pt, if it exists. If several alternatives match pt, take parameterless one. If no alternative matches pt, take the parameterless one anyway.

  36. def inferExprInstance(tree: Global.Tree, tparams: List[Global.Symbol], pt: Global.Type = WildcardType, treeTp0: Global.Type = null, keepNothings: Boolean = true, useWeaklyCompatible: Boolean = false): List[Global.Symbol]

    Infer type arguments targs for tparams of polymorphic expression in tree, given prototype pt.

    Infer type arguments targs for tparams of polymorphic expression in tree, given prototype pt.

    Substitute tparams to targs in tree, after adjustment by adjustTypeArgs, returning the type parameters that were not determined If passed, infers against specified type treeTp instead of tree.tp.

  37. def inferMethodAlternative(tree: Global.Tree, undetparams: List[Global.Symbol], argtpes: List[Global.Type], pt0: Global.Type, varArgsOnly: Boolean = false, lastInferAttempt: Boolean = true): Unit

    Assign tree the type of an alternative which is applicable to argtpes, and whose result type is compatible with pt.

    Assign tree the type of an alternative which is applicable to argtpes, and whose result type is compatible with pt. If several applicable alternatives exist, drop the alternatives which use default arguments, then select the most specialized one. If no applicable alternative exists, and pt != WildcardType, try again with pt = WildcardType. Otherwise, if there is no best alternative, error.

    argtpes

    contains the argument types. If an argument is named, as "a = 3", the corresponding type is NamedType("a", Int)'. If the name of some NamedType does not exist in an alternative's parameter names, the type is replaces by Unit, i.e. the argument is treated as an assignment expression.

  38. def inferMethodInstance(fn: Global.Tree, undetparams: List[Global.Symbol], args: List[Global.Tree], pt0: Global.Type): List[Global.Symbol]

    Substitute free type variables undetparams of application fn(args), given prototype pt.

    Substitute free type variables undetparams of application fn(args), given prototype pt.

    fn

    fn: the function that needs to be instantiated.

    undetparams

    the parameters that need to be determined

    args

    the actual arguments supplied in the call.

    returns

    The type parameters that remain uninstantiated, and that thus have not been substituted.

  39. def inferModulePattern(pat: Global.Tree, pt: Global.Type): Unit

  40. def inferPolyAlternatives(tree: Global.Tree, argtypes: List[Global.Type]): Unit

    Assign tree the type of all polymorphic alternatives with nparams as the number of type parameters, if it exists.

    Assign tree the type of all polymorphic alternatives with nparams as the number of type parameters, if it exists. If no such polymorphic alternative exist, error.

    tree

    ...

  41. def inferTypedPattern(tree0: Global.Tree, pattp: Global.Type, pt0: Global.Type, canRemedy: Boolean): Global.Type

  42. def instBounds(tvar: Global.TypeVar): (Global.Type, Global.Type)

  43. def instantiateTypeVar(tvar: Global.TypeVar): Unit

  44. def intersect(tp1: Global.Type, tp2: Global.Type): Global.Type

    Type intersection of simple type tp1 with general type tp2.

    Type intersection of simple type tp1 with general type tp2. The result eliminates some redundancies.

  45. def isAsSpecific(ftpe1: Global.Type, ftpe2: Global.Type): Boolean

    Is type ftpe1 strictly more specific than type ftpe2 when both are alternatives in an overloaded function?

    Is type ftpe1 strictly more specific than type ftpe2 when both are alternatives in an overloaded function?

    ftpe1

    ...

    ftpe2

    ...

    returns

    ...

    See also

    SLS (sec:overloading-resolution)

  46. def isCoercible(tp: Global.Type, pt: Global.Type): Boolean

    This is overridden in the Typer.

    This is overridden in the Typer.infer with some logic, but since that's the only place in the compiler an Inferencer is ever created, I suggest this should either be abstract or have the implementation.

  47. def isCompatibleArgs(tps: List[Global.Type], pts: List[Global.Type]): Boolean

  48. def isConservativelyCompatible(tp: Global.Type, pt: Global.Type): Boolean

    Like weakly compatible but don't apply any implicit conversions yet.

    Like weakly compatible but don't apply any implicit conversions yet. Used when comparing the result type of a method with its prototype. [Martin] I think Infer is also created by Erasure, with the default implementation of isCoercible

  49. def isInProperSubClassOrObject(sym1: Global.Symbol, sym2: Global.Symbol): Boolean

    is symbol sym1 defined in a proper subclass of symbol sym2?

  50. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  51. def isInstantiatable(tvars: List[Global.TypeVar]): Boolean

  52. def isPossiblyMissingArgs(found: Global.Type, req: Global.Type): Boolean

  53. def isProperSubClassOrObject(sym1: Global.Symbol, sym2: Global.Symbol): Boolean

    Is sym1 (or its companion class in case it is a module) a subclass of sym2 (or its companion class in case it is a module)?

  54. def isStrictlyMoreSpecific(ftpe1: Global.Type, ftpe2: Global.Type, sym1: Global.Symbol, sym2: Global.Symbol): Boolean

  55. def isUnitForVarArgs(args: List[AnyRef], params: List[Global.Symbol]): Boolean

    don't do a () to (()) conversion for methods whose second parameter is a varargs.

    don't do a () to (()) conversion for methods whose second parameter is a varargs. This is a fairly kludgey way to address #3224. We'll probably find a better way to do this by identifying tupled and n-ary methods, but thiws is something for a future major revision.

  56. def isWeaklyCompatible(tp: Global.Type, pt: Global.Type): Boolean

  57. def issue(err: Analyzer.AbsTypeError): Unit

  58. def makeFullyDefined(tp: Global.Type): Global.Type

    Replace any (possibly bounded) wildcard types in type tp by existentially bound variables.

  59. def methTypeArgs(tparams: List[Global.Symbol], formals: List[Global.Type], restpe: Global.Type, argtpes: List[Global.Type], pt: Global.Type): Result

    Return inferred type arguments, given type parameters, formal parameters, argument types, result type and expected result type.

    Return inferred type arguments, given type parameters, formal parameters, argument types, result type and expected result type. If this is not possible, throw a NoInstance exception. Undetermined type arguments are represented by definitions.NothingClass.tpe. No check that inferred parameters conform to their bounds is made here.

    tparams

    the type parameters of the method

    formals

    the value parameter types of the method

    argtpes

    the argument types of the application

    pt

    the expected return type of the application

    returns

    @see adjustTypeArgs

    Exceptions thrown
    NoInstance

  60. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  61. final def notify(): Unit

    Definition Classes
    AnyRef
  62. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  63. def protoTypeArgs(tparams: List[Global.Symbol], formals: List[Global.Type], restpe: Global.Type, pt: Global.Type): List[Global.Type]

    Return inferred proto-type arguments of function, given its type and value parameters and result type, and a prototype pt for the function result.

    Return inferred proto-type arguments of function, given its type and value parameters and result type, and a prototype pt for the function result. Type arguments need to be either determined precisely by the prototype, or they are maximized, if they occur only covariantly in the value parameter list. If instantiation of a type parameter fails, take WildcardType for the proto-type argument.

    tparams

    ...

    formals

    ...

    pt

    ...

    returns

    ...

  64. def setError[T <: Global.Tree](tree: T): T

  65. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  66. object toOrigin extends Global.TypeMap

  67. def toString(): String

    Definition Classes
    AnyRef → Any
  68. def tryTwice(infer: (Boolean) ⇒ Unit): Unit

    Try inference twice, once without views and once with views, unless views are already disabled.

    Try inference twice, once without views and once with views, unless views are already disabled.

    infer

    ...

  69. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  70. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  71. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  72. def widen(tp: Global.Type): Global.Type

  73. def [B](y: B): (Analyzer.Inferencer, B)

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to ArrowAssoc[Analyzer.Inferencer] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implict Value Members

  1. val self: Any

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to StringAdd performed by method any2stringadd in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (inferencer: StringAdd).self
    Definition Classes
    StringAdd
  2. val self: Any

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to StringFormat performed by method any2stringfmt in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (inferencer: StringFormat).self
    Definition Classes
    StringFormat

Deprecated Value Members

  1. def x: Analyzer.Inferencer

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to ArrowAssoc[Analyzer.Inferencer] performed by method any2ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (inferencer: ArrowAssoc[Analyzer.Inferencer]).x
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use leftOfArrow instead

  2. def x: Analyzer.Inferencer

    Implicit information
    This member is added by an implicit conversion from Analyzer.Inferencer to Ensuring[Analyzer.Inferencer] performed by method any2Ensuring in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (inferencer: Ensuring[Analyzer.Inferencer]).x
    Definition Classes
    Ensuring
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use resultOfEnsuring instead

Inherited from Analyzer.InferCheckable

Inherited from Analyzer.InferencerContextErrors

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from Analyzer.Inferencer to StringAdd

Inherited by implicit conversion any2stringfmt from Analyzer.Inferencer to StringFormat

Inherited by implicit conversion any2ArrowAssoc from Analyzer.Inferencer to ArrowAssoc[Analyzer.Inferencer]

Inherited by implicit conversion any2Ensuring from Analyzer.Inferencer to Ensuring[Analyzer.Inferencer]

Ungrouped