@@ -757,26 +757,27 @@ class Typer extends Namer
757
757
758
758
def typedFunctionType (tree : untpd.Function , pt : Type )(implicit ctx : Context ): Tree = {
759
759
val untpd .Function (args, body) = tree
760
- val (isContextual, isErased) = tree match {
761
- case tree : untpd.FunctionWithMods =>
762
- val isContextual = tree.mods.is(Contextual )
763
- var isErased = tree.mods.is(Erased )
764
- if (isErased && args.isEmpty) {
765
- ctx.error(" An empty function cannot not be erased" , tree.pos)
766
- isErased = false
767
- }
768
- (isContextual, isErased)
769
- case _ => (false , false )
760
+ var funFlags = tree match {
761
+ case tree : untpd.FunctionWithMods => tree.mods.flags
762
+ case _ => EmptyFlags
763
+ }
764
+ if (funFlags.is(Erased ) && args.isEmpty) {
765
+ ctx.error(" An empty function cannot not be erased" , tree.pos)
766
+ funFlags = funFlags &~ Erased
770
767
}
771
768
772
- val funCls = defn.FunctionClass (args.length, isContextual, isErased)
769
+ val funCls = defn.FunctionClass (args.length,
770
+ isContextual = funFlags.is(Contextual ), isErased = funFlags.is(Erased ))
773
771
774
772
/** Typechecks dependent function type with given parameters `params` */
775
773
def typedDependent (params : List [ValDef ])(implicit ctx : Context ): Tree = {
776
774
completeParams(params)
777
775
val params1 = params.map(typedExpr(_).asInstanceOf [ValDef ])
776
+ if (! funFlags.isEmpty)
777
+ params1.foreach(_.symbol.setFlag(funFlags))
778
778
val resultTpt = typed(body)
779
- val companion = MethodType .maker(isContextual = isContextual, isErased = isErased)
779
+ val companion = MethodType .maker(
780
+ isContextual = funFlags.is(Contextual ), isErased = funFlags.is(Erased ))
780
781
val mt = companion.fromSymbols(params1.map(_.symbol), resultTpt.tpe)
781
782
if (mt.isParamDependent)
782
783
ctx.error(i " $mt is an illegal function type because it has inter-parameter dependencies " , tree.pos)
@@ -2271,6 +2272,7 @@ class Typer extends Namer
2271
2272
2272
2273
def adaptToArgs (wtp : Type , pt : FunProto ): Tree = wtp match {
2273
2274
case wtp : MethodOrPoly =>
2275
+ def methodStr = methPart(tree).symbol.showLocated
2274
2276
if (matchingApply(wtp, pt))
2275
2277
if (pt.args.lengthCompare(1 ) > 0 && isUnary(wtp) && ctx.canAutoTuple)
2276
2278
adapt(tree, pt.tupled, locked)
@@ -2279,7 +2281,7 @@ class Typer extends Namer
2279
2281
else if (wtp.isContextual)
2280
2282
adaptNoArgs(wtp) // insert arguments implicitly
2281
2283
else
2282
- errorTree(tree, em " Missing arguments for ${methPart(tree).symbol.showLocated} " )
2284
+ errorTree(tree, em " Missing arguments for $methodStr " )
2283
2285
case _ => tryInsertApplyOrImplicit(tree, pt, locked) {
2284
2286
errorTree(tree, MethodDoesNotTakeParameters (tree))
2285
2287
}
0 commit comments