diff options
author | Martin Odersky <odersky@gmail.com> | 2015-04-13 15:47:54 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-04-13 16:06:01 +0200 |
commit | 046376e48bd3c4a294cef239a6cc77a61b62bc6e (patch) | |
tree | d38a3d329da8ece65029b6167e55c62e39e38d2c /tests | |
parent | 04eea24326c3a42ad908fe45e204af41b880f2cd (diff) | |
download | dotty-046376e48bd3c4a294cef239a6cc77a61b62bc6e.tar.gz dotty-046376e48bd3c4a294cef239a6cc77a61b62bc6e.tar.bz2 dotty-046376e48bd3c4a294cef239a6cc77a61b62bc6e.zip |
Added phase to check `New` nodes for instantiability.
- Abstract classes cannot be instantiated (exceptions:
parent news and Java annotations)
- Instantiateed class must conform to its self type.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/instantiateAbstract.scala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/neg/instantiateAbstract.scala b/tests/neg/instantiateAbstract.scala new file mode 100644 index 000000000..1e119a8b5 --- /dev/null +++ b/tests/neg/instantiateAbstract.scala @@ -0,0 +1,38 @@ +abstract class AA + +trait TT + +class A { self: B => + +} + +@scala.annotation.Annotation class C // error + +class B extends A() { +} + +object Test { + + @scala.annotation.Annotation type T = String // error + @scala.annotation.Annotation val x = 1 // error + @scala.annotation.Annotation def f = 1 //error + + (1: @scala.annotation.Annotation) // error + + + new AA // error + + new TT // error + + new A // error + +// the following are OK in Typer but would be caught later in RefChecks + + new A() {} + + new AA() {} + + object O extends A + + object OO extends AA +} |