@@ -980,7 +980,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
980980 }
981981 }
982982
983- def applyOverloaded (receiver : Tree , method : TermName , args : List [Tree ], targs : List [Type ], expectedType : Type , isAnnotConstructor : Boolean = false )(implicit ctx : Context ): Tree = {
983+ def applyOverloaded (receiver : Tree , method : TermName , args : List [Tree ], targs : List [Type ], expectedType : Type )(implicit ctx : Context ): Tree = {
984984 val typer = ctx.typer
985985 val proto = new FunProtoTyped (args, expectedType)(typer)
986986 val denot = receiver.tpe.member(method)
@@ -998,7 +998,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
998998 assert(alternatives.size == 1 ,
999999 i " ${if (alternatives.isEmpty) " no" else " multiple" } overloads available for " +
10001000 i " $method on ${receiver.tpe.widenDealiasKeepAnnots} with targs: $targs%, %; args: $args%, % of types ${args.tpes}%, %; expectedType: $expectedType. " +
1001- i " isAnnotConstructor = $isAnnotConstructor. \n " +
10021001 i " all alternatives: ${allAlts.map(_.symbol.showDcl).mkString(" , " )}\n " +
10031002 i " matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(" , " )}. " ) // this is parsed from bytecode tree. there's nothing user can do about it
10041003 alternatives.head
@@ -1008,35 +1007,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
10081007 .select(TermRef (receiver.tpe, selected.termSymbol.asTerm))
10091008 .appliedToTypes(targs)
10101009
1011- def adaptLastArg (lastParam : Tree , expectedType : Type ) = {
1012- if (isAnnotConstructor && ! (lastParam.tpe <:< expectedType)) {
1013- val defn = ctx.definitions
1014- val prefix = args.take(selected.widen.paramInfoss.head.size - 1 )
1015- expectedType match {
1016- case defn.ArrayOf (el) =>
1017- lastParam.tpe match {
1018- case defn.ArrayOf (el2) if el2 <:< el =>
1019- // we have a JavaSeqLiteral with a more precise type
1020- // we cannot construct a tree as JavaSeqLiteral inferred to precise type
1021- // if we add typed than it would be both type-correct and
1022- // will pass Ycheck
1023- prefix ::: List (tpd.Typed (lastParam, TypeTree (defn.ArrayOf (el))))
1024- case _ =>
1025- ???
1026- }
1027- case _ => args
1028- }
1029- } else args
1030- }
1031-
1032- val callArgs : List [Tree ] = if (args.isEmpty) Nil else {
1033- val expectedType = selected.widen.paramInfoss.head.last
1034- val lastParam = args.last
1035- adaptLastArg(lastParam, expectedType)
1036- }
1037-
1038- val apply = untpd.Apply (fun, callArgs)
1039- new typer.ApplyToTyped (apply, fun, selected, callArgs, expectedType).result.asInstanceOf [Tree ] // needed to handle varargs
1010+ val apply = untpd.Apply (fun, args)
1011+ new typer.ApplyToTyped (apply, fun, selected, args, expectedType).result.asInstanceOf [Tree ] // needed to handle varargs
10401012 }
10411013
10421014 @ tailrec
0 commit comments