diff options
author | Martin Odersky <odersky@gmail.com> | 2015-08-23 23:11:20 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-08-23 23:11:31 +0200 |
commit | b1aecb1a8d0c7982981296ac4bfa67d9db596e24 (patch) | |
tree | 0ed870be30732f2c9d56728cdaf29a10820f65cd /tests/pos/singletons.scala | |
parent | 5b454b1070c3018203263f3bda21db217ed84f3f (diff) | |
download | dotty-b1aecb1a8d0c7982981296ac4bfa67d9db596e24.tar.gz dotty-b1aecb1a8d0c7982981296ac4bfa67d9db596e24.tar.bz2 dotty-b1aecb1a8d0c7982981296ac4bfa67d9db596e24.zip |
Tests of functionality.
As the comment in pos/singletons.scala says, we currently
test only constant propagation during typer. We should also have a
test that literalize produces the literals in the right places.
Diffstat (limited to 'tests/pos/singletons.scala')
-rw-r--r-- | tests/pos/singletons.scala | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/pos/singletons.scala b/tests/pos/singletons.scala new file mode 100644 index 000000000..55f9b5ecb --- /dev/null +++ b/tests/pos/singletons.scala @@ -0,0 +1,40 @@ + +object Test { + + val x: 1 = 1 + final val y = x + val z: 1 = y + + object O { final val x = 42 } + val fourtyTwo: 42 = O.x + + final val a = { println("x"); 2 } // side effects don't matter + val b: 2 = a + + def f: 3 = 3 + val c = f + +} +/* To do: test that after erasure we have generated code like this: + * +package <empty> { + final lazy module val Test: Test$ = new Test$() + final module class Test$() extends Object() { this: <notype> => + <accessor> def x(): Int = 1 + final <accessor> def y(): Int = 1 + <accessor> def z(): Int = 1 + final lazy module val O: Test.O$ = new Test.O$() + final module class O$() extends Object() { this: <notype> => + final <accessor> def x(): Int = 42 + } + <accessor> def fourtyTwo(): Int = 42 + final <accessor> def a(): Int = { + println("x") + 2 + } + <accessor> def b(): Int = 2 + def f(): Int = 3 + <accessor> def c(): Int = Test.f() + } +} +*/ |