blob: 974a5f1a5cf6e61a8a73e13b49b6ec3f1faf8ad8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/**
* Copyright (C) 2012 Typesafe Inc. <http://www.typesafe.com>
*/
package scala.async
package neg
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import org.junit.Test
@RunWith(classOf[JUnit4])
class AnfTransformNegSpec {
@Test
def `inlining block produces duplicate definition`() {
expectError("x is already defined as value x", "-cp target/scala-2.10/classes -deprecation -Xfatal-warnings") {
"""
| import scala.concurrent.ExecutionContext.Implicits.global
| import scala.concurrent.Future
| import scala.async.Async._
|
| async {
| val f = Future { 12 }
| val x = await(f)
|
| {
| val x = 42
| println(x)
| }
|
| x
| }
""".stripMargin
}
}
@Test
def `inlining block in tail position produces duplicate definition`() {
expectError("x is already defined as value x", "-cp target/scala-2.10/classes -deprecation -Xfatal-warnings") {
"""
| import scala.concurrent.ExecutionContext.Implicits.global
| import scala.concurrent.Future
| import scala.async.Async._
|
| async {
| val f = Future { 12 }
| val x = await(f)
|
| {
| val x = 42
| x
| }
| }
""".stripMargin
}
}
}
|