File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
src/dotty/tools/dotc/transform Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -96,14 +96,22 @@ class InterceptedMethods extends MiniPhaseTransform {
96
96
s " that means the intercepted methods set doesn't match the code " )
97
97
tree
98
98
}
99
- lazy val Select (qual, _) = tree.fun
99
+ lazy val qual = tree.fun match {
100
+ case Select (qual, _) => qual
101
+ case Ident (name) => EmptyTree
102
+ }
100
103
val Any_## = this .Any_##
101
104
val Any_!= = defn.Any_!=
102
105
val rewrite : Tree = tree.fun.symbol match {
103
106
case Any_## =>
104
107
poundPoundValue(qual)
105
108
case Any_!= =>
109
+ if (qual.isEmpty) {
110
+ ctx.error(ex " Binary operation != should have an operand on the left hand side " , tree.fun.pos)
111
+ tree
112
+ } else {
106
113
qual.select(defn.Any_== ).appliedToArgs(tree.args).select(defn.Boolean_! )
114
+ }
107
115
/*
108
116
/* else if (isPrimitiveValueClass(qual.tpe.typeSymbol)) {
109
117
// todo: this is needed to support value classes
Original file line number Diff line number Diff line change
1
+
2
+ object Test {
3
+ != (1 ) // error: Binary operation != should have an operand on the left hand side
4
+ != (" abc" ) // error: Binary operation != should have an operand on the left hand side
5
+ }
Original file line number Diff line number Diff line change
1
+
2
+ import scala .reflect .runtime .universe ._
3
+ import scala .reflect .runtime .{currentMirror => cm }
4
+
5
+ object Test extends App {
6
+ val mutant = new { val x = 2 }
7
+ val c = cm.classSymbol(mutant.getClass)
8
+ != (c) // error: Binary operation != should have an operand on the left hand side
9
+ println(c.fullName)
10
+ c.info.toString.lines
11
+ .filter(_ != " private var bitmap$init$0: Boolean" ) foreach println
12
+ }
You can’t perform that action at this time.
0 commit comments