Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9cc281e

Browse files
committed
Notice args of forwarder when generating it
1 parent5381be8 commit9cc281e

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

‎src/compiler/scala/tools/nsc/ast/TreeGen.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,16 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL {
327327
enclosingStaticModules.foldLeft(tree)((tree, moduleClass)=> tree.substituteThis(moduleClass, gen.mkAttributedIdent(moduleClass.sourceModule)) )
328328
}
329329

330-
newDefDef(methSym, substThisForModule(moveToMethod(useMethodParams(fun.body))))(tpt=TypeTree(resTp))
330+
valbody= useMethodParams(fun.body)
331+
if (methParamSyms.exists(p=> isByNameParamType(p.info))) {
332+
valbynames= methParamSyms.zip(fun.vparams).collect {case (mp, vp)if isByNameParamType(mp.info)!= isByNameParamType(vp.tpt.tpe)=> mp }
333+
if (bynames.nonEmpty)
334+
body.foreach {
335+
case t@Ident(_)if bynames.contains(t.symbol)=> t.updateAttachment(PreserveArg)
336+
case _=>
337+
}
338+
}
339+
newDefDef(methSym, substThisForModule(moveToMethod(body)))(tpt=TypeTree(resTp))
331340
}
332341

333342
/**

‎src/compiler/scala/tools/nsc/transform/UnCurry.scala

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,6 @@ abstract class UnCurry extends InfoTransform
246246
else typeNewFunmatch {
247247
case typedNewFun@Block(stats,expr:Function)=>
248248
valexpansion= gen.expandFunction(localTyper)(expr, inConstructorFlag)
249-
expansionmatch {
250-
caseBlock(ClassDef(_, _, _,Template(_, _, body))::Nil, _)=>
251-
body.lastmatch {
252-
caseDefDef(_, _, _, _, _,Apply(_, args))=> noApply.addAll(args)// samDef args are pass-thru
253-
case _=>
254-
}
255-
case _=>
256-
}
257249
treeCopy.Block(typedNewFun, stats, expansion)
258250
case x=>thrownewMatchError(x)
259251
}
@@ -467,7 +459,7 @@ abstract class UnCurry extends InfoTransform
467459
else translateSynchronized(tree)match {
468460
case dd@DefDef(mods, name, tparams, _, tpt, rhs)=>
469461
// Remove default argument trees from parameter ValDefs, scala/bug#4812
470-
valvparamssNoRhs= dd.vparamssmapConserve (_mapConserve {p=>
462+
valvparamssNoRhs= dd.vparamss.mapConserve(_.mapConserve {p=>
471463
treeCopy.ValDef(p, p.mods, p.name, p.tpt,EmptyTree)
472464
})
473465

@@ -558,7 +550,7 @@ abstract class UnCurry extends InfoTransform
558550
if (isByNameRef(tree1)) {
559551
valtree2= tree1 setType functionType(Nil, tree1.tpe)
560552
return {
561-
if (noApplycontainstree2) tree2
553+
if (tree.attachments.contains[PreserveArg.type]|| noApply.contains(tree2)) tree2
562554
else localTyper.typedPos(tree1.pos)(Apply(Select(tree2, nme.apply),Nil))
563555
}
564556
}

‎src/reflect/scala/reflect/internal/StdAttachments.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,7 @@ trait StdAttachments {
186186

187187
/** This Bind tree was derived immediately from the given tree, for unused accounting.*/
188188
caseclassVarAlias(tree:Tree/*Bind | ValDef*/)extendsPlainAttachment
189+
190+
/** Do not mangle the arg. It is passed directly in a forwarding application.*/
191+
caseobjectPreserveArgextendsPlainAttachment
189192
}

‎src/reflect/scala/reflect/runtime/JavaUniverseForce.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
9292
this.DiscardedExpr
9393
this.BooleanParameterType
9494
this.VarAlias
95+
this.PreserveArg
9596
this.noPrint
9697
this.typeDebug
9798
// inaccessible: this.posAssigner

‎test/files/run/t11237.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//> abusing options -Vprint:~uncurry
1+
// using options -Vprint:~uncurry
2+
23
traitSemigroup[F] { self=>
34
defappend(f1:F,f2:=>F):F
45
valz=10

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp