@@ -690,12 +690,10 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
690
690
val context1 = context.makeSilent(reportAmbiguousErrors, newtree)
691
691
context1.undetparams = context.undetparams
692
692
context1.savedTypeBounds = context.savedTypeBounds
693
- context1.namedApplyBlockInfo = context.namedApplyBlockInfo
694
693
val typer1 = newTyper(context1)
695
694
val result = op(typer1)
696
695
context.undetparams = context1.undetparams
697
696
context.savedTypeBounds = context1.savedTypeBounds
698
- context.namedApplyBlockInfo = context1.namedApplyBlockInfo
699
697
700
698
// If we have a successful result, emit any warnings it created.
701
699
if (! context1.reporter.hasErrors)
@@ -3298,11 +3296,6 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3298
3296
}
3299
3297
}
3300
3298
3301
- /** Is `tree` a block created by a named application?
3302
- */
3303
- def isNamedApplyBlock (tree : Tree ) =
3304
- context.namedApplyBlockInfo exists (_._1 == tree)
3305
-
3306
3299
def callToCompanionConstr (context : Context , calledFun : Symbol ) = {
3307
3300
calledFun.isConstructor && {
3308
3301
val methCtx = context.enclMethod
@@ -3534,7 +3527,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3534
3527
} else if (! allArgsArePositional(argPos) && ! sameLength(formals, params))
3535
3528
// !allArgsArePositional indicates that named arguments are used to re-order arguments
3536
3529
duplErrorTree(MultipleVarargError (tree))
3537
- else if (allArgsArePositional(argPos) && ! isNamedApplyBlock (fun)) {
3530
+ else if (allArgsArePositional(argPos) && ! NamedApplyBlock .unapply (fun).isDefined ) {
3538
3531
// if there's no re-ordering, and fun is not transformed, no need to transform
3539
3532
// more than an optimization, e.g. important in "synchronized { x = update-x }"
3540
3533
checkNotMacro()
@@ -3573,13 +3566,12 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3573
3566
val fun1 = transformNamedApplication(Typer .this , mode, pt)(fun, x => x)
3574
3567
if (fun1.isErroneous) duplErrTree
3575
3568
else {
3576
- assert(isNamedApplyBlock(fun1), fun1)
3577
- val NamedApplyInfo (qual, targs, previousArgss, _) = context.namedApplyBlockInfo.get._2
3569
+ val NamedApplyBlock (NamedApplyInfo (qual, targs, previousArgss, _)) = fun1
3578
3570
val blockIsEmpty = fun1 match {
3579
3571
case Block (Nil , _) =>
3580
3572
// if the block does not have any ValDef we can remove it. Note that the call to
3581
3573
// "transformNamedApplication" is always needed in order to obtain targs/previousArgss
3582
- context.namedApplyBlockInfo = None
3574
+ fun1.attachments.remove[ NamedApplyInfo ]
3583
3575
true
3584
3576
case _ => false
3585
3577
}
@@ -3595,7 +3587,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3595
3587
} else if (lencmp2 == 0 ) {
3596
3588
// useful when a default doesn't match parameter type, e.g. def f[T](x:T="a"); f[Int]()
3597
3589
checkNotMacro()
3598
- context.diagUsedDefaults = true
3590
+ context.set( ContextMode . DiagUsedDefaults )
3599
3591
doTypedApply(tree, if (blockIsEmpty) fun else fun1, allArgs, mode, pt)
3600
3592
} else {
3601
3593
rollbackNamesDefaultsOwnerChanges()
@@ -3607,7 +3599,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3607
3599
3608
3600
if (! sameLength(formals, args) || // wrong nb of arguments
3609
3601
(args exists isNamedArg) || // uses a named argument
3610
- isNamedApplyBlock (fun)) { // fun was transformed to a named apply block =>
3602
+ NamedApplyBlock .unapply (fun).isDefined ) { // fun was transformed to a named apply block =>
3611
3603
// integrate this application into the block
3612
3604
if (isApplyDynamicNamed(fun) && isDynamicRewrite(fun)) typedNamedApply(tree, fun, args, mode, pt)
3613
3605
else tryNamesDefaults
0 commit comments