@@ -692,26 +692,33 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
692
692
.select(TermRef .withSig(receiver.tpe.normalizedPrefix, selected.termSymbol.asTerm))
693
693
.appliedToTypes(targs)
694
694
695
- val callArgs : List [Tree ] = if (args.isEmpty) Nil else {
696
- val lastParamType = selected.widen.paramTypess.head.last
697
- val lastParam = args.last
698
- if (isAnnotConstructor && ! (lastParam.tpe <:< lastParamType)) {
695
+ def adaptLastArg (lastParam : Tree , expectedType : Type ) = {
696
+ if (isAnnotConstructor && ! (lastParam.tpe <:< expectedType)) {
699
697
val defn = ctx.definitions
700
698
val prefix = args.take(selected.widen.paramTypess.head.size - 1 )
701
- lastParamType match {
699
+ expectedType match {
702
700
case defn.ArrayType (el) =>
703
701
lastParam.tpe match {
704
- case defn.ArrayType (el2) if (el2 <:< el) => // we have a JavaSeqLiteral with a more precise type
702
+ case defn.ArrayType (el2) if (el2 <:< el) =>
703
+ // we have a JavaSeqLiteral with a more precise type
704
+ // we cannot construct a tree as JavaSeqLiteral infered to precise type
705
+ // if we add typed than it would be both type-correct and
706
+ // will pass Ycheck
705
707
prefix ::: List (tpd.Typed (lastParam, TypeTree (defn.ArrayType (el))))
706
708
case _ =>
707
709
???
708
710
}
709
- // case defn.ArrayType(el) if(lastParam)
710
711
case _ => args
711
712
}
712
713
} else args
713
714
}
714
715
716
+ val callArgs : List [Tree ] = if (args.isEmpty) Nil else {
717
+ val expectedType = selected.widen.paramTypess.head.last
718
+ val lastParam = args.last
719
+ adaptLastArg(lastParam, expectedType)
720
+ }
721
+
715
722
val apply = untpd.Apply (fun, callArgs)
716
723
new typer.ApplyToTyped (apply, fun, selected, callArgs, expectedType).result.asInstanceOf [Tree ] // needed to handle varargs
717
724
}
0 commit comments