Skip to content

Commit 8371dfc

Browse files
committed
Drop explicit BYNAME pickles
Instead, drop <by-name> applications when pickling and reconstitute them based on formal parameter types when unpickling.
1 parent 40c6e70 commit 8371dfc

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,9 @@ class TreePickler(pickler: TastyPickler) {
418418
writeByte(THROW)
419419
pickleTree(args.head)
420420
else if fun.symbol eq defn.byNameMethod then
421-
writeByte(BYNAME)
422421
pickleTree(args.head)
422+
// <by-name>(...) applications are re-constituted when unpickling
423+
// based on formal parameter types.
423424
else
424425
writeByte(APPLY)
425426
withLength {

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,8 +1123,6 @@ class TreeUnpickler(reader: TastyReader,
11231123
New(readTpt())
11241124
case THROW =>
11251125
Throw(readTerm())
1126-
case BYNAME =>
1127-
ByName(readTerm())
11281126
case SINGLETONtpt =>
11291127
SingletonTypeTree(readTerm())
11301128
case BYNAMEtpt =>
@@ -1145,7 +1143,12 @@ class TreeUnpickler(reader: TastyReader,
11451143
tpd.Super(qual, mixId, mixTpe.typeSymbol)
11461144
case APPLY =>
11471145
val fn = readTerm()
1148-
tpd.Apply(fn, until(end)(readTerm()))
1146+
var args = until(end)(readTerm())
1147+
fn.tpe.widen match
1148+
case mt: MethodType =>
1149+
args = args.zipWithConserve(mt.paramInfos)(_.alignByName(_))
1150+
case _ =>
1151+
tpd.Apply(fn, args)
11491152
case TYPEAPPLY =>
11501153
tpd.TypeApply(readTerm(), until(end)(readTpt()))
11511154
case TYPED =>

tasty/src/dotty/tools/tasty/TastyFormat.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ Standard-Section: "ASTs" TopLevelStat*
8989
QUALTHIS typeIdent_Tree -- id.this, different from THIS in that it contains a qualifier ident with position.
9090
NEW clsType_Term -- new cls
9191
THROW throwableExpr_Term -- throw throwableExpr
92-
BYNAME expr_Term -- by-name argument
9392
NAMEDARG paramName_NameRef arg_Term -- paramName = arg
9493
APPLY Length fn_Term arg_Term* -- fn(args)
9594
TYPEAPPLY Length fn_Term arg_Type* -- fn[args]
@@ -512,7 +511,6 @@ object TastyFormat {
512511
final val RECtype = 100
513512
final val SINGLETONtpt = 101
514513
final val BOUNDED = 102
515-
final val BYNAME = 103
516514

517515
// Cat. 4: tag Nat AST
518516

@@ -790,7 +788,6 @@ object TastyFormat {
790788
case TYPEBOUNDStpt => "TYPEBOUNDStpt"
791789
case ANDtype => "ANDtype"
792790
case ORtype => "ORtype"
793-
case BYNAME => "BYNAME"
794791
case BYNAMEtype => "BYNAMEtype"
795792
case BYNAMEtpt => "BYNAMEtpt"
796793
case POLYtype => "POLYtype"

0 commit comments

Comments
 (0)