File tree 7 files changed +390
-4
lines changed 7 files changed +390
-4
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
3
+ * for details. All rights reserved. Use of this source code is governed by a
4
+ * BSD-style license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * @assertion NativeType's subtypes represent a native type in C.
8
+ *
9
+ * NativeType's subtypes are not constructible in the Dart code and serve purely a
10
+ * s markers in type signatures.
11
+ *
12
+ * @description Checks that this class cannot be extended
13
+
14
+ */
15
+ import "dart:ffi" ;
16
+
17
+ class C1 extends NativeType {
18
+ // ^^^^^^^^^^
19
+ // [analyzer] unspecified
20
+ // [cfe] unspecified
21
+ }
22
+
23
+ class C2 implements NativeType {
24
+ // ^^^^^^^^^^
25
+ // [analyzer] unspecified
26
+ // [cfe] unspecified
27
+ }
28
+
29
+ class C3 extends Object with NativeType {
30
+ // ^^^^^^^^^^
31
+ // [analyzer] unspecified
32
+ // [cfe] unspecified
33
+ }
34
+
35
+ void main () {
36
+ C1 ? c1;
37
+ C2 ? c2;
38
+ C3 ? c3;
39
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
3
+ * for details. All rights reserved. Use of this source code is governed by a
4
+ * BSD-style license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * @assertion All field declarations in a Struct subclass declaration must
8
+ * either have type int or double and be annotated with a NativeType
9
+ * representing the native type, or must be of type Pointer or subtype of Struct.
10
+ *
11
+ * @description Checks that it is a compile error if any of the field in Struct
12
+ * subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'
13
+
14
+ */
15
+ import "dart:ffi" ;
16
+
17
+ class S1 extends Struct {
18
+ @Double ()
19
+ external double x;
20
+ @Int 32()
21
+ external int y;
22
+ @Int 8()
23
+ external num z;
24
+ // ^^^
25
+ // [analyzer] unspecified
26
+ // [cfe] unspecified
27
+ }
28
+
29
+ class S2 extends Struct {
30
+ @Double ()
31
+ external double x;
32
+ @Int 32()
33
+ external int y;
34
+
35
+ String ? s;
36
+ //^^^^^^^
37
+ // [analyzer] unspecified
38
+ // [cfe] unspecified
39
+ }
40
+
41
+ class S3 extends Struct {
42
+ @Double ()
43
+ external double x;
44
+ @Int 32()
45
+ external int y;
46
+
47
+ external String ? s;
48
+ // ^^^^^^^
49
+ // [analyzer] unspecified
50
+ // [cfe] unspecified
51
+ }
52
+
53
+ class S4 extends Struct {
54
+ @Double ()
55
+ external double x;
56
+ @Int 32()
57
+ external int y;
58
+ @Int 16()
59
+ external String ? s;
60
+ // ^^^^^^^
61
+ // [analyzer] unspecified
62
+ // [cfe] unspecified
63
+ }
64
+
65
+ class S5 extends Struct {
66
+ @Double ()
67
+ external double x;
68
+ @Int 32()
69
+ external int y;
70
+
71
+ external bool ? b;
72
+ // ^^^^^
73
+ // [analyzer] unspecified
74
+ // [cfe] unspecified
75
+ }
76
+
77
+ class S6 extends Struct {
78
+ @Double ()
79
+ external double x;
80
+ @Int 32()
81
+ external int y;
82
+
83
+ bool ? b;
84
+ //^^^^^
85
+ // [analyzer] unspecified
86
+ // [cfe] unspecified
87
+ }
88
+
89
+ void main () {
90
+ S1 ? s1;
91
+ S2 ? s2;
92
+ S3 ? s3;
93
+ S4 ? s4;
94
+ S5 ? s5;
95
+ S6 ? s6;
96
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
3
+ * for details. All rights reserved. Use of this source code is governed by a
4
+ * BSD-style license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * @assertion All field declarations in a Struct subclass declaration must
8
+ * either have type int or double and be annotated with a NativeType
9
+ * representing the native type, or must be of type Pointer or subtype of Struct.
10
+ *
11
+ * @description Checks that it is a compile error if any of the field in Struct
12
+ * subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'
13
+
14
+ */
15
+ import "dart:ffi" ;
16
+
17
+ class S1 extends Struct {
18
+ @Double ()
19
+ external List <double > x;
20
+ // ^^^^^^^^^^^^
21
+ // [analyzer] unspecified
22
+ // [cfe] unspecified
23
+ @Int 32()
24
+ external List <int > y;
25
+ // ^^^^^^^^^
26
+ // [analyzer] unspecified
27
+ // [cfe] unspecified
28
+ }
29
+
30
+ class S2 extends Struct {
31
+ NativeType p;
32
+ //^^^^^^^^^^
33
+ // [analyzer] unspecified
34
+ // [cfe] unspecified
35
+ }
36
+
37
+ class S3 extends Struct {
38
+ external NativeType p;
39
+ // ^^^^^^^^^^
40
+ // [analyzer] unspecified
41
+ // [cfe] unspecified
42
+ }
43
+
44
+ class S4 extends Struct {
45
+ @Int 8()
46
+ external NativeType p;
47
+ // ^^^^^^^^^^
48
+ // [analyzer] unspecified
49
+ // [cfe] unspecified
50
+ }
51
+
52
+ void main () {
53
+ S1 ? s1;
54
+ S2 ? s2;
55
+ S3 ? s3;
56
+ S4 ? s4;
57
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
3
+ * for details. All rights reserved. Use of this source code is governed by a
4
+ * BSD-style license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * @assertion All field declarations in a Struct subclass declaration must
8
+ * either have type int or double and be annotated with a NativeType
9
+ * representing the native type, or must be of type Pointer or subtype of Struct.
10
+ *
11
+ * @description Checks that it is a compile error if any of the field in Struct
12
+ * subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'
13
+
14
+ */
15
+ import "dart:ffi" ;
16
+
17
+ class S1 extends Struct {
18
+ @Int 8()
19
+ external Object ? o;
20
+ // ^^^^^^
21
+ // [analyzer] unspecified
22
+ // [cfe] unspecified
23
+ }
24
+
25
+ class S2 extends Struct {
26
+ @Int 8()
27
+ external void v;
28
+ // ^^^^
29
+ // [analyzer] unspecified
30
+ // [cfe] unspecified
31
+ }
32
+
33
+ class S3 extends Struct {
34
+ @Int 8()
35
+ external Null n;
36
+ // ^^^^
37
+ // [analyzer] unspecified
38
+ // [cfe] unspecified
39
+ }
40
+
41
+ class S4 extends Struct {
42
+ @Double ()
43
+ external dynamic x;
44
+ // ^^^^^^^
45
+ // [analyzer] unspecified
46
+ // [cfe] unspecified
47
+ }
48
+
49
+ void main () {
50
+ S1 ? s1;
51
+ S2 ? s2;
52
+ S3 ? s3;
53
+ S4 ? s4;
54
+ S5 ? s5;
55
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
3
+ * for details. All rights reserved. Use of this source code is governed by a
4
+ * BSD-style license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * @assertion All field declarations in a Struct subclass declaration must
8
+ * either have type int or double and be annotated with a NativeType
9
+ * representing the native type, or must be of type Pointer or subtype of Struct.
10
+ *
11
+ * @description Checks that it is a compile error if any of the field in Struct
12
+ * subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'
13
+
14
+ */
15
+ import "dart:ffi" ;
16
+ import "dart:async" ;
17
+
18
+ class S1 extends Struct {
19
+ @Double ()
20
+ external FutureOr <double > x;
21
+ // ^^^^^^^^^^^^^^^^
22
+ // [analyzer] unspecified
23
+ // [cfe] unspecified
24
+ @Int 32()
25
+ external FutureOr <int > y;
26
+ // ^^^^^^^^^^^^^
27
+ // [analyzer] unspecified
28
+ // [cfe] unspecified
29
+ }
30
+
31
+ class S2 extends Struct {
32
+ Pointer <FutureOr <Int8 >> x;
33
+ // ^^^^^^^
34
+ // [analyzer] unspecified
35
+ // [cfe] unspecified
36
+ }
37
+
38
+ void main () {
39
+ S1 ? s1;
40
+ S2 ? s2;
41
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
3
+ * for details. All rights reserved. Use of this source code is governed by a
4
+ * BSD-style license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * @assertion All field declarations in a Struct subclass declaration must
8
+ * either have type int or double and be annotated with a NativeType
9
+ * representing the native type, or must be of type Pointer or subtype of Struct.
10
+ *
11
+ * @description Checks that it is a compile error if any of the field in Struct
12
+ * subclass is not 'int', 'double' or 'Pointer' or subtype of 'Struct'
13
+
14
+ */
15
+ import "dart:ffi" ;
16
+
17
+ class S1 extends Struct {
18
+ @Double ()
19
+ external Double x;
20
+ // ^^^^^^
21
+ // [analyzer] unspecified
22
+ // [cfe] unspecified
23
+ @Int 32()
24
+ external Int32 y;
25
+ // ^^^^^
26
+ // [analyzer] unspecified
27
+ // [cfe] unspecified
28
+ }
29
+
30
+ class S2 extends Struct {
31
+ Struct ? s;
32
+ //^^^^^^
33
+ // [analyzer] unspecified
34
+ // [cfe] unspecified
35
+ }
36
+
37
+ void main () {
38
+ S1 ? s1;
39
+ S2 ? s2;
40
+ }
You can’t perform that action at this time.
0 commit comments