summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala7
-rw-r--r--test/files/neg/bug839.check2
-rw-r--r--test/files/neg/checksensible.check11
-rw-r--r--test/files/neg/checksensible.scala5
-rw-r--r--test/files/pos/bug1010.scala15
5 files changed, 34 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index f591768e15..7e8f49ad2f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2259,11 +2259,10 @@ trait Typers requires Analyzer {
}
case ex: TypeError =>
fun match {
- case Select(qual, name) =>
+ case Select(qual, name)
+ if (mode & PATTERNmode) == 0 && nme.isOpAssignmentName(name) =>
val qual1 = typedQualifier(qual)
- if ((mode & PATTERNmode) == 0 &&
- nme.isOpAssignmentName(name) &&
- treeInfo.isVariableOrGetter(qual1)) {
+ if (treeInfo.isVariableOrGetter(qual1)) {
convertToAssignment(fun, qual1, name, args, ex)
} else {
reportTypeError(fun.pos, ex)
diff --git a/test/files/neg/bug839.check b/test/files/neg/bug839.check
index 281254ea00..ec5206effa 100644
--- a/test/files/neg/bug839.check
+++ b/test/files/neg/bug839.check
@@ -1,5 +1,5 @@
bug839.scala:25: error: method set cannot be accessed in object Test.this.FileImpl#treeBuilder
- because its instance type (Test.this.FileImpl#treeBuilder#global.Tree)scala.Unit contains a malformed type: object Test.this.FileImpl#treeBuilder#global
+ because its instance type (Test.this.Global#Tree)scala.Unit contains a malformed type: Test.this.Global#Tree
file.treeBuilder.set(nsc.get);
^
one error found
diff --git a/test/files/neg/checksensible.check b/test/files/neg/checksensible.check
index 6ca462b528..442780f55c 100644
--- a/test/files/neg/checksensible.check
+++ b/test/files/neg/checksensible.check
@@ -31,5 +31,14 @@ checksensible.scala:16: warning: comparing values of types scala.Int and scala.N
checksensible.scala:26: warning: comparing values of types scala.Unit and scala.Int using `!=' will always yield true
while((c = in.read) != -1) {
^
-10 warnings found
+checksensible.scala:33: warning: comparing values of types scala.Unit and scala.Boolean using `==' will always yield false
+ println({} == true)
+ ^
+checksensible.scala:35: warning: comparing a fresh object using `==' will always yield false
+ println(new Object == 1)
+ ^
+checksensible.scala:36: warning: comparing values of types scala.Int and java.lang.Object using `==' will always yield false
+ println(1 == (new Object))
+ ^
+13 warnings found
one error found
diff --git a/test/files/neg/checksensible.scala b/test/files/neg/checksensible.scala
index fa2655a241..7d0514396d 100644
--- a/test/files/neg/checksensible.scala
+++ b/test/files/neg/checksensible.scala
@@ -30,6 +30,11 @@ class Test {
in.close
}
+ println({} == true)
+ println("hello" == 2)
+ println(new Object == 1)
+ println(1 == (new Object))
+
def isabstract: int
}
diff --git a/test/files/pos/bug1010.scala b/test/files/pos/bug1010.scala
new file mode 100644
index 0000000000..7a1e6615e5
--- /dev/null
+++ b/test/files/pos/bug1010.scala
@@ -0,0 +1,15 @@
+class MailBox {
+ class Message
+ //type Message = AnyRef
+}
+
+abstract class Actor {
+ private val in = new MailBox
+
+ def send(msg: in.Message) = error("foo")
+
+ def unstable: Actor = error("foo")
+
+ def dubiousSend(msg: MailBox#Message): Nothing =
+ unstable.send(msg) // in.Message becomes unstable.Message, but that's ok since Message is a concrete type member
+}