@@ -692,26 +692,33 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
692692 .select(TermRef .withSig(receiver.tpe.normalizedPrefix, selected.termSymbol.asTerm))
693693 .appliedToTypes(targs)
694694
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)) {
699697 val defn = ctx.definitions
700698 val prefix = args.take(selected.widen.paramTypess.head.size - 1 )
701- lastParamType match {
699+ expectedType match {
702700 case defn.ArrayType (el) =>
703701 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
705707 prefix ::: List (tpd.Typed (lastParam, TypeTree (defn.ArrayType (el))))
706708 case _ =>
707709 ???
708710 }
709- // case defn.ArrayType(el) if(lastParam)
710711 case _ => args
711712 }
712713 } else args
713714 }
714715
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+
715722 val apply = untpd.Apply (fun, callArgs)
716723 new typer.ApplyToTyped (apply, fun, selected, callArgs, expectedType).result.asInstanceOf [Tree ] // needed to handle varargs
717724 }
0 commit comments