Skip to content

Commit 8d9cbaf

Browse files
committed
[kernel] Allow invalid types in naive_type_checker
Change-Id: I9a7614056fa3a14a382e41ad1e927f023fe00250 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134726 Reviewed-by: Jens Johansen <[email protected]>
1 parent a73b0ce commit 8d9cbaf

16 files changed

+512
-41
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/general/ignore_function.dart:14:15: Error: Can't infer a type for 'other' as some of the inherited members have different types.
6+
// Try adding an explicit type.
7+
// operator ==(other) => false;
8+
// ^^^^^
9+
//
10+
import self as self;
11+
import "dart:core" as core;
12+
13+
import "dart:core" as core;
14+
15+
class A extends core::Object implements core::Function {
16+
synthetic constructor •() → self::A*
17+
: super core::Object::•()
18+
;
19+
operator ==(dynamic other) → core::bool*
20+
return false;
21+
}
22+
class B extends core::Object implements self::Function {
23+
synthetic constructor •() → self::B*
24+
: super core::Object::•()
25+
;
26+
operator ==(invalid-type other) → core::bool*
27+
return false;
28+
}
29+
class Function extends core::Object {
30+
synthetic constructor •() → self::Function*
31+
: super core::Object::•()
32+
;
33+
operator ==(core::Object* other) → core::bool*
34+
return false;
35+
}
36+
static method main() → dynamic {}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/general_nnbd_opt_out/ignore_function.dart:16:15: Error: Can't infer a type for 'other' as some of the inherited members have different types.
6+
// Try adding an explicit type.
7+
// operator ==(other) => false;
8+
// ^^^^^
9+
//
10+
import self as self;
11+
import "dart:core" as core;
12+
13+
import "dart:core" as core;
14+
15+
class A extends core::Object implements core::Function {
16+
synthetic constructor •() → self::A*
17+
: super core::Object::•()
18+
;
19+
operator ==(dynamic other) → core::bool*
20+
return false;
21+
}
22+
class B extends core::Object implements self::Function {
23+
synthetic constructor •() → self::B*
24+
: super core::Object::•()
25+
;
26+
operator ==(invalid-type other) → core::bool*
27+
return false;
28+
}
29+
class Function extends core::Object {
30+
synthetic constructor •() → self::Function*
31+
: super core::Object::•()
32+
;
33+
operator ==(core::Object* other) → core::bool*
34+
return false;
35+
}
36+
static method main() → dynamic {}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/general_nnbd_opt_out/ignore_function.dart:16:15: Error: Can't infer a type for 'other' as some of the inherited members have different types.
6+
// Try adding an explicit type.
7+
// operator ==(other) => false;
8+
// ^^^^^
9+
//
10+
import self as self;
11+
import "dart:core" as core;
12+
13+
import "dart:core" as core;
14+
15+
class A extends core::Object implements core::Function {
16+
synthetic constructor •() → self::A*
17+
: super core::Object::•()
18+
;
19+
operator ==(dynamic other) → core::bool*
20+
return false;
21+
}
22+
class B extends core::Object implements self::Function {
23+
synthetic constructor •() → self::B*
24+
: super core::Object::•()
25+
;
26+
operator ==(invalid-type other) → core::bool*
27+
return false;
28+
}
29+
class Function extends core::Object {
30+
synthetic constructor •() → self::Function*
31+
: super core::Object::•()
32+
;
33+
operator ==(core::Object* other) → core::bool*
34+
return false;
35+
}
36+
static method main() → dynamic {}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/inference/conflicting_fields.dart:20:14: Error: Can't infer a type for 'value' as some of the inherited members have different types.
6+
// Try adding an explicit type.
7+
// set field1(value) {}
8+
// ^^^^^
9+
//
10+
// pkg/front_end/testcases/inference/conflicting_fields.dart:21:14: Error: Can't infer a type for 'value' as some of the inherited members have different types.
11+
// Try adding an explicit type.
12+
// set field2(value) {}
13+
// ^^^^^
14+
//
15+
import self as self;
16+
import "dart:core" as core;
17+
18+
class A extends core::Object {
19+
field dynamic field1 = null;
20+
field core::int* field2 = null;
21+
synthetic constructor •() → self::A*
22+
: super core::Object::•()
23+
;
24+
}
25+
class I extends core::Object {
26+
field core::int* field1 = null;
27+
field dynamic field2 = null;
28+
synthetic constructor •() → self::I*
29+
: super core::Object::•()
30+
;
31+
}
32+
class B extends self::A implements self::I {
33+
synthetic constructor •() → self::B*
34+
: super self::A::•()
35+
;
36+
get field1() → core::int*
37+
return null;
38+
get field2() → core::int*
39+
return null;
40+
set field1(invalid-type value) → void {}
41+
set field2(invalid-type value) → void {}
42+
}
43+
static method main() → dynamic {}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
library test;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/inference/conflicts_can_happen.dart:25:7: Error: Can't infer a return type for 'a' as some of the inherited members have different types.
6+
// Try adding an explicit type.
7+
// get a => null;
8+
// ^
9+
//
10+
// pkg/front_end/testcases/inference/conflicts_can_happen.dart:30:7: Error: Can't infer a return type for 'a' as some of the inherited members have different types.
11+
// Try adding an explicit type.
12+
// get a => null;
13+
// ^
14+
//
15+
import self as self;
16+
import "dart:core" as core;
17+
18+
class I1 extends core::Object {
19+
field core::int* x = null;
20+
synthetic constructor •() → self::I1*
21+
: super core::Object::•()
22+
;
23+
}
24+
class I2 extends self::I1 {
25+
field core::int* y = null;
26+
synthetic constructor •() → self::I2*
27+
: super self::I1::•()
28+
;
29+
}
30+
class A extends core::Object {
31+
final field self::I1* a = null;
32+
synthetic constructor •() → self::A*
33+
: super core::Object::•()
34+
;
35+
}
36+
class B extends core::Object {
37+
final field self::I2* a = null;
38+
synthetic constructor •() → self::B*
39+
: super core::Object::•()
40+
;
41+
}
42+
class C1 extends core::Object implements self::A, self::B {
43+
synthetic constructor •() → self::C1*
44+
: super core::Object::•()
45+
;
46+
get a() → invalid-type
47+
return null;
48+
}
49+
class C2 extends core::Object implements self::B, self::A {
50+
synthetic constructor •() → self::C2*
51+
: super core::Object::•()
52+
;
53+
get a() → invalid-type
54+
return null;
55+
}
56+
static method main() → dynamic {}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
library test;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/inference/conflicts_can_happen2.dart:34:7: Error: Can't infer a return type for 'a' as some of the inherited members have different types.
6+
// Try adding an explicit type.
7+
// get a => null;
8+
// ^
9+
//
10+
import self as self;
11+
import "dart:core" as core;
12+
13+
class I1 extends core::Object {
14+
field core::int* x = null;
15+
synthetic constructor •() → self::I1*
16+
: super core::Object::•()
17+
;
18+
}
19+
class I2 extends core::Object {
20+
field core::int* y = null;
21+
synthetic constructor •() → self::I2*
22+
: super core::Object::•()
23+
;
24+
}
25+
class I3 extends core::Object implements self::I1, self::I2 {
26+
field core::int* x = null;
27+
field core::int* y = null;
28+
synthetic constructor •() → self::I3*
29+
: super core::Object::•()
30+
;
31+
}
32+
class A extends core::Object {
33+
final field self::I1* a = null;
34+
synthetic constructor •() → self::A*
35+
: super core::Object::•()
36+
;
37+
}
38+
class B extends core::Object {
39+
final field self::I2* a = null;
40+
synthetic constructor •() → self::B*
41+
: super core::Object::•()
42+
;
43+
}
44+
class C1 extends core::Object implements self::A, self::B {
45+
synthetic constructor •() → self::C1*
46+
: super core::Object::•()
47+
;
48+
get a() → self::I3*
49+
return null;
50+
}
51+
class C2 extends core::Object implements self::A, self::B {
52+
synthetic constructor •() → self::C2*
53+
: super core::Object::•()
54+
;
55+
get a() → invalid-type
56+
return null;
57+
}
58+
static method main() → dynamic {}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
library test;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/inference/inconsistent_overrides.dart:16:3: Error: Can't infer a return type for 'f' as some of the inherited members have different types.
6+
// Try adding an explicit type.
7+
// f(x, {y}) {}
8+
// ^
9+
//
10+
// pkg/front_end/testcases/inference/inconsistent_overrides.dart:16:5: Error: Can't infer a type for 'x' as some of the inherited members have different types.
11+
// Try adding an explicit type.
12+
// f(x, {y}) {}
13+
// ^
14+
//
15+
// pkg/front_end/testcases/inference/inconsistent_overrides.dart:16:9: Error: Can't infer a type for 'y' as some of the inherited members have different types.
16+
// Try adding an explicit type.
17+
// f(x, {y}) {}
18+
// ^
19+
//
20+
// pkg/front_end/testcases/inference/inconsistent_overrides.dart:18:9: Error: Can't infer a type for 'y' as some of the inherited members have different types.
21+
// Try adding an explicit type.
22+
// h(x, {y}) {}
23+
// ^
24+
//
25+
// pkg/front_end/testcases/inference/inconsistent_overrides.dart:17:5: Error: Can't infer a type for 'x' as some of the inherited members have different types.
26+
// Try adding an explicit type.
27+
// g(x, {y}) {}
28+
// ^
29+
//
30+
// pkg/front_end/testcases/inference/inconsistent_overrides.dart:17:9: Error: Can't infer a type for 'y' as some of the inherited members have different types.
31+
// Try adding an explicit type.
32+
// g(x, {y}) {}
33+
// ^
34+
//
35+
import self as self;
36+
import "dart:core" as core;
37+
38+
class A extends core::Object {
39+
synthetic constructor •() → self::A*
40+
: super core::Object::•()
41+
;
42+
method f(self::A* x, {self::A* y = #C1}) → self::A* {}
43+
method g(self::A* x, {self::A* y = #C1}) → self::A* {}
44+
method h(self::A* x, {self::A* y = #C1}) → self::A* {}
45+
}
46+
class B extends self::A implements self::I {
47+
synthetic constructor •() → self::B*
48+
: super self::A::•()
49+
;
50+
method f(invalid-type x, {invalid-type y = #C1}) → invalid-type {}
51+
method g(invalid-type x, {invalid-type y = #C1}) → self::A* {}
52+
method h(self::A* x, {invalid-type y = #C1}) → self::A* {}
53+
}
54+
class I extends core::Object {
55+
synthetic constructor •() → self::I*
56+
: super core::Object::•()
57+
;
58+
method f(self::I* x, {self::I* y = #C1}) → self::I* {}
59+
method g(self::I* x, {self::I* y = #C1}) → self::A* {}
60+
method h(self::A* x, {self::I* y = #C1}) → self::A* {}
61+
}
62+
static method main() → dynamic {}
63+
64+
constants {
65+
#C1 = null
66+
}

0 commit comments

Comments
 (0)