@@ -926,27 +926,21 @@ class Typer extends Namer
926926 isContextual = funFlags.is(Given ), isErased = funFlags.is(Erased ))
927927
928928 /** Typechecks dependent function type with given parameters `params` */
929- def typedDependent (params : List [ValDef ])(implicit ctx : Context ): Tree = {
930- completeParams(params)
931- val params1 = params.map(typedExpr(_).asInstanceOf [ValDef ])
932- if (! funFlags.isEmpty)
933- params1.foreach(_.symbol.setFlag(funFlags))
934- val resultTpt = typed(body)
935- val companion = MethodType .companion(
936- isContextual = funFlags.is(Given ), isErased = funFlags.is(Erased ))
937- val mt = companion.fromSymbols(params1.map(_.symbol), resultTpt.tpe)
929+ def typedDependent (params : List [ValDef ])(implicit ctx : Context ): Tree =
930+ val params1 =
931+ if funFlags.is(Given ) then params.map(_.withAddedFlags(Given ))
932+ else params
933+ val appDef0 = untpd.DefDef (nme.apply, Nil , List (params1), body, EmptyTree ).withSpan(tree.span)
934+ index(appDef0 :: Nil )
935+ val appDef = typed(appDef0).asInstanceOf [DefDef ]
936+ val mt = appDef.symbol.info.asInstanceOf [MethodType ]
938937 if (mt.isParamDependent)
939938 ctx.error(i " $mt is an illegal function type because it has inter-parameter dependencies " , tree.sourcePos)
940939 val resTpt = TypeTree (mt.nonDependentResultApprox).withSpan(body.span)
941- val typeArgs = params1 .map(_.tpt) :+ resTpt
940+ val typeArgs = appDef.vparamss.head .map(_.tpt) :+ resTpt
942941 val tycon = TypeTree (funCls.typeRef)
943- val core = assignType(cpy.AppliedTypeTree (tree)(tycon, typeArgs), tycon, typeArgs)
944- val appMeth = ctx.newSymbol(ctx.owner, nme.apply, Synthetic | Method | Deferred , mt, coord = body.span)
945- val appDef = assignType(
946- untpd.DefDef (appMeth.name, Nil , List (params1), resultTpt, EmptyTree ),
947- appMeth).withSpan(body.span)
942+ val core = AppliedTypeTree (tycon, typeArgs)
948943 RefinedTypeTree (core, List (appDef), ctx.owner.asClass)
949- }
950944
951945 args match {
952946 case ValDef (_, _, _) :: _ =>
0 commit comments