abstract class Inferencer extends Analyzer.InferencerContextErrors with Analyzer.InferCheckable
- Alphabetic
- By Inheritance
- Inferencer
- InferCheckable
- InferencerContextErrors
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Inferencer()
Abstract Value Members
- abstract def context: Analyzer.Context
Concrete Value Members
-
object
InferErrorGen
- Definition Classes
- InferencerContextErrors
-
final
def
!=(arg0: Any): Boolean
Test two objects for inequality.
Test two objects for inequality.
- returns
true
if !(this == that), false otherwise.
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
Equivalent to
x.hashCode
except for boxed numeric types andnull
.Equivalent to
x.hashCode
except for boxed numeric types andnull
. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. Fornull
returns a hashcode wherenull.hashCode
throws aNullPointerException
.- returns
a hash value consistent with ==
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from Analyzer.Inferencer to any2stringadd[Analyzer.Inferencer] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (Analyzer.Inferencer, B)
- Implicit
- This member is added by an implicit conversion from Analyzer.Inferencer to ArrowAssoc[Analyzer.Inferencer] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
-
final
def
==(arg0: Any): Boolean
The expression
x == that
is equivalent toif (x eq null) that eq null else x.equals(that)
.The expression
x == that
is equivalent toif (x eq null) that eq null else x.equals(that)
.- returns
true
if the receiver object is equivalent to the argument;false
otherwise.
- Definition Classes
- AnyRef → Any
-
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 inrestpe
are taken to be undetermined
- it occurs in an invariant/contravariant position in
-
final
def
asInstanceOf[T0]: T0
Cast the receiver object to be of type
T0
.Cast the receiver object to be of type
T0
.Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression
1.asInstanceOf[String]
will throw aClassCastException
at runtime, while the expressionList(1).asInstanceOf[List[String]]
will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested type.- returns
the receiver object.
- Definition Classes
- Any
- Exceptions thrown
ClassCastException
if the receiver object is not an instance of the erasure of typeT0
.
-
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 treesite
with typepre
in current context. -
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.
-
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
- def checkKindBounds(tparams: List[Global.Symbol], targs: List[Global.Type], pre: Global.Type, owner: Global.Symbol): List[String]
-
def
clone(): AnyRef
Create a copy of the receiver object.
Create a copy of the receiver object.
The default implementation of the
clone
method is platform dependent.- returns
a copy of the receiver object.
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- Note
not specified by SLS as a member of AnyRef
- def eligibleForTupleConversion(formals: List[Global.Type], argsCount: Int): Boolean
-
def
eligibleForTupleConversion(paramsCount: Int, argsCount: Int, varargsTarget: Boolean): Boolean
True if the given parameter list can accept a tupled argument list, and the argument list can be tupled (based on its length.)
- def ensureFullyDefined(tp: Global.Type): Global.Type
-
def
ensuring(cond: (Analyzer.Inferencer) ⇒ Boolean, msg: ⇒ Any): Analyzer.Inferencer
- Implicit
- This member is added by an implicit conversion from Analyzer.Inferencer to Ensuring[Analyzer.Inferencer] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (Analyzer.Inferencer) ⇒ Boolean): Analyzer.Inferencer
- Implicit
- This member is added by an implicit conversion from Analyzer.Inferencer to Ensuring[Analyzer.Inferencer] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): Analyzer.Inferencer
- Implicit
- This member is added by an implicit conversion from Analyzer.Inferencer to Ensuring[Analyzer.Inferencer] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): Analyzer.Inferencer
- Implicit
- This member is added by an implicit conversion from Analyzer.Inferencer to Ensuring[Analyzer.Inferencer] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
final
def
eq(arg0: AnyRef): Boolean
Tests whether the argument (
that
) is a reference to the receiver object (this
).Tests whether the argument (
that
) is a reference to the receiver object (this
).The
eq
method implements an equivalence relation on non-null instances ofAnyRef
, and has three additional properties:- It is consistent: for any non-null instances
x
andy
of typeAnyRef
, multiple invocations ofx.eq(y)
consistently returnstrue
or consistently returnsfalse
. - For any non-null instance
x
of typeAnyRef
,x.eq(null)
andnull.eq(x)
returnsfalse
. null.eq(null)
returnstrue
.
When overriding the
equals
orhashCode
methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2
), they should be equal to each other (o1 == o2
) and they should hash to the same value (o1.hashCode == o2.hashCode
).- returns
true
if the argument is a reference to the receiver object;false
otherwise.
- Definition Classes
- AnyRef
- It is consistent: for any non-null instances
-
def
equals(arg0: Any): Boolean
The equality method for reference types.
- def explainTypes(tp1: Global.Type, tp2: Global.Type): Unit
-
def
finalize(): Unit
Called by the garbage collector on the receiver object when there are no more references to the object.
Called by the garbage collector on the receiver object when there are no more references to the object.
The details of when and if the
finalize
method is invoked, as well as the interaction betweenfinalize
and non-local returns and exceptions, are all platform dependent.- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- Note
not specified by SLS as a member of AnyRef
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from Analyzer.Inferencer to StringFormat[Analyzer.Inferencer] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
-
def
freeTypeParamsOfTerms(tp: Global.Type): List[Global.Symbol]
Collects type parameters referred to in a type.
-
final
def
getClass(): Class[_]
Returns the runtime class representation of the object.
Returns the runtime class representation of the object.
- returns
a class object corresponding to the runtime type of the receiver.
- Definition Classes
- AnyRef → Any
- def getContext: Analyzer.Context
-
def
hashCode(): Int
The hashCode method for reference types.
-
def
inferArgumentInstance(tree: Global.Tree, undetparams: List[Global.Symbol], strictPt: Global.Type, lenientPt: Global.Type): Unit
Substitute free type variables
undetparams
of polymorphic argument expressiontree
, given two prototypesstrictPt
, andlenientPt
.Substitute free type variables
undetparams
of polymorphic argument expressiontree
, given two prototypesstrictPt
, andlenientPt
.strictPt
is the first attempt prototype where type parameters are left unchanged.lenientPt
is the fall-back prototype where type parameters are replaced byWildcardType
s. We try to instantiate first tostrictPt
and then, if this fails, tolenientPt
. If both attempts fail, an error is produced. -
def
inferConstructorInstance(tree: Global.Tree, undetparams: List[Global.Symbol], pt0: Global.Type): Unit
Substitute free type variables
undetparams
of type constructortree
in pattern, given prototypept
.Substitute free type variables
undetparams
of type constructortree
in pattern, given prototypept
.- tree
the constructor that needs to be instantiated
- undetparams
the undetermined type parameters
- pt0
the expected result type of the instance
-
def
inferExprAlternative(tree: Global.Tree, pt: Global.Type): Global.Tree
Assign
tree
the symbol and type of the alternative which matches prototypept
, if it exists.Assign
tree
the symbol and type of the alternative which matches prototypept
, if it exists. If several alternatives matchpt
, take parameterless one. If no alternative matchespt
, take the parameterless one anyway. -
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
fortparams
of polymorphic expression intree
, given prototypept
.Infer type arguments
targs
fortparams
of polymorphic expression intree
, given prototypept
.Substitute
tparams
totargs
intree
, after adjustment byadjustTypeArgs
, returning the type parameters that were not determined If passed, infers against specified typetreeTp
instead oftree.tp
. -
def
inferMethodAlternative(tree: Global.Tree, undetparams: List[Global.Symbol], argtpes0: List[Global.Type], pt0: Global.Type): Unit
Assign
tree
the type of an alternative which is applicable toargtpes
, and whose result type is compatible withpt
.Assign
tree
the type of an alternative which is applicable toargtpes
, and whose result type is compatible withpt
. 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.- argtpes0
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 byUnit
, i.e. the argument is treated as an assignment expression.
-
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 applicationfn(args)
, given prototypept
.Substitute free type variables
undetparams
of applicationfn(args)
, given prototypept
.- 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.
- pt0
the expected type of the function application
- returns
The type parameters that remain uninstantiated, and that thus have not been substituted.
- def inferModulePattern(pat: Global.Tree, pt: Global.Type): Unit
-
def
inferPolyAlternatives(tree: Global.Tree, argtypes: List[Global.Type]): Unit
Assign
tree
the type of all polymorphic alternatives which have the same number of type parameters as doesargtypes
with all argtypes are within the corresponding type parameter bounds.Assign
tree
the type of all polymorphic alternatives which have the same number of type parameters as doesargtypes
with all argtypes are within the corresponding type parameter bounds. If no such polymorphic alternative exist, error. - def inferTypedPattern(tree0: Global.Tree, pattp: Global.Type, pt0: Global.Type, canRemedy: Boolean): Global.Type
- def instBounds(tvar: Global.TypeVar): Global.TypeBounds
- def instantiateTypeVar(tvar: Global.TypeVar): Unit
-
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.
-
def
isAsSpecific(ftpe1: Global.Type, ftpe2: Global.Type): Boolean
Is type
ftpe1
strictly more specific than typeftpe2
when both are alternatives in an overloaded function?Is type
ftpe1
strictly more specific than typeftpe2
when both are alternatives in an overloaded function?- See also
SLS (sec:overloading-resolution)
-
def
isCheckable(P0: Global.Type): Boolean
- Definition Classes
- InferCheckable
- def isCoercible(tp: Global.Type, pt: Global.Type): Boolean
- def isCompatibleArgs(tps: List[Global.Type], pts: List[Global.Type]): Boolean
- def isConservativelyCompatible(tp: Global.Type, pt: Global.Type): Boolean
-
def
isInProperSubClassOrObject(sym1: Global.Symbol, sym2: Global.Symbol): Boolean
is symbol
sym1
defined in a proper subclass of symbolsym2
? -
final
def
isInstanceOf[T0]: Boolean
Test whether the dynamic type of the receiver object is
T0
.Test whether the dynamic type of the receiver object is
T0
.Note that the result of the test is modulo Scala's erasure semantics. Therefore the expression
1.isInstanceOf[String]
will returnfalse
, while the expressionList(1).isInstanceOf[List[String]]
will returntrue
. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the specified type.- returns
true
if the receiver object is an instance of erasure of typeT0
;false
otherwise.
- Definition Classes
- Any
- def isInstantiatable(tvars: List[Global.TypeVar]): Boolean
-
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)?
- def isStrictlyMoreSpecific(ftpe1: Global.Type, ftpe2: Global.Type, sym1: Global.Symbol, sym2: Global.Symbol): Boolean
-
def
isUncheckable(P0: Global.Type): Boolean
- Definition Classes
- InferCheckable
- def isWeaklyCompatible(tp: Global.Type, pt: Global.Type): Boolean
-
def
makeFullyDefined(tp: Global.Type): Global.Type
Replace any (possibly bounded) wildcard types in type
tp
by existentially bound variables. -
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 bydefinitions.NothingTpe
. 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
- restpe
the result type of the method
- argtpes
the argument types of the application
- pt
the expected return type of the application
- returns
@see adjustTypeArgs
- Exceptions thrown
-
final
def
ne(arg0: AnyRef): Boolean
Equivalent to
!(this eq that)
.Equivalent to
!(this eq that)
.- returns
true
if the argument is not a reference to the receiver object;false
otherwise.
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
Wakes up a single thread that is waiting on the receiver object's monitor.
Wakes up a single thread that is waiting on the receiver object's monitor.
- Definition Classes
- AnyRef
- Note
not specified by SLS as a member of AnyRef
-
final
def
notifyAll(): Unit
Wakes up all threads that are waiting on the receiver object's monitor.
Wakes up all threads that are waiting on the receiver object's monitor.
- Definition Classes
- AnyRef
- Note
not specified by SLS as a member of AnyRef
-
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. - def setError[T <: Global.Tree](tree: T): T
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
Creates a String representation of this object.
Creates a String representation of this object. The default representation is platform dependent. On the java platform it is the concatenation of the class name, "@", and the object's hashcode in hexadecimal.
- returns
a String representation of the object.
- Definition Classes
- AnyRef → Any
-
def
tupleIfNecessary(formals: List[Global.Type], argtpes: List[Global.Type]): List[Global.Type]
If the argument list needs to be tupled for the parameter list, a list containing the type of the tuple.
If the argument list needs to be tupled for the parameter list, a list containing the type of the tuple. Otherwise, the original argument list.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
→[B](y: B): (Analyzer.Inferencer, B)
- Implicit
- This member is added by an implicit conversion from Analyzer.Inferencer to ArrowAssoc[Analyzer.Inferencer] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
-
object
AdjustedTypeArgs
[Martin] Can someone comment this please? I have no idea what it's for and the code is not exactly readable.
- object approximateAbstracts extends Global.TypeMap
- object toOrigin extends Global.TypeMap
The Scala compiler API.
The following resources are useful for Scala plugin/compiler development: