blob: 706a715badd24b8de7c0560a1611f324d3045798 (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
class ann(i: Int) extends scala.annotation.Annotation
class cfann(x: String) extends annotation.ClassfileAnnotation
// annotations on abstract types
abstract class C1[@serializable @cloneable +T, U, V[_]]
abstract class C2[@deprecated
@ann(1) T <: Number,
V]
abstract class C3 {
@ann(2) type X <: Number
}
object Test {
// bug #1028
val x = 1
@ann(x) val a = ()
@ann({val yy = 2; yy}) val b = ()
val bb: Int @ann({val yy = 2; yy}) = 10
def c: Int @ann(x) = 1
def d: String @ann({val z = 0; z - 1}) = "2"
def e[@deprecated T, U](x: T) = x
//bug #1214
val y = new (Integer @ann(0))(2)
import scala.beans.BeanProperty
// bug #637
trait S { def getField(): Int }
class O extends S { @BeanProperty val field = 0 }
// bug #1070
trait T { @BeanProperty var field = 1 }
// annotation on annotation constructor
@(ann @ann(100))(200) def foo() = 300
// #2984
private final val NAMESPACE = "/info"
@cfann(x = NAMESPACE + "/index") def index = "success"
}
// test forward references to getters / setters
class BeanPropertyTests {
@scala.beans.BeanProperty lazy val lv1 = 0
def foo() {
val bp1 = new BeanPropertyTests1
println(lv1)
println(getLv1())
println(bp1.getLv2())
println(getV1())
setV1(10)
bp1.setV2(100)
}
@scala.beans.BeanProperty var v1 = 0
}
class BeanPropertyTests1 {
@scala.beans.BeanProperty lazy val lv2 = "0"
@scala.beans.BeanProperty var v2 = 0
}
// test mixin of getters / setters, and implementing abstract
// methods using @BeanProperty
class C extends T with BeanF {
def foo() {
setF("doch!")
setG(true)
this.getF()
}
}
trait T {
@scala.beans.BeanProperty var f = "nei"
@scala.beans.BooleanBeanProperty var g = false
}
trait BeanF {
def getF(): String
def setF(n: String): Unit
def isG(): Boolean
def setG(nb: Boolean): Unit
}
class Ann3(arr: Array[String]) extends annotation.ClassfileAnnotation
class Ann4(i: Int) extends annotation.ClassfileAnnotation
class Ann5(value: Class[_]) extends annotation.ClassfileAnnotation
object Test3 {
final val i = 1083
final val cls = classOf[String]
}
class Test4 {
@Ann3(arr = Array("dlkfj", "DSF"))
@Ann4(i = 2908)
@Ann4(i = Test3.i)
@Ann5(value = classOf[Int])
@Ann5(Test3.cls)
def foo {}
}
|