From 74ca558412b6ef9a8694a6f9d1034b9e09ba4af0 Mon Sep 17 00:00:00 2001 From: Nada Amin Date: Sun, 21 Oct 2012 16:12:00 +0200 Subject: SI-6551: don't insert apply call in polymorphic expression. Don't rewrite an explicit apply method to dynamic polytypes. --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index d3847de894..c1fd008e62 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1100,6 +1100,10 @@ trait Typers extends Modes with Adaptations with Tags { instantiateToMethodType(mt) case _ => + def shouldInsertApply(tree: Tree) = inAllModes(mode, EXPRmode | FUNmode) && (tree.tpe match { + case _: MethodType | _: OverloadedType | _: PolyType => false + case _ => applyPossible + }) def applyPossible = { def applyMeth = member(adaptToName(tree, nme.apply), nme.apply) dyna.acceptsApplyDynamic(tree.tpe) || ( @@ -1117,10 +1121,7 @@ trait Typers extends Modes with Adaptations with Tags { macroExpand(this, tree, mode, pt) else if ((mode & (PATTERNmode | FUNmode)) == (PATTERNmode | FUNmode)) adaptConstrPattern() - else if (inAllModes(mode, EXPRmode | FUNmode) && - !tree.tpe.isInstanceOf[MethodType] && - !tree.tpe.isInstanceOf[OverloadedType] && - applyPossible) + else if (shouldInsertApply(tree)) insertApply() else if (!context.undetparams.isEmpty && !inPolyMode(mode)) { // (9) assert(!inHKMode(mode), modeString(mode)) //@M -- cgit v1.2.3