@@ -1245,11 +1245,11 @@ object Trees {
12451245 * innermost enclosing call for which the inlined version is currently
12461246 * processed.
12471247 */
1248- protected def inlineContext (call : Tree )(using Ctx , CState ): Context = ctx
1248+ protected def inlineContext (call : Tree )(using Ctx , CState ): Ctx = ctx
12491249
12501250 abstract class TreeMap (val cpy : TreeCopier = inst.cpy) { self =>
12511251 def transform (tree : Tree )(using Ctx , CState ): Tree = {
1252- inContext (
1252+ inCtx (
12531253 if tree.source != ctx.source && tree.source.exists
12541254 then ctx.withSource(tree.source)
12551255 else ctx
@@ -1313,11 +1313,11 @@ object Trees {
13131313 case AppliedTypeTree (tpt, args) =>
13141314 cpy.AppliedTypeTree (tree)(transform(tpt), transform(args))
13151315 case LambdaTypeTree (tparams, body) =>
1316- inContext (localCtx) {
1316+ inCtx (localCtx) {
13171317 cpy.LambdaTypeTree (tree)(transformSub(tparams), transform(body))
13181318 }
13191319 case TermLambdaTypeTree (params, body) =>
1320- inContext (localCtx) {
1320+ inCtx (localCtx) {
13211321 cpy.TermLambdaTypeTree (tree)(transformSub(params), transform(body))
13221322 }
13231323 case MatchTypeTree (bound, selector, cases) =>
@@ -1335,17 +1335,17 @@ object Trees {
13351335 case EmptyValDef =>
13361336 tree
13371337 case tree @ ValDef (name, tpt, _) =>
1338- inContext (localCtx) {
1338+ inCtx (localCtx) {
13391339 val tpt1 = transform(tpt)
13401340 val rhs1 = transform(tree.rhs)
13411341 cpy.ValDef (tree)(name, tpt1, rhs1)
13421342 }
13431343 case tree @ DefDef (name, tparams, vparamss, tpt, _) =>
1344- inContext (localCtx) {
1344+ inCtx (localCtx) {
13451345 cpy.DefDef (tree)(name, transformSub(tparams), vparamss mapConserve (transformSub(_)), transform(tpt), transform(tree.rhs))
13461346 }
13471347 case tree @ TypeDef (name, rhs) =>
1348- inContext (localCtx) {
1348+ inCtx (localCtx) {
13491349 cpy.TypeDef (tree)(name, transform(rhs))
13501350 }
13511351 case tree @ Template (constr, parents, self, _) if tree.derived.isEmpty =>
@@ -1446,11 +1446,11 @@ object Trees {
14461446 case AppliedTypeTree (tpt, args) =>
14471447 this (this (x, tpt), args)
14481448 case LambdaTypeTree (tparams, body) =>
1449- inContext (localCtx) {
1449+ inCtx (localCtx) {
14501450 this (this (x, tparams), body)
14511451 }
14521452 case TermLambdaTypeTree (params, body) =>
1453- inContext (localCtx) {
1453+ inCtx (localCtx) {
14541454 this (this (x, params), body)
14551455 }
14561456 case MatchTypeTree (bound, selector, cases) =>
@@ -1466,15 +1466,15 @@ object Trees {
14661466 case UnApply (fun, implicits, patterns) =>
14671467 this (this (this (x, fun), implicits), patterns)
14681468 case tree @ ValDef (_, tpt, _) =>
1469- inContext (localCtx) {
1469+ inCtx (localCtx) {
14701470 this (this (x, tpt), tree.rhs)
14711471 }
14721472 case tree @ DefDef (_, tparams, vparamss, tpt, _) =>
1473- inContext (localCtx) {
1473+ inCtx (localCtx) {
14741474 this (this (vparamss.foldLeft(this (x, tparams))(apply), tpt), tree.rhs)
14751475 }
14761476 case TypeDef (_, rhs) =>
1477- inContext (localCtx) {
1477+ inCtx (localCtx) {
14781478 this (x, rhs)
14791479 }
14801480 case tree @ Template (constr, parents, self, _) if tree.derived.isEmpty =>
@@ -1538,7 +1538,7 @@ object Trees {
15381538 }.asInstanceOf [tree.ThisTree [T ]]
15391539
15401540 /** 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
15421542
15431543 /** Construct the application `$receiver.$method[$targs]($args)` using overloading resolution
15441544 * to find a matching overload of `$method` if necessary.
@@ -1549,41 +1549,41 @@ object Trees {
15491549 */
15501550 def applyOverloaded (
15511551 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
15651580 }
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)
15831583
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+ }
15871587
15881588
15891589 def resolveConstructor (atp : Type , args : List [Tree ])(using Ctx , CState ): tpd.Tree = {
0 commit comments