diff options
author | Dmitry Petrashko <dark@d-d.me> | 2017-04-19 06:58:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 06:58:40 -0500 |
commit | 02e38832668ed2a0504a77dd4f86270fa1a1d4bf (patch) | |
tree | 5f931022c36fc3cf8ef585e4bcc08f554f92142e /tests | |
parent | 4623e1282ebe7dfc31cb12411fed16457ed289ca (diff) | |
parent | 983ce8da3ce321bed7f8100c00b4aa709528208e (diff) | |
download | dotty-02e38832668ed2a0504a77dd4f86270fa1a1d4bf.tar.gz dotty-02e38832668ed2a0504a77dd4f86270fa1a1d4bf.tar.bz2 dotty-02e38832668ed2a0504a77dd4f86270fa1a1d4bf.zip |
Merge pull request #2267 from dotty-staging/fix-constant-lazy-vals
Fix #2266: Do not replace constant type lazy vals with constant.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run/if-with-constant-cond.check | 4 | ||||
-rw-r--r-- | tests/run/if-with-constant-cond.scala | 9 | ||||
-rw-r--r-- | tests/run/inline-constant-in-constructor-1.check | 3 | ||||
-rw-r--r-- | tests/run/inline-constant-in-constructor-1.scala | 15 | ||||
-rw-r--r-- | tests/run/inline-constant-in-constructor-2.check | 3 | ||||
-rw-r--r-- | tests/run/inline-constant-in-constructor-2.scala | 14 | ||||
-rw-r--r-- | tests/run/inline-constant-in-constructor-3.check | 4 | ||||
-rw-r--r-- | tests/run/inline-constant-in-constructor-3.scala | 19 | ||||
-rw-r--r-- | tests/run/inline-constant-lazy-val.check | 2 | ||||
-rw-r--r-- | tests/run/inline-constant-lazy-val.scala | 10 |
10 files changed, 83 insertions, 0 deletions
diff --git a/tests/run/if-with-constant-cond.check b/tests/run/if-with-constant-cond.check new file mode 100644 index 000000000..2e31d4f23 --- /dev/null +++ b/tests/run/if-with-constant-cond.check @@ -0,0 +1,4 @@ +cond1 +then1 +cond2 +else2 diff --git a/tests/run/if-with-constant-cond.scala b/tests/run/if-with-constant-cond.scala new file mode 100644 index 000000000..db5959c84 --- /dev/null +++ b/tests/run/if-with-constant-cond.scala @@ -0,0 +1,9 @@ + +object Test { + + def main(args: Array[String]): Unit = { + if ({ println("cond1"); true }: true) println("then1") else println("else1") + if ({ println("cond2"); false }: false) println("then2") else println("else2") + } + +}
\ No newline at end of file diff --git a/tests/run/inline-constant-in-constructor-1.check b/tests/run/inline-constant-in-constructor-1.check new file mode 100644 index 000000000..05035c26d --- /dev/null +++ b/tests/run/inline-constant-in-constructor-1.check @@ -0,0 +1,3 @@ +assert +s +r init diff --git a/tests/run/inline-constant-in-constructor-1.scala b/tests/run/inline-constant-in-constructor-1.scala new file mode 100644 index 000000000..11a727fd6 --- /dev/null +++ b/tests/run/inline-constant-in-constructor-1.scala @@ -0,0 +1,15 @@ + + +abstract class A { + def s: Boolean = { println("s"); r } + def r: Boolean +} + +object Test extends A { + assert({ println("assert"); r == s }) // r constant type not replaced by true, r not initialized yet + override val r: true = { + println("r init") + true + } + def main(args: Array[String]): Unit = {} +} diff --git a/tests/run/inline-constant-in-constructor-2.check b/tests/run/inline-constant-in-constructor-2.check new file mode 100644 index 000000000..05035c26d --- /dev/null +++ b/tests/run/inline-constant-in-constructor-2.check @@ -0,0 +1,3 @@ +assert +s +r init diff --git a/tests/run/inline-constant-in-constructor-2.scala b/tests/run/inline-constant-in-constructor-2.scala new file mode 100644 index 000000000..a8d351ab6 --- /dev/null +++ b/tests/run/inline-constant-in-constructor-2.scala @@ -0,0 +1,14 @@ + +abstract class A { + def s: Boolean = { println("s"); r } + def r: Boolean +} + +object Test extends A { + assert({ println("assert"); r == s }) // r constant type replaced by false + override val r: false = { + println("r init") + false + } + def main(args: Array[String]): Unit = {} +} diff --git a/tests/run/inline-constant-in-constructor-3.check b/tests/run/inline-constant-in-constructor-3.check new file mode 100644 index 000000000..b0171e3d9 --- /dev/null +++ b/tests/run/inline-constant-in-constructor-3.check @@ -0,0 +1,4 @@ +assert +r2 +s +r init diff --git a/tests/run/inline-constant-in-constructor-3.scala b/tests/run/inline-constant-in-constructor-3.scala new file mode 100644 index 000000000..621ace231 --- /dev/null +++ b/tests/run/inline-constant-in-constructor-3.scala @@ -0,0 +1,19 @@ + + +abstract class A { + def s: Boolean = { println("s"); r } + def r: Boolean +} + +object Test extends A { + assert({ println("assert"); r2 != s }) // s not initialized yet + def r2: true = { + println("r2") + true + } + override val r: true = { + println("r init") + true + } + def main(args: Array[String]): Unit = {} +} diff --git a/tests/run/inline-constant-lazy-val.check b/tests/run/inline-constant-lazy-val.check new file mode 100644 index 000000000..16858db7a --- /dev/null +++ b/tests/run/inline-constant-lazy-val.check @@ -0,0 +1,2 @@ +X +Y diff --git a/tests/run/inline-constant-lazy-val.scala b/tests/run/inline-constant-lazy-val.scala new file mode 100644 index 000000000..5f4aaa12b --- /dev/null +++ b/tests/run/inline-constant-lazy-val.scala @@ -0,0 +1,10 @@ + +object Test { + lazy val x: true = { println("X"); true } + + def main(args: Array[String]): Unit = { + lazy val y: true = { println("Y"); true } + x + y + } +}
\ No newline at end of file |