diff options
author | Paul Phillips <paulp@improving.org> | 2010-07-03 00:56:00 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-07-03 00:56:00 +0000 |
commit | 39e4641ec932965eaa9ef30b3954aef3f0579fa5 (patch) | |
tree | 6dce13c4da159d528826807c5cee1ff7b844fd3d /test/files/neg | |
parent | 322e856f132c4ee8ac651848a041b693f830371b (diff) | |
download | scala-39e4641ec932965eaa9ef30b3954aef3f0579fa5.tar.gz scala-39e4641ec932965eaa9ef30b3954aef3f0579fa5.tar.bz2 scala-39e4641ec932965eaa9ef30b3954aef3f0579fa5.zip |
When compilation fails because of an unimplemen...
When compilation fails because of an unimplemented abstract var, give
a more precise error message about what happened. Also avoid issuing
the same error twice because neither getter nor setter is implemented.
Closes #36, review by rytz.
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/abstract-vars.check | 21 | ||||
-rw-r--r-- | test/files/neg/abstract-vars.scala | 29 |
2 files changed, 50 insertions, 0 deletions
diff --git a/test/files/neg/abstract-vars.check b/test/files/neg/abstract-vars.check new file mode 100644 index 0000000000..8aa47745f6 --- /dev/null +++ b/test/files/neg/abstract-vars.check @@ -0,0 +1,21 @@ +abstract-vars.scala:5: error: class Fail1 needs to be abstract, since variable x is not defined +(Note that variables need to be initialized to be defined) +class Fail1 extends A { + ^ +abstract-vars.scala:9: error: class Fail2 needs to be abstract, since variable x in class A of type Int is not defined +(Note that variables need to be initialized to be defined) +class Fail2 extends A { } + ^ +abstract-vars.scala:11: error: class Fail3 needs to be abstract, since variable x in class A of type Int is not defined +(Note that an abstract var requires a setter in addition to the getter) +class Fail3 extends A { + ^ +abstract-vars.scala:14: error: class Fail4 needs to be abstract, since variable x in class A of type Int is not defined +(Note that an abstract var requires a setter in addition to the getter) +class Fail4 extends A { + ^ +abstract-vars.scala:18: error: class Fail5 needs to be abstract, since variable x in class A of type Int is not defined +(Note that an abstract var requires a getter in addition to the setter) +class Fail5 extends A { + ^ +5 errors found diff --git a/test/files/neg/abstract-vars.scala b/test/files/neg/abstract-vars.scala new file mode 100644 index 0000000000..df6109d3a8 --- /dev/null +++ b/test/files/neg/abstract-vars.scala @@ -0,0 +1,29 @@ +abstract class A { + var x: Int +} + +class Fail1 extends A { + var x: Int +} + +class Fail2 extends A { } + +class Fail3 extends A { + val x: Int = 5 +} +class Fail4 extends A { + def x: Int = 5 +} + +class Fail5 extends A { + def x_=(y: Int) = () +} + +class Success1 extends A { + val x: Int = 5 + def x_=(y: Int) = () +} + +class Success2 extends A { + var x: Int = 5 +} |