Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Unified Diff: tests/compiler/dart2js/field_type_simple_inferer_test.dart

Issue 2799763003: Fix for type analysis bug in constructor with early return (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/inferrer/locals_handler.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/field_type_simple_inferer_test.dart
diff --git a/tests/compiler/dart2js/field_type_simple_inferer_test.dart b/tests/compiler/dart2js/field_type_simple_inferer_test.dart
index 2d64709223787e86e1f04ed3b55dae3c4a90aa86..2eaf8085a537a9c24e5e39bc820136d0747bcde9 100644
--- a/tests/compiler/dart2js/field_type_simple_inferer_test.dart
+++ b/tests/compiler/dart2js/field_type_simple_inferer_test.dart
@@ -470,6 +470,63 @@ const String TEST_27 = r"""
}
""";
+const String TEST_28 = r"""
+ class A {
+ var f1;
+ var f2;
+ A(x) {
+ this.f1 = x;
+ if (x == 0) return;
+ this.f2 = x;
+ }
+ }
+ main() {
+ new A(0);
+ new A(1);
+ }
+""";
+
+const String TEST_29 = r"""
+ class A {
+ var f1;
+ var f2;
+ A(x) {
+ this.f1 = x;
+ if (x == 0) {
+ } else {
+ return;
+ }
+ this.f2 = x;
+ }
+ }
+ main() {
+ new A(0);
+ new A(1);
+ }
+""";
+
+const String TEST_30 = r"""
+ class A {
+ var f1;
+ var f2;
+ var f3;
+ A(x) {
+ this.f1 = x;
+ if (x == 0) {
+ this.f2 = 1;
+ } else {
+ this.f2 = x;
+ return;
+ }
+ this.f3 = x;
+ }
+ }
+ main() {
+ new A(0);
+ new A(1);
+ }
+""";
+
typedef TypeMask TestCallback(ClosedWorld closedWorld);
void doTest(
@@ -481,7 +538,7 @@ void doTest(
TypeMask type = f(closedWorld);
TypeMask inferredType =
simplify(inferrer.getTypeOfElement(field), closedWorld);
- Expect.equals(type, inferredType, test);
+ Expect.equals(type, inferredType, '$name of:\n$test');
});
});
}
@@ -609,6 +666,19 @@ void test() {
'f1': (closedWorld) => closedWorld.commonMasks.uint31Type,
'f2': (closedWorld) => closedWorld.commonMasks.uint31Type.nullable()
});
+ runTest(TEST_28, <String, TestCallback>{
+ 'f1': (closedWorld) => closedWorld.commonMasks.uint31Type,
+ 'f2': (closedWorld) => closedWorld.commonMasks.uint31Type.nullable()
+ });
+ runTest(TEST_29, <String, TestCallback>{
+ 'f1': (closedWorld) => closedWorld.commonMasks.uint31Type,
+ 'f2': (closedWorld) => closedWorld.commonMasks.uint31Type.nullable()
+ });
+ runTest(TEST_30, <String, TestCallback>{
+ 'f1': (closedWorld) => closedWorld.commonMasks.uint31Type,
+ 'f2': (closedWorld) => closedWorld.commonMasks.uint31Type,
+ 'f3': (closedWorld) => closedWorld.commonMasks.uint31Type.nullable()
+ });
}
void main() {
« no previous file with comments | « pkg/compiler/lib/src/inferrer/locals_handler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698