1
+ // test mixin of getters / setters, and implementing abstract
2
+ // methods using @BeanProperty
3
+ class C extends T with BeanF {
4
+ def foo () {
5
+ setF(" doch!" )
6
+ setG(true )
7
+ this .getF()
8
+ }
9
+ }
10
+
11
+ trait T {
12
+ @ scala.beans.BeanProperty var f = " nei"
13
+ @ scala.beans.BooleanBeanProperty var g = false
14
+ }
15
+
16
+ trait BeanF {
17
+ def getF (): String
18
+ def setF (n : String ): Unit
19
+
20
+ def isG (): Boolean
21
+ def setG (nb : Boolean ): Unit
22
+ }
23
+
24
+ /*
25
+ @scala.beans.BeanProperty private[this] var f: String = "nei";
26
+ <accessor> def f: String = T.this.f;
27
+ <accessor> def f_=(x$1: String): Unit = T.this.f = x$1;
28
+ def setF(x$1: String): Unit = T.this.f = x$1;
29
+ @scala.beans.BooleanBeanProperty private[this] var g: Boolean = false;
30
+ <accessor> def g: Boolean = T.this.g;
31
+ <accessor> def g_=(x$1: Boolean): Unit = T.this.g = x$1;
32
+ def setG(x$1: Boolean): Unit = T.this.g = x$1;
33
+ def getF(): String = T.this.f;
34
+ def isG(): Boolean = T.this.g
35
+ */
36
+
37
+
38
+ trait T { final val bla : Int = 123 }
39
+ class C extends T // bla should be final in C
40
+
41
+
42
+
43
+ trait T { final val C = " S" }
44
+ // there should be a C method in `T$class`!
45
+ class C extends T { println(C ) }
46
+
47
+ trait T {
48
+ type Res
49
+ val x : Res = ???
50
+ }
51
+
52
+ abstract class MiddleMan extends T
53
+
54
+ class C extends MiddleMan with T
55
+
56
+ //
57
+
58
+ abstract class Context extends Aliases with AliasesOverrides
59
+
60
+ trait Aliases {
61
+ val TypeTag = " universe.TypeTag"
62
+ }
63
+
64
+ trait AliasesOverrides extends Aliases { // or self: Aliases =>
65
+ override val TypeTag = " the real universe.TypeTag"
66
+ }
67
+
68
+ // TODO: check that this prints the right thing....
69
+
70
+ // //////////
71
+
72
+ trait B { val y = " a" }
73
+ trait T extends B {
74
+ val x : y.type = y
75
+ }
76
+
77
+ // ///////////
78
+ trait Foo { self : Meh =>
79
+ def bar (x : String ) = x == " a"
80
+ private final val meh = bar(" a" )
81
+ }
82
+
83
+ abstract class Meh extends Foo
84
+ // ///////////
85
+
86
+ trait SymbolTable {
87
+ def currentRunId : Int
88
+ }
89
+
90
+ trait ReflectSetup extends SymbolTable {
91
+ override val currentRunId = 1
92
+ }
93
+
94
+ class G extends SymbolTable with ReflectSetup
95
+
96
+ trait OneVal { val x : Int = 123 }
97
+ // class Conflicting extends OneVal { def x: Int = 1 } // error expected TODO: right message
98
+ class OverridingVal extends OneVal { override val x : Int = ??? }
99
+
100
+
101
+ trait VolatileAbort {
102
+ @ volatile private var abortflag = false
103
+ }
104
+
105
+ class DefaultSignalling extends VolatileAbort
106
+
107
+ trait V {
108
+ // ok
109
+ // error: java.lang.IllegalArgumentException: Could not find proxy for val f: Function1 in List(value f, value v, trait V, package <empty>, package <root>) (currentOwner= value <local V$class> )
110
+ val v = { val f = (x : Int ) => x + 1 ; f(2 ) }
111
+
112
+ // ok
113
+ // assertion failed:
114
+ // Trying to access the this of another class: tree.symbol = trait V, class symbol = object V$class compilation unit: fields.scala
115
+ val developmentVersion =
116
+ for {
117
+ v <- scalaPropOrNone(" maven.version.number" )
118
+ if v endsWith " -SNAPSHOT"
119
+ ov <- scalaPropOrNone(" version.number" )
120
+ } yield ov
121
+
122
+ def scalaPropOrNone (name : String ): Option [String ] = ???
123
+ }
124
+
125
+ object O extends V
126
+
127
+
128
+ // done
129
+ // test/files/trait-defaults/fields.scala:24: error: double definition:
130
+ // def signalDelegate_=(x$1: Signalling): Unit at line 24 and
131
+ // def signalDelegate_=(x$1: Signalling): Unit at line 24
132
+ // have same type
133
+ // class SUB extends IterableSplitter
134
+ // ^
135
+ // one error found
136
+
137
+ trait Signalling
138
+
139
+ trait DelegatedSignalling extends Signalling {
140
+ var signalDelegate : Signalling
141
+ }
142
+
143
+ trait IterableSplitter extends DelegatedSignalling {
144
+ var signalDelegate : Signalling = ???
145
+ }
146
+
147
+ class SUB extends IterableSplitter
148
+
149
+
150
+
151
+ // package <empty> {
152
+ // abstract trait OneAbstractVar extends Object {
153
+ // <accessor> def OneAbstractVar$_setter_$x_=(x$1: Int): Unit;
154
+ // <stable> <accessor> def x(): Int
155
+ // };
156
+ // class ConcVar extends Object with OneAbstractVar {
157
+ // <accessor> def OneAbstractVar$_setter_$x_=(x$1: Int): Unit = ();
158
+ // private[this] val x: Int = _;
159
+ // override <stable> <accessor> def x(): Int = ConcVar.this.x;
160
+ // def <init>(): ConcVar = {
161
+ // ConcVar.super.<init>();
162
+ // OneAbstractVar$class./*OneAbstractVar$class*/$init$(ConcVar.this);
163
+ // ConcVar.this.x = scala.this.Predef.???();
164
+ // ()
165
+ // }
166
+ // };
167
+ // abstract trait OneAbstractVar$class extends {
168
+ // def /*OneAbstractVar$class*/$init$($this: OneAbstractVar): Unit = {
169
+ // $this.OneAbstractVar$_setter_$x_=(123);
170
+ // ()
171
+ // }
172
+ // }
173
+ // }
174
+
175
+ class Nest { val x = println(1 )}
176
+
177
+ package scala
178
+
179
+ trait OneConcreteVal [T ] {
180
+ @ deprecatedOverriding val x = 1 // : T = ???
181
+ @ volatile var vy = " a"
182
+ println(x)
183
+ def foo = x
184
+ }
185
+
186
+
187
+ trait OneOtherConcreteVal [T ] {
188
+ var y : T = ???
189
+ }
190
+
191
+ class C extends OneConcreteVal [Int ] with OneOtherConcreteVal [String ]
192
+
193
+ object T extends App {
194
+ val c = new C
195
+ println(c.x)
196
+ println(c.y)
197
+ }
198
+ /*
199
+ old decls for trait trait OneOtherConcreteVal: Scope{
200
+ def y(): Object;
201
+ def y_=(x$1: Object): Unit
202
+ }
203
+ new decls for trait trait OneOtherConcreteVal: Scope{
204
+ def y(): Object;
205
+ def y_=(x$1: Object): Unit;
206
+ def $init$(): Unit
207
+ }
208
+ old decls for trait trait OneConcreteVal: Scope{
209
+ val x(): Int
210
+ }
211
+ new decls for trait trait OneConcreteVal: Scope{
212
+ val x(): Int;
213
+ def $init$(): Unit;
214
+ private[this] def x_=(x$1: Int): Unit
215
+ }
216
+ old decls for class C: Scope{
217
+ def <init>(): C
218
+ }
219
+ mixing in List(method y, method y_=, value x, method x_=) from List(trait OneOtherConcreteVal, trait OneConcreteVal)
220
+ ()String
221
+ ()Object
222
+ ()String
223
+ ()Object
224
+ (x$1: String)Unit
225
+ (x$1: Object)Unit
226
+ ()Int
227
+ ()Int
228
+ ()Int
229
+ ()Int
230
+ (x$1: Int)Unit
231
+ (x$1: Int)Unit
232
+ new decls for class C: Scope{
233
+ def <init>(): C;
234
+ def y(): Object;
235
+ private[this] var y: Object;
236
+ def y_=(x$1: Object): Unit;
237
+ val x(): Int;
238
+ private[this] val x: Int;
239
+ private[this] def x_=(x$1: Int): Unit
240
+ }
241
+ */
242
+
243
+
244
+ class Meh {
245
+ final val x = 1
246
+ def foo = x
247
+ }
248
+ class CE extends Empty
249
+
250
+ trait T {
251
+ val abs : String
252
+ protected val protabs : String
253
+ val pub = " public"
254
+ protected val prot = " protected"
255
+ private val privvy = " private"
256
+ private [this ] val privateThis = " private[this]"
257
+ // TODO:
258
+ // final val const = "const"
259
+
260
+ trait Nested { println(abs + privateThis) }
261
+
262
+ object NO {
263
+ println(abs)
264
+ println(pub)
265
+ println(prot)
266
+ println(protabs)
267
+ println(privvy)
268
+ println(privateThis)
269
+ }
270
+
271
+ trait NT {
272
+ println(abs)
273
+ println(pub)
274
+ println(prot)
275
+ println(protabs)
276
+ println(privvy)
277
+ println(privateThis)
278
+ }
279
+
280
+ class NC {
281
+ println(abs)
282
+ println(pub)
283
+ println(prot)
284
+ println(protabs)
285
+ println(privvy)
286
+ println(privateThis)
287
+ }
288
+ }
289
+
290
+ class C extends AnyRef with T {
291
+ println(" x" )
292
+ val abs = " abstract"
293
+ println(" y" )
294
+ val protabs = " abstract protected"
295
+ final val const = " const"
296
+ println(" z" )
297
+ }
298
+
299
+ object Test extends C {
300
+ def main (args : Array [String ]): Unit = {
301
+ NO
302
+ new NT {}
303
+ new NC
304
+ }}
0 commit comments