File tree 2 files changed +18
-1
lines changed
compiler/src/dotty/tools/dotc
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -428,7 +428,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
428
428
changePrec (GlobalPrec ) {
429
429
keywordStr(" throw " ) ~ toText(args.head)
430
430
}
431
- else if fun.symbol == defn.byNameMethod && ! printDebug then
431
+ else if fun.symbol == defn.byNameMethod && ! printDebug && ! ctx.settings. YtestPickler .value then
432
432
toText(args.head)
433
433
else if (! printDebug && fun.hasType && fun.symbol == defn.QuotedRuntime_exprQuote )
434
434
keywordStr(" '{" ) ~ toTextGlobal(args, " , " ) ~ keywordStr(" }" )
Original file line number Diff line number Diff line change @@ -222,6 +222,13 @@ class TreeChecker extends Phase with SymTransformer {
222
222
res
223
223
}
224
224
225
+ val arguments : mutable.Set [untpd.Tree ] = mutable.Set ()
226
+ private def withArgs [T ](args : List [untpd.Tree ])(op : => T ): T =
227
+ arguments ++= args
228
+ val res = op
229
+ arguments --= args
230
+ res
231
+
225
232
def assertDefined (tree : untpd.Tree )(using Context ): Unit =
226
233
if (tree.symbol.maybeOwner.isTerm) {
227
234
val sym = tree.symbol
@@ -446,6 +453,16 @@ class TreeChecker extends Phase with SymTransformer {
446
453
typed(tree.expr, pt1)
447
454
untpd.cpy.Typed (tree)(expr1, tpt1).withType(tree.typeOpt)
448
455
456
+ override def typedApply (tree : untpd.Apply , pt : Type )(using Context ): Tree =
457
+ if tree.fun.symbol == defn.byNameMethod then
458
+ assert(arguments.contains(tree),
459
+ i " unexpected <by-name> application $tree, \n which is not a method argument " )
460
+ ByName (typedUnadapted(tree.args.head, pt.widenByName))
461
+ else
462
+ withArgs(tree.args) {
463
+ super .typedApply(tree, pt)
464
+ }
465
+
449
466
private def checkOwner (tree : untpd.Tree )(using Context ): Unit = {
450
467
def ownerMatches (symOwner : Symbol , ctxOwner : Symbol ): Boolean =
451
468
symOwner == ctxOwner ||
You can’t perform that action at this time.
0 commit comments