@@ -29,17 +29,17 @@ object Inferencing {
29
29
* but only if the overall result of `isFullyDefined` is `true`.
30
30
* Variables that are successfully minimized do not count as uninstantiated.
31
31
*/
32
- def isFullyDefined (tp : Type , force : ForceDegree .Value )(implicit ctx : Context ): Boolean = {
32
+ def isFullyDefined (tp : Type , force : ForceDegree .Value )(using Context ): Boolean = {
33
33
val nestedCtx = ctx.fresh.setNewTyperState()
34
- val result = new IsFullyDefinedAccumulator (force)(nestedCtx).process(tp)
34
+ val result = new IsFullyDefinedAccumulator (force)(using nestedCtx).process(tp)
35
35
if (result) nestedCtx.typerState.commit()
36
36
result
37
37
}
38
38
39
39
/** The fully defined type, where all type variables are forced.
40
40
* Throws an error if type contains wildcards.
41
41
*/
42
- def fullyDefinedType (tp : Type , what : String , span : Span )(implicit ctx : Context ): Type =
42
+ def fullyDefinedType (tp : Type , what : String , span : Span )(using Context ): Type =
43
43
if (isFullyDefined(tp, ForceDegree .all)) tp
44
44
else throw new Error (i " internal error: type of $what $tp is not fully defined, pos = $span" ) // !!! DEBUG
45
45
@@ -52,7 +52,7 @@ object Inferencing {
52
52
* If none of (1) - (4) applies, the type variable is left uninstantiated.
53
53
* The method is called to instantiate type variables before an implicit search.
54
54
*/
55
- def instantiateSelected (tp : Type , tvars : List [Type ])(implicit ctx : Context ): Unit =
55
+ def instantiateSelected (tp : Type , tvars : List [Type ])(using Context ): Unit =
56
56
if (tvars.nonEmpty)
57
57
IsFullyDefinedAccumulator (
58
58
ForceDegree .Value (tvars.contains, IfBottom .flip), minimizeSelected = true
@@ -61,7 +61,7 @@ object Inferencing {
61
61
/** Instantiate any type variables in `tp` whose bounds contain a reference to
62
62
* one of the parameters in `tparams` or `vparamss`.
63
63
*/
64
- def instantiateDependent (tp : Type , tparams : List [Symbol ], vparamss : List [List [Symbol ]])(implicit ctx : Context ): Unit = {
64
+ def instantiateDependent (tp : Type , tparams : List [Symbol ], vparamss : List [List [Symbol ]])(using Context ): Unit = {
65
65
val dependentVars = new TypeAccumulator [Set [TypeVar ]] {
66
66
@ threadUnsafe lazy val params = (tparams :: vparamss).flatten
67
67
def apply (tvars : Set [TypeVar ], tp : Type ) = tp match {
@@ -108,7 +108,7 @@ object Inferencing {
108
108
* to their upper bound.
109
109
*/
110
110
private class IsFullyDefinedAccumulator (force : ForceDegree .Value , minimizeSelected : Boolean = false )
111
- (implicit ctx : Context ) extends TypeAccumulator [Boolean ] {
111
+ (using Context ) extends TypeAccumulator [Boolean ] {
112
112
113
113
private def instantiate (tvar : TypeVar , fromBelow : Boolean ): Type = {
114
114
val inst = tvar.instantiate(fromBelow)
@@ -167,7 +167,7 @@ object Inferencing {
167
167
* instantiate the type parameter to the lower bound's approximation
168
168
* (approximation because of possible F-bounds).
169
169
*/
170
- def replaceSingletons (tp : Type )(implicit ctx : Context ): Unit = {
170
+ def replaceSingletons (tp : Type )(using Context ): Unit = {
171
171
val tr = new TypeTraverser {
172
172
def traverse (tp : Type ): Unit = {
173
173
tp match {
@@ -190,7 +190,7 @@ object Inferencing {
190
190
}
191
191
192
192
/** If `tree` has a type lambda type, infer its type parameters by comparing with expected type `pt` */
193
- def inferTypeParams (tree : Tree , pt : Type )(implicit ctx : Context ): Tree = tree.tpe match {
193
+ def inferTypeParams (tree : Tree , pt : Type )(using Context ): Tree = tree.tpe match {
194
194
case tl : TypeLambda =>
195
195
val (tl1, tvars) = constrained(tl, tree)
196
196
var tree1 = AppliedTypeTree (tree.withType(tl1), tvars)
@@ -201,7 +201,7 @@ object Inferencing {
201
201
tree
202
202
}
203
203
204
- def isSkolemFree (tp : Type )(implicit ctx : Context ): Boolean =
204
+ def isSkolemFree (tp : Type )(using Context ): Boolean =
205
205
! tp.existsPart(_.isInstanceOf [SkolemType ])
206
206
207
207
/** The list of uninstantiated type variables bound by some prefix of type `T` which
@@ -212,7 +212,7 @@ object Inferencing {
212
212
* - The prefix `p` of a selection `p.f`.
213
213
* - The result expression `e` of a block `{s1; .. sn; e}`.
214
214
*/
215
- def tvarsInParams (tree : Tree , locked : TypeVars )(implicit ctx : Context ): List [TypeVar ] = {
215
+ def tvarsInParams (tree : Tree , locked : TypeVars )(using Context ): List [TypeVar ] = {
216
216
@ tailrec def boundVars (tree : Tree , acc : List [TypeVar ]): List [TypeVar ] = tree match {
217
217
case Apply (fn, _) => boundVars(fn, acc)
218
218
case TypeApply (fn, targs) =>
@@ -252,7 +252,7 @@ object Inferencing {
252
252
* -1 (minimize) if constraint is uniformly from below,
253
253
* 0 if unconstrained, or constraint is from below and above.
254
254
*/
255
- private def instDirection (param : TypeParamRef )(implicit ctx : Context ): Int = {
255
+ private def instDirection (param : TypeParamRef )(using Context ): Int = {
256
256
val constrained = ctx.typeComparer.fullBounds(param)
257
257
val original = param.binder.paramInfos(param.paramNum)
258
258
val cmp = ctx.typeComparer
@@ -267,7 +267,7 @@ object Inferencing {
267
267
* class type reference where the class has a companion module, a reference to
268
268
* that companion module. Otherwise NoType
269
269
*/
270
- def companionRef (tp : Type )(implicit ctx : Context ): Type =
270
+ def companionRef (tp : Type )(using Context ): Type =
271
271
tp.underlyingClassRef(refinementOK = true ) match {
272
272
case tp : TypeRef =>
273
273
val companion = tp.classSymbol.companionModule
@@ -281,7 +281,7 @@ object Inferencing {
281
281
* @return The list of type symbols that were created
282
282
* to instantiate undetermined type variables that occur non-variantly
283
283
*/
284
- def maximizeType (tp : Type , span : Span , fromScala2x : Boolean )(implicit ctx : Context ): List [Symbol ] = {
284
+ def maximizeType (tp : Type , span : Span , fromScala2x : Boolean )(using Context ): List [Symbol ] = {
285
285
Stats .record(" maximizeType" )
286
286
val vs = variances(tp)
287
287
val patternBound = new mutable.ListBuffer [Symbol ]
@@ -325,7 +325,7 @@ object Inferencing {
325
325
*
326
326
* we want to instantiate U to x.type right away. No need to wait further.
327
327
*/
328
- private def variances (tp : Type )(implicit ctx : Context ): VarianceMap = {
328
+ private def variances (tp : Type )(using Context ): VarianceMap = {
329
329
Stats .record(" variances" )
330
330
val constraint = ctx.typerState.constraint
331
331
@@ -400,7 +400,7 @@ trait Inferencing { this: Typer =>
400
400
* Then `Y` also occurs co-variantly in `T` because it needs to be minimized in order to constrain
401
401
* `T` the least. See `variances` for more detail.
402
402
*/
403
- def interpolateTypeVars (tree : Tree , pt : Type , locked : TypeVars )(implicit ctx : Context ): tree.type = {
403
+ def interpolateTypeVars (tree : Tree , pt : Type , locked : TypeVars )(using Context ): tree.type = {
404
404
val state = ctx.typerState
405
405
406
406
// Note that some variables in `locked` might not be in `state.ownedVars`
0 commit comments