@@ -1245,11 +1245,11 @@ object Trees {
1245
1245
* innermost enclosing call for which the inlined version is currently
1246
1246
* processed.
1247
1247
*/
1248
- protected def inlineContext (call : Tree )(using Ctx , CState ): Context = ctx
1248
+ protected def inlineContext (call : Tree )(using Ctx , CState ): Ctx = ctx
1249
1249
1250
1250
abstract class TreeMap (val cpy : TreeCopier = inst.cpy) { self =>
1251
1251
def transform (tree : Tree )(using Ctx , CState ): Tree = {
1252
- inContext (
1252
+ inCtx (
1253
1253
if tree.source != ctx.source && tree.source.exists
1254
1254
then ctx.withSource(tree.source)
1255
1255
else ctx
@@ -1313,11 +1313,11 @@ object Trees {
1313
1313
case AppliedTypeTree (tpt, args) =>
1314
1314
cpy.AppliedTypeTree (tree)(transform(tpt), transform(args))
1315
1315
case LambdaTypeTree (tparams, body) =>
1316
- inContext (localCtx) {
1316
+ inCtx (localCtx) {
1317
1317
cpy.LambdaTypeTree (tree)(transformSub(tparams), transform(body))
1318
1318
}
1319
1319
case TermLambdaTypeTree (params, body) =>
1320
- inContext (localCtx) {
1320
+ inCtx (localCtx) {
1321
1321
cpy.TermLambdaTypeTree (tree)(transformSub(params), transform(body))
1322
1322
}
1323
1323
case MatchTypeTree (bound, selector, cases) =>
@@ -1335,17 +1335,17 @@ object Trees {
1335
1335
case EmptyValDef =>
1336
1336
tree
1337
1337
case tree @ ValDef (name, tpt, _) =>
1338
- inContext (localCtx) {
1338
+ inCtx (localCtx) {
1339
1339
val tpt1 = transform(tpt)
1340
1340
val rhs1 = transform(tree.rhs)
1341
1341
cpy.ValDef (tree)(name, tpt1, rhs1)
1342
1342
}
1343
1343
case tree @ DefDef (name, tparams, vparamss, tpt, _) =>
1344
- inContext (localCtx) {
1344
+ inCtx (localCtx) {
1345
1345
cpy.DefDef (tree)(name, transformSub(tparams), vparamss mapConserve (transformSub(_)), transform(tpt), transform(tree.rhs))
1346
1346
}
1347
1347
case tree @ TypeDef (name, rhs) =>
1348
- inContext (localCtx) {
1348
+ inCtx (localCtx) {
1349
1349
cpy.TypeDef (tree)(name, transform(rhs))
1350
1350
}
1351
1351
case tree @ Template (constr, parents, self, _) if tree.derived.isEmpty =>
@@ -1446,11 +1446,11 @@ object Trees {
1446
1446
case AppliedTypeTree (tpt, args) =>
1447
1447
this (this (x, tpt), args)
1448
1448
case LambdaTypeTree (tparams, body) =>
1449
- inContext (localCtx) {
1449
+ inCtx (localCtx) {
1450
1450
this (this (x, tparams), body)
1451
1451
}
1452
1452
case TermLambdaTypeTree (params, body) =>
1453
- inContext (localCtx) {
1453
+ inCtx (localCtx) {
1454
1454
this (this (x, params), body)
1455
1455
}
1456
1456
case MatchTypeTree (bound, selector, cases) =>
@@ -1466,15 +1466,15 @@ object Trees {
1466
1466
case UnApply (fun, implicits, patterns) =>
1467
1467
this (this (this (x, fun), implicits), patterns)
1468
1468
case tree @ ValDef (_, tpt, _) =>
1469
- inContext (localCtx) {
1469
+ inCtx (localCtx) {
1470
1470
this (this (x, tpt), tree.rhs)
1471
1471
}
1472
1472
case tree @ DefDef (_, tparams, vparamss, tpt, _) =>
1473
- inContext (localCtx) {
1473
+ inCtx (localCtx) {
1474
1474
this (this (vparamss.foldLeft(this (x, tparams))(apply), tpt), tree.rhs)
1475
1475
}
1476
1476
case TypeDef (_, rhs) =>
1477
- inContext (localCtx) {
1477
+ inCtx (localCtx) {
1478
1478
this (x, rhs)
1479
1479
}
1480
1480
case tree @ Template (constr, parents, self, _) if tree.derived.isEmpty =>
@@ -1538,7 +1538,7 @@ object Trees {
1538
1538
}.asInstanceOf [tree.ThisTree [T ]]
1539
1539
1540
1540
/** Delegate to FunProto or FunProtoTyped depending on whether the prefix is `untpd` or `tpd`. */
1541
- protected def FunProto (args : List [Tree ], resType : Type )(using Context ): ProtoTypes .FunProto
1541
+ protected def FunProto (args : List [Tree ], resType : Type )(using Ctx , CState ): ProtoTypes .FunProto
1542
1542
1543
1543
/** Construct the application `$receiver.$method[$targs]($args)` using overloading resolution
1544
1544
* to find a matching overload of `$method` if necessary.
@@ -1549,41 +1549,41 @@ object Trees {
1549
1549
*/
1550
1550
def applyOverloaded (
1551
1551
receiver : tpd.Tree , method : TermName , args : List [Tree ], targs : List [Type ],
1552
- expectedType : Type )(using parentCtx : Context , cs : CState ): tpd.Tree = {
1553
- given ctx as Context = parentCtx.retractMode(Mode .ImplicitsEnabled )
1554
- import dotty .tools .dotc .ast .tpd .TreeOps
1555
-
1556
- val typer = ctx.typer
1557
- val proto = FunProto (args, expectedType)
1558
- val denot = receiver.tpe.member(method)
1559
- assert(denot.exists, i " no member $receiver . $method, members = ${receiver.tpe.decls}" )
1560
- val selected =
1561
- if (denot.isOverloaded) {
1562
- def typeParamCount (tp : Type ) = tp.widen match {
1563
- case tp : PolyType => tp.paramInfos.length
1564
- case _ => 0
1552
+ expectedType : Type )(using parentCtx : Ctx , cs : CState ): tpd.Tree =
1553
+ withoutMode(Mode .ImplicitsEnabled ) {
1554
+ import dotty .tools .dotc .ast .tpd .TreeOps
1555
+
1556
+ val typer = ctx.typer
1557
+ val proto = FunProto (args, expectedType)
1558
+ val denot = receiver.tpe.member(method)
1559
+ assert(denot.exists, i " no member $receiver . $method, members = ${receiver.tpe.decls}" )
1560
+ val selected =
1561
+ if (denot.isOverloaded) {
1562
+ def typeParamCount (tp : Type ) = tp.widen match {
1563
+ case tp : PolyType => tp.paramInfos.length
1564
+ case _ => 0
1565
+ }
1566
+ val allAlts = denot.alternatives
1567
+ .map(denot => TermRef (receiver.tpe, denot.symbol))
1568
+ .filter(tr => typeParamCount(tr) == targs.length)
1569
+ .filter { _.widen match {
1570
+ case MethodTpe (_, _, x : MethodType ) => ! x.isImplicitMethod
1571
+ case _ => true
1572
+ }}
1573
+ val alternatives = ctx.typer.resolveOverloaded(allAlts, proto)
1574
+ assert(alternatives.size == 1 ,
1575
+ i " ${if (alternatives.isEmpty) " no" else " multiple" } overloads available for " +
1576
+ i " $method on ${receiver.tpe.widenDealiasKeepAnnots} with targs: $targs%, %; args: $args%, %; expectedType: $expectedType. " +
1577
+ i " all alternatives: ${allAlts.map(_.symbol.showDcl).mkString(" , " )}\n " +
1578
+ i " matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(" , " )}. " ) // this is parsed from bytecode tree. there's nothing user can do about it
1579
+ alternatives.head
1565
1580
}
1566
- val allAlts = denot.alternatives
1567
- .map(denot => TermRef (receiver.tpe, denot.symbol))
1568
- .filter(tr => typeParamCount(tr) == targs.length)
1569
- .filter { _.widen match {
1570
- case MethodTpe (_, _, x : MethodType ) => ! x.isImplicitMethod
1571
- case _ => true
1572
- }}
1573
- val alternatives = ctx.typer.resolveOverloaded(allAlts, proto)
1574
- assert(alternatives.size == 1 ,
1575
- i " ${if (alternatives.isEmpty) " no" else " multiple" } overloads available for " +
1576
- i " $method on ${receiver.tpe.widenDealiasKeepAnnots} with targs: $targs%, %; args: $args%, %; expectedType: $expectedType. " +
1577
- i " all alternatives: ${allAlts.map(_.symbol.showDcl).mkString(" , " )}\n " +
1578
- i " matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(" , " )}. " ) // this is parsed from bytecode tree. there's nothing user can do about it
1579
- alternatives.head
1580
- }
1581
- else TermRef (receiver.tpe, denot.symbol)
1582
- val fun = receiver.select(selected).appliedToTypes(targs)
1581
+ else TermRef (receiver.tpe, denot.symbol)
1582
+ val fun = receiver.select(selected).appliedToTypes(targs)
1583
1583
1584
- val apply = untpd.Apply (fun, args)
1585
- typer.ApplyTo (apply, fun, selected, proto, expectedType)
1586
- }
1584
+ val apply = untpd.Apply (fun, args)
1585
+ typer.ApplyTo (apply, fun, selected, proto, expectedType)
1586
+ }
1587
1587
1588
1588
1589
1589
def resolveConstructor (atp : Type , args : List [Tree ])(using Ctx , CState ): tpd.Tree = {
0 commit comments