diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 6 | ||||
-rw-r--r-- | test/files/neg/t1215.check | 4 | ||||
-rw-r--r-- | test/files/neg/t1215.scala | 3 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 138d2f469d..529ec0444c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2634,8 +2634,10 @@ trait Typers { self: Analyzer => if (treeInfo.isVariableOrGetter(qual1)) { convertToAssignment(fun, qual1, name, args, ex) } else { - if (qual1.symbol.isValue) error(tree.pos, "reassignment to val") - else reportTypeError(fun.pos, ex) + if ((qual1.symbol ne null) && qual1.symbol.isValue) + error(tree.pos, "reassignment to val") + else + reportTypeError(fun.pos, ex) setError(tree) } case _ => diff --git a/test/files/neg/t1215.check b/test/files/neg/t1215.check new file mode 100644 index 0000000000..1f9dd6bf38 --- /dev/null +++ b/test/files/neg/t1215.check @@ -0,0 +1,4 @@ +t1215.scala:2: error: value += is not a member of Int + val x = 1 += 1 + ^ +one error found diff --git a/test/files/neg/t1215.scala b/test/files/neg/t1215.scala new file mode 100644 index 0000000000..0e994d06e2 --- /dev/null +++ b/test/files/neg/t1215.scala @@ -0,0 +1,3 @@ +object Test { + val x = 1 += 1 +} |