summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorNada Amin <namin@alum.mit.edu>2012-10-21 16:12:00 +0200
committeramin <nada.amin@epfl.ch>2012-11-16 23:34:57 +0100
commit74ca558412b6ef9a8694a6f9d1034b9e09ba4af0 (patch)
tree3b84c0db711ae33552637f06374d96deedc5e20f /src/compiler
parent73d9ae5aa9c6866fe6794459eab9a6cd0dc5cdcd (diff)
downloadscala-74ca558412b6ef9a8694a6f9d1034b9e09ba4af0.tar.gz
scala-74ca558412b6ef9a8694a6f9d1034b9e09ba4af0.tar.bz2
scala-74ca558412b6ef9a8694a6f9d1034b9e09ba4af0.zip
SI-6551: don't insert apply call in polymorphic expression.
Don't rewrite an explicit apply method to dynamic polytypes.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala9
1 files changed, 5 insertions, 4 deletions
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