oop_SE.ttcn 29 KB
Newer Older
1
/******************************************************************************
Adam Knapp's avatar
Adam Knapp committed
2
 * Copyright (c) 2000-2021 Ericsson Telecom AB
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
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Baranyi, Botond
 *
 ******************************************************************************/

module oop_SE { //^In TTCN-3 module//

type component Comp {
  var integer cv_comp;
  const integer cc_comp := -1;
}

type port Port message {
  inout integer
}
with {
  extension "internal"
}

type record Rec {
  integer num,
  charstring str
}

const integer c := 3;

type class C0 { }

type class C1 extends Nonexistent { } //^In type definition// //^In superclass definition// //There is no local or imported definition with name `Nonexistent'//

type class C2 extends c { } //^In type definition// //^In superclass definition// //`c' is not a reference to a type//

type class C3 extends Rec { } //^In type definition// //^In superclass definition// //Class type expected instead of `@oop_SE.Rec'//


43
type class C4 { //^In type definition//
44
45
  private var integer m_private_inherited;
  /*protected*/ var charstring m_protected_inherited;
46
  public var Rec m_public_inherited; //Class members cannot be public//
47
48
49
50
51
52
53
54
  private function f_private_inherited() {}
  /*protected*/ function f_protected_inherited() {}
  public function f_public_inherited() {}
}

type class C5 extends C4 { //^In type definition//
  private var boolean m_private_own;
  /*protected*/ var float m_protected_own;
55
  public var octetstring m_public_own; //Class members cannot be public//
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
111
112
113
114
115
116
  private function f_private_own() {}
  /*protected*/ function f_protected_own() {}
  public function f_public_own() {}
  
  public function f_member_access_inside() { //^In function definition//
    log(m_private_inherited); //^In log statement// //The member definition `m_private_inherited' in class type `C5' is not visible in this scope//
    log(m_protected_inherited);
    log(m_public_inherited);
    log(m_private_own);
    log(m_protected_own);
    log(m_public_own);
    log(m_nonexistent); //^In log statement// //There is no local or imported definition with name `m_nonexistent'//
    f_private_inherited(); //^In function or altstep instance// //The method definition `f_private_inherited' in class type `C5' is not visible in this scope//
    f_protected_inherited();
    f_public_inherited();
    f_private_own();
    f_protected_own();
    f_public_own();
    f_nonexistent(); //^In function or altstep instance// //There is no local or imported definition with name `f_nonexistent'//
  }
}

function f_member_access_outside() { //^In function definition//
  var C5 obj := C5.create(1, "a", { 2, "b" }, true, 0.1, '12'O);
  log(obj.m_private_inherited); //^In log statement// //The member definition `m_private_inherited' in class type `C5' is not visible in this scope//
  log(obj.m_protected_inherited); //^In log statement// //The member definition `m_protected_inherited' in class type `C5' is not visible in this scope//
  log(obj.m_public_inherited);
  log(obj.m_private_own); //^In log statement// //The member definition `m_private_own' in class type `C5' is not visible in this scope//
  log(obj.m_protected_own); //^In log statement// //The member definition `m_protected_own' in class type `C5' is not visible in this scope//
  log(obj.m_public_own);
  log(obj.m_nonexistent); //^In log statement// //Reference to non-existent member `m_nonexistent' in class type `@oop_SE.C5'//
  obj.f_private_inherited(); //^In function instance// //The method definition `f_private_inherited' in class type `C5' is not visible in this scope//
  obj.f_protected_inherited(); //^In function instance// //The method definition `f_protected_inherited' in class type `C5' is not visible in this scope//
  obj.f_public_inherited();
  obj.f_private_own(); //^In function instance// //The method definition `f_private_own' in class type `C5' is not visible in this scope//
  obj.f_protected_own(); //^In function instance// //The method definition `f_protected_own' in class type `C5' is not visible in this scope//
  obj.f_public_own();
  obj.f_nonexistent(); //^In function instance// //Reference to non-existent method `f_nonexistent' in class type `@oop_SE.C5'//
}

type class C6 { //^In type definition//
  public function f_member_access_other_class() { //^In function definition//
    var C5 obj := C5.create(1, "a", { 2, "b" }, true, 0.1, '12'O);
    log(obj.m_private_inherited); //^In log statement// //The member definition `m_private_inherited' in class type `C5' is not visible in this scope//
    log(obj.m_protected_inherited); //^In log statement// //The member definition `m_protected_inherited' in class type `C5' is not visible in this scope//
    log(obj.m_public_inherited);
    log(obj.m_private_own); //^In log statement// //The member definition `m_private_own' in class type `C5' is not visible in this scope//
    log(obj.m_protected_own); //^In log statement// //The member definition `m_protected_own' in class type `C5' is not visible in this scope//
    log(obj.m_public_own);
    log(obj.m_nonexistent); //^In log statement// //Reference to non-existent member `m_nonexistent' in class type `@oop_SE.C5'//
    obj.f_private_inherited(); //^In function instance// //The method definition `f_private_inherited' in class type `C5' is not visible in this scope//
    obj.f_protected_inherited(); //^In function instance// //The method definition `f_protected_inherited' in class type `C5' is not visible in this scope//
    obj.f_public_inherited();
    obj.f_private_own(); //^In function instance// //The method definition `f_private_own' in class type `C5' is not visible in this scope//
    obj.f_protected_own(); //^In function instance// //The method definition `f_protected_own' in class type `C5' is not visible in this scope//
    obj.f_public_own();
    obj.f_nonexistent(); //^In function instance// //Reference to non-existent method `f_nonexistent' in class type `@oop_SE.C5'//
  }
}


117
type class C7 extends C9 { } //^In type definition// //^In superclass definition//
118

119
type class C8 extends C7 { } //^In type definition// //While checking embedded recursions\: Circular reference\: `@oop_SE.C8' -> `@oop_SE.C8.<superclass>' -> `@oop_SE.C7' -> `@oop_SE.C7.<superclass>' -> `@oop_SE.C9' -> `@oop_SE.C9.<superclass>' -> `@oop_SE.C8'//
120

121
type class C9 extends C8 { } //^In type definition// //^In superclass definition//
122

123
124
125
126
127
128
external const C0 ec_c0; //^In external constant definition// //External constant cannot be defined for class type `@oop_SE.C0'//
external const object ec_obj; //^In external constant definition// //External constant cannot be defined for class type `object'//
modulepar C0 mp_c0; //^In module parameter definition// //Type of module parameter cannot be or embed class type `@oop_SE.C0'//
modulepar object mp_obj; //^In module parameter definition// //Type of module parameter cannot be or embed class type `object'//
modulepar template C0 mpt_c0; //^In template module parameter definition// //Type of template module parameter cannot be class type `@oop_SE.C0'//
modulepar template object mpt_obj; //^In template module parameter definition// //Type of template module parameter cannot be class type `object'//
129
130

function f_defs() { //^In function definition//
131
132
133
134
135
136
137
138
  const C0 c_c0 := null; //^In constant definition// //Constant cannot be defined for class type `@oop_SE.C0'//
  const object c_obj := null; //^In constant definition// //Constant cannot be defined for class type `object'//
  var C0 v_c0;
  var object v_obj;
  template C0 t_c0 := *; //^In template definition// //Template cannot be defined for class type `@oop_SE.C0'//
  template object t_obj := *; //^In template definition// //Template cannot be defined for class type `object'//
  var template C0 vt_c0; //^In template variable definition// //Template variable cannot be defined for class type `@oop_SE.C0'//
  var template object vt_obj; //^In template variable definition// //Template variable cannot be defined for class type `object'//
139
140
141
142
}


type record RecClass { //^In type definition//
143
144
  C0 x, //^In record field// //Class type `@oop_SE.C0' cannot be embedded into another type//
  object y //^In record field// //Class type `object' cannot be embedded into another type//
145
146
147
}

type set SetClass { //^In type definition//
148
149
  C0 x, //^In set field// //Class type `@oop_SE.C0' cannot be embedded into another type//
  object y //^In set field// //Class type `object' cannot be embedded into another type//
150
151
152
}

type record of C0 RecOfClass; //^In type definition// //^In embedded type of record of// //Class type `@oop_SE.C0' cannot be embedded into another type//
153
type record of object RecOfObject; //^In type definition// //^In embedded type of record of// //Class type `object' cannot be embedded into another type//
154
155

type set of C0 SetOfClass; //^In type definition// //^In embedded type of set of// //Class type `@oop_SE.C0' cannot be embedded into another type//
156
type set of object SetOfObject; //^In type definition// //^In embedded type of set of// //Class type `object' cannot be embedded into another type//
157
158

type union UniClass { //^In type definition//
159
160
  C0 x, //^In union field// //Class type `@oop_SE.C0' cannot be embedded into another type//
  object y //^In union field// //Class type `object' cannot be embedded into another type//
161
162
163
164
165
166
167
168
169
}

function f_embedded_types() { //^In function definition//
  var RecClass v_rec := { x := C0.create };
  var SetClass v_set := { x := C0.create };
  var RecOfClass v_recof := { C0.create };
  var SetOfClass v_setof := { C0.create };
  var UniClass v_uni := { x := C0.create };
  var anytype v_any; //^In variable definition// //^In type definition//
Botond Baranyi's avatar
Botond Baranyi committed
170
  v_any.C0 := C0.create;
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
}


function f_type_compatibility() { //^In function definition//
  var C4 x1 := C4.create(1, "a", { 2, "b" });
  var C5 y1 := C4.create(1, "a", { 2, "b" }); //^In variable definition// //Incompatible class types: operation `create' should refer to `@oop_SE.C5' instead of `@oop_SE.C4'//
  var C4 x2 := C5.create(1, "a", { 2, "b" }, true, 0.1, '12'O);
  var C5 y2 := C5.create(1, "a", { 2, "b" }, true, 0.1, '12'O);
  var C4 x3 := y1;
  var C5 y3 := x1; //^In variable definition// //Type mismatch: a value of type `@oop_SE.C5' was expected instead of `@oop_SE.C4'//
  x3 := y2;
  y3 := x2; //^In variable assignment// //Type mismatch: a value of type `@oop_SE.C5' was expected instead of `@oop_SE.C4'//
  log(x1.m_public_inherited);
  log(y1.m_public_inherited);
  log(x1.m_public_own); //^In log statement// //Reference to non-existent member `m_public_own' in class type `@oop_SE.C4'//
  log(y1.m_public_own);
  x1.f_public_inherited();
  y1.f_public_inherited();
  x1.f_public_own(); //^In function instance// //Reference to non-existent method `f_public_own' in class type `@oop_SE.C4'//
  y1.f_public_own();
}


type component CT_RunsOn {
  var integer cv_runs_on;
  const integer cc_runs_on := 0;
}

type component CT_Mtc {
  var integer cv_mtc;
  const integer cc_mtc := 1;
202
  port Port pt;
203
204
205
206
207
}

type component CT_System {
  var integer cv_system;
  const integer cc_system := 2;
208
209
210
211
212
213
214
215
216
217
218
219
220
  port Port pt;
}

type component CT_RunsOn2 extends CT_RunsOn {
  var template integer cvt_runs_on := *;
}

type component CT_Mtc2 extends CT_Mtc {
  var template integer cvt_mtc := ?;
}

type component CT_System2 extends CT_System {
  var template integer cvt_system := omit;
221
222
223
224
225
226
227
228
229
230
231
232
233
234
}

type class C10 runs on CT_RunsOn mtc CT_Mtc system CT_System { //^In type definition//
  public function f_comp_visibility(in integer p1 := cc_runs_on, //^In function definition// //^In formal parameter list//
                                    in integer p2 := cc_mtc,
                                    in integer p3 := cc_system,
                                    in integer p4 := cc_comp) { //^In parameter// //^In default value// //There is no local or imported definition with name `cc_comp'//
    log(cv_runs_on);
    log(cv_mtc);
    log(cv_system);
    log(cv_comp); //^In log statement// //There is no local or imported definition with name `cv_comp'//
  }
}

235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
type class C11 extends C10 { //^In type definition//
  public function f_inherited_comp_visibility(in integer p1 := cc_runs_on, //^In function definition// //^In formal parameter list//
                                              in integer p2 := cc_mtc,
                                              in integer p3 := cc_system,
                                              in integer p4 := cc_comp) { //^In parameter// //^In default value// //There is no local or imported definition with name `cc_comp'//
    log(cv_runs_on);
    log(cv_mtc);
    log(cv_system);
    log(cv_comp); //^In log statement// //There is no local or imported definition with name `cv_comp'//
  }
}

type class C12 extends C10 runs on CT_RunsOn mtc CT_Mtc system CT_System { }

type class C13 extends C11 //^In type definition//
  runs on Comp //^In `runs on' clause// //The `runs on' component type of the subclass, `@oop_SE.Comp', is not compatible with the `runs on' component type of the superclass, `@oop_SE.CT_RunsOn'//
  mtc Comp //^In `mtc' clause// //The `mtc' component type of the subclass, `@oop_SE.Comp', is not compatible with the `mtc' component type of the superclass, `@oop_SE.CT_Mtc'//
  system Comp //^In `system' clause// //The `system' component type of the subclass, `@oop_SE.Comp', is not compatible with the `system' component type of the superclass, `@oop_SE.CT_System'//
  { }

type class C14 extends C11
  runs on CT_RunsOn2
  mtc CT_Mtc2
  system CT_System2
  { }

function f_good_comp_usage() runs on CT_RunsOn mtc CT_Mtc system CT_System {
  var C11 x := C11.create;
}

function f_bad_comp_usage() runs on Comp mtc Comp system Comp { //^In function definition//
  var C11 x := C11.create; //^In variable definition// //Runs on clause mismatch: A definition that runs on component type `@oop_SE.Comp' cannot create a value of class type `@oop_SE.C11', which runs on `@oop_SE.CT_RunsOn'// //Mtc clause mismatch: A definition that runs on component type `@oop_SE.Comp' cannot create a value of class type `@oop_SE.C11', which has `mtc' component type `@oop_SE.CT_Mtc'// //System clause mismatch: A definition that runs on component type `@oop_SE.Comp' cannot create a value of class type `@oop_SE.C11', which has `system' component type `@oop_SE.CT_System'//
}

function f_no_comp_usage() { //^In function definition//
  var C11 x := C11.create; //^In variable definition// //A definition without `runs on' clause cannot create a value of class type `@oop_SE.C11', which runs on component type `@oop_SE.CT_RunsOn'//
}


274
275
276
277
278
279
280
281
282
283
284
285
286
287
type class C15 { //^In type definition//
  var integer v;
  function f() { }
  function g() return boolean { return true; }
  function f_access_with_class_name() { //^In function definition//
    log(C5.v); //^In log statement// //Reference to a value, template, timer, port or class object was expected instead of type `@oop_SE.C5'//
    log(C5.g()); //^In log statement// //Reference to a value, template, timer, port or class object was expected instead of type `@oop_SE.C5'//
    C5.f(); //Reference to a function or altstep was expected instead of type `@oop_SE.C5', which cannot be invoked//
    C5.g(); //Reference to a function or altstep was expected instead of type `@oop_SE.C5', which cannot be invoked//
    if (C5.g()) { log(1); } //^In if statement// //Reference to a value was expected instead of type `@oop_SE.C5'//
    if (C5.v == 1) { log(2); } //^In if statement// //Reference to a value was expected instead of type `@oop_SE.C5'//
    var integer x1 := C5.v + 1; //^In variable definition// //^In the left operand of operation// //Reference to a value was expected instead of type `@oop_SE.C5'//
    var boolean x2 := C5.g(); //^In variable definition// //Reference to a value was expected instead of type `@oop_SE.C5'//
  }
288
289
}

290

291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342


function f_init_values() { //^In function definition//
  var integer v_int := 3;
  var template integer vt_int := (1..10);
  var C4 v1 := 1; //^In variable definition// //class value was expected//
  var C4 v2 := v_int; //^In variable definition// //Type mismatch\: a value of type `@oop_SE.C4' was expected instead of `integer'//
  var C4 v3 := valueof(vt_int) + v_int; //^In variable definition// //Incompatible value\: `@oop_SE.C4' value was expected//
  var C4 v4 := CT_RunsOn.create; //^In variable definition// //Incompatible value\: `@oop_SE.C4' value was expected//
  var C4 v5 := C11.create; //^In variable definition// //Incompatible class types\: operation `create' should refer to `@oop_SE.C4' instead of `@oop_SE.C11'//
}


type class C16 extends C15 { //^In type definition//
  create() : C15(1) { } //Previous definition of `create' is here//
  create(in integer p) : C15(p) { } //Duplicate definition with name `create'//
}

type class C17 { //^In type definition//
  create() : C15(1) { } //^In constructor definition// //^In super-constructor call// //Class type `@oop_SE.C17' does not have a superclass//
}

type class C18 extends C15 { //^In type definition//
  create() : C16() { } //^In constructor definition// //^In super-constructor call// //expected call to constructor of class type `@oop_SE.C15', instead of class type `@oop_SE.C16'//
}

type class C19 extends C15 { //^In type definition//
  create() { } //^In constructor definition// //Missing super-constructor call//
}

type class C20 extends C15 { //^In type definition//
  create() : f_embedded_types() { } //^In constructor definition// //^In super-constructor call// //Reference to constructor was expected instead of function//
}


type class @final @abstract C21 { } //^In type definition// //Final classes cannot be abstract//

type class @final C22 { }

type class C23 extends C22 { } //^In type definition// //^In superclass definition// //The superclass cannot be final//

type class @abstract C24 { //^In type definition//
  public function @abstract f1(in Nonexistent a); //^In abstract function definition// //^In formal parameter list// //^In parameter// //There is no local or imported definition with name `Nonexistent'//
  public function @abstract f2() return template Nonexistent; //^In abstract function definition// //^In return type// //There is no local or imported definition with name `Nonexistent'//
  public function @abstract f3() return Port; //^In abstract function definition// //^In return type// //Port type `@oop_SE.Port' cannot be the return type of an abstract function//
}

function f_inst_abstract() { //^In function definition//
  var C24 x := C24.create; //^In variable definition// //Cannot create an instance of abstract class type `@oop_SE.C24'//
}

type class @abstract C25 {
343
  public function @abstract f_abs(inout template integer p) return integer;
344
345
346
}

type class @abstract C26 extends C25 {
347
  public function @abstract f_abs2();
348
349
350
351
352
}

type class C27 extends C26 { } //^In type definition// //Missing implementation of abstract method `@oop_SE.C25.f_abs'// //Missing implementation of abstract method `@oop_SE.C26.f_abs2'//

type class C28 extends C25 { //^In type definition//
353
  var integer f_abs; //variable `@oop_SE.C28.f_abs' shadows inherited method `@oop_SE.C25.f_abs'//
354
355
356
}

type class C29 extends C26 { //^In type definition// //Missing implementation of abstract method `@oop_SE.C25.f_abs'//
357
  public function f_abs2() { }
358
359
360
}

type class C30 extends C26 {
361
362
  public function f_abs(inout template integer p) return integer { return 1; }
  public function f_abs2() { }
363
364
365
}

type class C31 extends C25 { //^In type definition//
366
  public function f_abs(in template integer p) { } //The prototype of method `f_abs' is not identical to that of inherited method `@oop_SE.C25.f_abs'//
367
368
369
}

type class C32 extends C25 { //^In type definition//
370
  public function f_abs(inout integer p) { } //The prototype of method `f_abs' is not identical to that of inherited method `@oop_SE.C25.f_abs'//
371
372
373
}

type class C33 extends C25 { //^In type definition//
374
  public function f_abs(inout template integer q) { } //The prototype of method `f_abs' is not identical to that of inherited method `@oop_SE.C25.f_abs'//
375
376
377
}

type class C34 extends C25 { //^In type definition//
378
  public function f_abs(inout template integer p) return boolean { return false; } //The prototype of method `f_abs' is not identical to that of inherited method `@oop_SE.C25.f_abs'//
379
380
}

381
382
383
384
385
386
387
388
type class @abstract C35 {
  public function @abstract f(in object p) return object;
}

type class C36 extends C35 {
  public function f(in object p) return object { return p; }
}

389

390
type class C37 {
391
392
  const integer c := 3;
  template charstring t := "";
393
394
395
396
397
  public function f1() return Rec { return { 2, "a" }; }
  public function f2() return template charstring { return ?; }
  create() {}
}

398
function f_global_left_hand_side() { //^In function definition//
399
400
401
402
  var C37 x := C37.create;
  x.f1() := { 3, "b" }; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C37.f1'//
  x.f1().num := 3; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C37.f1'//
  x.f2() := "x"; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C37.f2'//
403
404
}

405
406
407
408
type class C38 extends C37 { //^In type definition//
  public function f1() return Rec { return { 3, "b" }; }
  public function f2() return template charstring { return omit; }
  function f_class_left_hand_side() { //^In function definition//
409
410
411
    var C37 x := C37.create;
    x.c := 2; //^In variable assignment// //Reference to a variable or template variable was expected instead of constant `@oop_SE.C37.c'//
    x.t := *; //^In variable assignment// //Reference to a variable or template variable was expected instead of template `@oop_SE.C37.t'//
412
413
414
415
416
417
418
419
420
    this := null; //^In variable assignment// //Reference to a variable or template variable was expected instead of type `@oop_SE.C38'//
    this.c := 4; //^In variable assignment// //Reference to a variable or template variable was expected instead of constant `@oop_SE.C37.c'//
    this.t := ?; //^In variable assignment// //Reference to a variable or template variable was expected instead of template `@oop_SE.C37.t'//
    this.f1().str := "x"; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C38.f1'//
    this.f2() := ?; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C38.f2//
    super.f1().str := "x"; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C38.f1'//
    super.f2() := ?; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C38.f2//
  }
}
421

422
423

type class C39 {
424
425
426
427
  public function f_def(in integer p := 3) return integer { return p; }
}

function f_default() { //^In function definition//
428
429
  var C39 x := C39.create;
  var integer ret1 := x.f_def; //^In variable definition// //Invalid reference to method `f_def' in class type `@oop_SE.C39', reference to a member was expected instead//
430
431
432
433
  var integer ret2 := x.f_def();
}


434
type external class C40 {
435
  create(in integer x);
436
  function f1(in integer p) return octetstring;
437
438
439
  external function f2();
}

440
441
type external class C41 extends C40 { //^In type definition//
  create();
442
443
444
445
446
  const charstring c := "a"; //An external class cannot contain a constant//
  template charstring t := "b"; //An external class cannot contain a template//
  var charstring v; //An external class cannot contain a variable//
  var template charstring vt; //An external class cannot contain a template variable//
  timer tmr; //An external class cannot contain a timer//
447
448
449
  function g1() { } //An external class cannot contain a function//
  function g2(in charstring x) return charstring { return x; } //An external class cannot contain a function//
  function g3() return template charstring { return ?; } //An external class cannot contain a function//
450
451
452
453
454
455
456
457
}

type external class @abstract C42 { //^In type definition// //External classes cannot be abstract//
  function @abstract f(); //An external class cannot contain a function//
}

type external class C43 extends C39 { } //^In type definition// //^In superclass definition// //An external class cannot extend an internal class//

458
type class C44 extends C40 { //^In type definition//
459
  external function f();
460
  create(); //^In constructor definition// //Missing super-constructor call// //Missing constructor body//
461
462
}

463
464
465
466
467
468
469
470
471
472
type class C45 { //^In type definition//
  function f(); //^In external function definition// //Missing function body or `external' keyword//
}


type class C46 extends object { }


type class C47 {
  const integer m1 := 3;
473
  public function m2() return boolean { return true; }
474
  function m3(in integer p) return charstring { return int2str(p); }
475
  function @final m4() { }
476
477
478
479
480
481
}

type class C48 extends C47 { //^In type definition//
  var template octetstring m1; //template variable `@oop_SE.C48.m1' shadows inherited member `@oop_SE.C47.m1'//
  var integer m2; //variable `@oop_SE.C48.m2' shadows inherited method `@oop_SE.C47.m2'//
  function m3() return charstring { return "1"; } //The prototype of method `m3' is not identical to that of inherited method `@oop_SE.C47.m3'//
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
  function m4() { } //Cannot override final method `@oop_SE.C47.m4'//
}


function f_of_operator() { //^In function definition//
  var C0 x := C0.create;
  if (x of object) { log(1); }
  if (x of C0) { log(2); }
  if (x of C5) { log(3); } //^In if statement// //Control never reaches this code because the conditional expression evaluates to false//
  if (x of Comp) { log(4); } //^In if statement// //^In the second operand of operation `of'// //Class type was expected//
  if (C0 of C0) { log(5); } //^In if statement// //^In the first operand of operation `of'// //Reference to a variable or value parameter was expected instead of type `@oop_SE.C0'//
}

function f_select_class() { //^In function definition//
  var C0 x := C0.create;
  select class (x) { //^In select class statement//
    case (C0) { log(1); }
    case (C5) { log(2); } //^In select class case statement// //Control never reaches this code because the case will never be chosen//
    case else { log(3); }
    case (Comp) { log(4); } //^In select class case statement// //Control never reaches this code because of previous effective case\(s\)// //Class type was expected//
  }
  var integer y;
  select class (y) { //^In select class statement// //Reference to a class object was expected//
    case (object) { log(5); }
    case else { log(6); }
  }
}

function f_casting() { //^In function definition//
  var C35 x1 := C36.create;
  var C36 x2 := x1 => C36;
  var C0 x3 := x1 => C0; //^In variable definition// //^In the second operand of operation `=>'// //Cannot cast an object of class type `@oop_SE.C35' to class type `@oop_SE.C0'//
514
  var C35 x4 := x2 => (x1);
515
516
517
  var C36 x5 := c => C36; //^In variable definition// //^In the first operand of operation `=>'// //Reference to a variable or value parameter was expected instead of constant `@oop_SE.c'//
  var Rec x6 := x1 => Rec; //^In variable definition// //^In the second operand of operation `=>'// //Class type was expected//
  var integer x7 := x1 => (x6); //^In variable definition// //^In the second operand of operation `=>'// //Class type was expected//
518
519
}

520
521
522
523
524
525
526
function f_parameters(in boolean p1, inout boolean p2, out boolean p3) { }

function f_param_test() { //^In function definition//
  var C47 x := C47.create(1);
  f_parameters(x.m2(), x.m2(), x.m2()); //^In function instance// //^In actual parameter list of function// //^In parameter #2// //^In parameter #3// //Reference to a variable or value parameter was expected for an \`inout\' value parameter instead of function// //Reference to a variable or value parameter was expected for an \`out\' value parameter instead of function//
}

527
528
529
530
531
532
533
534
535
536
537
function f_class_param(in C39 x) runs on Comp { }

function f_start_comp() { //^In function definition//
  var Comp ct := Comp.create alive;
  var C39 x := C39.create;
  ct.start(x.f_def(1)); //^In start test component statement// //A method of a class cannot be started on a parallel test component//
  ct.done;
  ct.start(f_class_param(x)); //^In start test component statement// //Function `@oop_SE.f_class_param' cannot be started on a parallel test component because parameter `x' is of a class type//
  ct.done;
}

538

539
540
541
542
543
544
545
546
547
type C47 C47_alias; //^In type definition// //Subtyping is not allowed for class type//
type C47_alias C47_alias_alias; //^In type definition// //Subtyping is not allowed for class type//

function f_aliases() {
  var C47_alias x1 := C47_alias.create(1);
  var C47_alias_alias x2 := C47_alias_alias.create(2);
}


548
549
550
control { //^In control part//
  var C11 x := C11.create; //^In variable definition// //A definition without `runs on' clause cannot create a value of class type `@oop_SE.C11', which runs on component type `@oop_SE.CT_RunsOn'// //Cannot create value of class type `@oop_SE.C11', which has an `mtc' clause, in the control part.// //Cannot create value of class type `@oop_SE.C11', which has a `system' clause, in the control part.//
}
551
552
553

}
with {
554
  extension "anytype C0, object" //^In anytype field// //Class type `@oop_SE.C0' cannot be embedded into another type// //Class type `object' cannot be added to the anytype//
555
}