summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala9
-rw-r--r--test/files/run/bug1110.scala11
2 files changed, 19 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index e05bed9682..7819ced3c2 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -408,7 +408,14 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
/* ### CALLING THE APPLY -> one for operators (see above), one for normal methods ### */
def callAsOperator(paramTypes: List[Type], resType: Type): Tree = localTyper typed {
def default = callAsMethod(paramTypes, resType)
- if (getPrimitiveReplacementForStructuralCall isDefinedAt ad.symbol.name) {
+ // This is more indirect than it should be (and I don't think it spots every
+ // case either) but it's the most direct way I could see to address ticket #1110
+ // given the information available from this vantage.
+ def useOperator =
+ (getPrimitiveReplacementForStructuralCall isDefinedAt ad.symbol.name) &&
+ ((resType :: paramTypes) forall (x => isValueClass(x.typeSymbol)))
+
+ if (useOperator) {
val (operator, test) = getPrimitiveReplacementForStructuralCall(ad.symbol.name)
def args = qual :: fixParams(params, paramTypes)
diff --git a/test/files/run/bug1110.scala b/test/files/run/bug1110.scala
new file mode 100644
index 0000000000..b0969f6aad
--- /dev/null
+++ b/test/files/run/bug1110.scala
@@ -0,0 +1,11 @@
+class Stuff {
+ def zoop(p: Any{def &(q: Int): Int}) = p & 7
+ def floop = new { def & = "Hello" }
+
+ assert((floop &) == "Hello")
+ assert(zoop(10) == 2)
+}
+
+object Test extends Application {
+ new Stuff
+} \ No newline at end of file