Skip to content

Fix #1665: Check that != has an operand on the left. #1685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions compiler/src/dotty/tools/dotc/transform/InterceptedMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,24 @@ class InterceptedMethods extends MiniPhaseTransform {
s"that means the intercepted methods set doesn't match the code")
tree
}
lazy val Select(qual, _) = tree.fun
lazy val qual = tree.fun match {
case Select(qual, _) => qual
case ident @ Ident(_) =>
ident.tpe match {
case TermRef(prefix: TermRef, _) =>
tpd.ref(prefix)
case TermRef(prefix: ThisType, _) =>
tpd.This(prefix.cls)
}

}
val Any_## = this.Any_##
val Any_!= = defn.Any_!=
val rewrite: Tree = tree.fun.symbol match {
case Any_## =>
poundPoundValue(qual)
poundPoundValue(qual)
case Any_!= =>
qual.select(defn.Any_==).appliedToArgs(tree.args).select(defn.Boolean_!)
qual.select(defn.Any_==).appliedToArgs(tree.args).select(defn.Boolean_!)
/*
/* else if (isPrimitiveValueClass(qual.tpe.typeSymbol)) {
// todo: this is needed to support value classes
Expand All @@ -121,7 +131,7 @@ class InterceptedMethods extends MiniPhaseTransform {
// we get a primitive form of _getClass trying to target a boxed value
// so we need replace that method name with Object_getClass to get correct behavior.
// See SI-5568.
qual.selectWithSig(defn.Any_getClass).appliedToNone
qual.selectWithSig(defn.Any_getClass).appliedToNone
case _ =>
tree
}
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i1665.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

object Test {
!=(1)
!=("abc")
1 != this
!=(this)
}