@@ -344,6 +344,7 @@ object ProtoTypes {
344
344
trait ApplyingProto extends ProtoType // common trait of ViewProto and FunProto
345
345
trait FunOrPolyProto extends ProtoType : // common trait of PolyProto and FunProto
346
346
def applyKind : ApplyKind = ApplyKind .Regular
347
+ def applyStyle : ApplyStyle = ApplyStyle .Unknown
347
348
348
349
class FunProtoState {
349
350
@@ -368,9 +369,10 @@ object ProtoTypes {
368
369
* [](args): resultType
369
370
*
370
371
* @param args The untyped arguments to which the function is applied
371
- * @param resType The expeected result type
372
+ * @param resType The expected result type
372
373
* @param typer The typer to use for typing the arguments
373
374
* @param applyKind The kind of application (regular/using/tupled infix operand)
375
+ * @param applyStyle The [[ApplyStyle ]] of the application
374
376
* @param state The state object to use for tracking the changes to this prototype
375
377
* @param constrainResultDeep
376
378
* A flag to indicate that constrainResult on this prototype
@@ -379,6 +381,7 @@ object ProtoTypes {
379
381
case class FunProto (args : List [untpd.Tree ], resType : Type )(
380
382
typer : Typer ,
381
383
override val applyKind : ApplyKind ,
384
+ override val applyStyle : ApplyStyle ,
382
385
state : FunProtoState = new FunProtoState ,
383
386
val constrainResultDeep : Boolean = false )(using protoCtx : Context )
384
387
extends UncachedGroundType with ApplyingProto with FunOrPolyProto {
@@ -402,7 +405,7 @@ object ProtoTypes {
402
405
&& (typer eq this .typer)
403
406
&& constrainResultDeep == this .constrainResultDeep
404
407
then this
405
- else new FunProto (args, resultType)(typer, applyKind, constrainResultDeep = constrainResultDeep)
408
+ else new FunProto (args, resultType)(typer, applyKind, applyStyle, constrainResultDeep = constrainResultDeep)
406
409
407
410
/** @return True if all arguments have types.
408
411
*/
@@ -572,7 +575,7 @@ object ProtoTypes {
572
575
val dualArgs = args match
573
576
case untpd.Tuple (elems) :: Nil => elems
574
577
case _ => untpd.Tuple (args) :: Nil
575
- state.tupledDual = new FunProto (dualArgs, resultType)(typer, applyKind)
578
+ state.tupledDual = new FunProto (dualArgs, resultType)(typer, applyKind, applyStyle )
576
579
tupledDual
577
580
}
578
581
@@ -614,15 +617,15 @@ object ProtoTypes {
614
617
615
618
override def withContext (newCtx : Context ): ProtoType =
616
619
if newCtx `eq` protoCtx then this
617
- else new FunProto (args, resType)(typer, applyKind, state)(using newCtx)
620
+ else new FunProto (args, resType)(typer, applyKind, applyStyle, state)(using newCtx)
618
621
}
619
622
620
623
/** A prototype for expressions that appear in function position
621
624
*
622
625
* [](args): resultType, where args are known to be typed
623
626
*/
624
- class FunProtoTyped (args : List [tpd.Tree ], resultType : Type )(typer : Typer , applyKind : ApplyKind )(using Context )
625
- extends FunProto (args, resultType)(typer, applyKind):
627
+ class FunProtoTyped (args : List [tpd.Tree ], resultType : Type )(typer : Typer , applyKind : ApplyKind , applyStyle : ApplyStyle )(using Context )
628
+ extends FunProto (args, resultType)(typer, applyKind, applyStyle ):
626
629
override def typedArgs (norm : (untpd.Tree , Int ) => untpd.Tree )(using Context ): List [tpd.Tree ] = args
627
630
override def typedArg (arg : untpd.Tree , formal : Type )(using Context ): tpd.Tree = arg.asInstanceOf [tpd.Tree ]
628
631
override def allArgTypesAreCurrent ()(using Context ): Boolean = true
@@ -684,7 +687,10 @@ object ProtoTypes {
684
687
}
685
688
686
689
class UnapplyFunProto (argType : Type , typer : Typer )(using Context ) extends FunProto (
687
- untpd.TypedSplice (dummyTreeOfType(argType)(ctx.source)) :: Nil , WildcardType )(typer, applyKind = ApplyKind .Regular )
690
+ untpd.TypedSplice (dummyTreeOfType(argType)(ctx.source)) :: Nil , WildcardType
691
+ )(
692
+ typer, applyKind = ApplyKind .Regular , applyStyle = ApplyStyle .Parentheses
693
+ )
688
694
689
695
/** A prototype for expressions [] that are type-parameterized:
690
696
*
@@ -1006,7 +1012,7 @@ object ProtoTypes {
1006
1012
if (args eq tp.args) && (resTp eq tp.resultType) then
1007
1013
tp
1008
1014
else
1009
- FunProtoTyped (args, resTp)(ctx.typer, tp.applyKind)
1015
+ FunProtoTyped (args, resTp)(ctx.typer, tp.applyKind, tp.applyStyle )
1010
1016
case tp : IgnoredProto =>
1011
1017
WildcardType
1012
1018
case _ : ThisType | _ : BoundType => // default case, inlined for speed
0 commit comments