Skip to content

Commit f749040

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[model] Keep Let expressions intact in the verifier
Prior to this CL the CFE verifier would update the type of the variable in Let expressions from `dynamic` to the computed static type of the initializer. This CL removes the type update, making the .expect files reflect the CFE output more accurately. Additionally, a verification check is added to make sure the static type of the initializer is assignable to the type of the Let variable. Change-Id: I0b7b8f175bcb319678c323eb6440d93f1f384a85 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425500 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent 8e45add commit f749040

File tree

229 files changed

+870
-875
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+870
-875
lines changed

pkg/front_end/testcases/constructor_tearoffs/new_as_selector.dart.strong.transformed.expect

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ static method test() → dynamic {
235235
self::new;
236236
self::E|call<dynamic>(self::new);
237237
self::E|call<core::int>(self::new);
238-
let final core::Object? #t7 = CheckLibraryIsLoaded(prefix2) in self::c.{self::C::new}{core::int};
239-
let final core::Object? #t8 = CheckLibraryIsLoaded(prefix2) in self::E|call<dynamic>(self::c.{self::C::new}{core::int});
240-
let final core::Object? #t9 = CheckLibraryIsLoaded(prefix2) in self::E|call<core::int>(self::c.{self::C::new}{core::int});
238+
let final dynamic #t7 = CheckLibraryIsLoaded(prefix2) in self::c.{self::C::new}{core::int};
239+
let final dynamic #t8 = CheckLibraryIsLoaded(prefix2) in self::E|call<dynamic>(self::c.{self::C::new}{core::int});
240+
let final dynamic #t9 = CheckLibraryIsLoaded(prefix2) in self::E|call<core::int>(self::c.{self::C::new}{core::int});
241241
self::E|get#new(0);
242242
self::E|call<dynamic>(self::E|get#new(0));
243243
self::E|call<core::int>(self::E|get#new(0));

pkg/front_end/testcases/dart2js/issue53804.dart.strong.transformed.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ class A extends core::Object {
2424
{
2525
final hoisted core::int? f1;
2626
if(true) {
27-
f1 = #0#1#isSet ?{core::int?} #0#1{core::int?} : let final core::bool #t2 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?};
27+
f1 = #0#1#isSet ?{core::int?} #0#1{core::int?} : let final dynamic #t2 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?};
2828
#t1 = "${f1}";
2929
break #L1;
3030
}
3131
}
3232
{
3333
final hoisted core::double? f2;
34-
if(#0#4#isSet ?{core::bool} #0#4{core::bool} : let final core::bool #t3 = #0#4#isSet = true in #0#4 = (#0#1#isSet ?{core::int?} #0#1{core::int?} : let final core::bool #t4 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?}) == null) {
35-
f2 = #0#2#isSet ?{core::double?} #0#2{core::double?} : let final core::bool #t5 = #0#2#isSet = true in #0#2 = #0#0.$2{core::double?};
34+
if(#0#4#isSet ?{core::bool} #0#4{core::bool} : let final dynamic #t3 = #0#4#isSet = true in #0#4 = (#0#1#isSet ?{core::int?} #0#1{core::int?} : let final dynamic #t4 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?}) == null) {
35+
f2 = #0#2#isSet ?{core::double?} #0#2{core::double?} : let final dynamic #t5 = #0#2#isSet = true in #0#2 = #0#0.$2{core::double?};
3636
#t1 = "${f2}";
3737
break #L1;
3838
}
3939
}
4040
{
41-
if((#0#4#isSet ?{core::bool} #0#4{core::bool} : let final core::bool #t6 = #0#4#isSet = true in #0#4 = (#0#1#isSet ?{core::int?} #0#1{core::int?} : let final core::bool #t7 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?}) == null) && (#0#2#isSet ?{core::double?} #0#2{core::double?} : let final core::bool #t8 = #0#2#isSet = true in #0#2 = #0#0.$2{core::double?}) == null) {
41+
if((#0#4#isSet ?{core::bool} #0#4{core::bool} : let final dynamic #t6 = #0#4#isSet = true in #0#4 = (#0#1#isSet ?{core::int?} #0#1{core::int?} : let final dynamic #t7 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?}) == null) && (#0#2#isSet ?{core::double?} #0#2{core::double?} : let final dynamic #t8 = #0#2#isSet = true in #0#2 = #0#0.$2{core::double?}) == null) {
4242
#t1 = "?";
4343
break #L1;
4444
}

pkg/front_end/testcases/expression/class_static3.expression.yaml.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Errors: {
44
^^^^^^^^^
55
}
66
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
7-
return #lib1::globalVar.{dart.core::num::+}(invalid-expression "org-dartlang-debug:synthetic_debug_expression:1:13: Error: Undefined name 'staticVar'.\nglobalVar + staticVar + 5\n ^^^^^^^^^"){(dart.core::num) → dart.core::double}.{dart.core::double::+}(5){(dart.core::num) → dart.core::double};
7+
return #lib1::globalVar.{dart.core::num::+}(invalid-expression "org-dartlang-debug:synthetic_debug_expression:1:13: Error: Undefined name 'staticVar'.\nglobalVar + staticVar + 5\n ^^^^^^^^^"){(dart.core::num) → invalid-type}{<invalid>}.+(5);
88
Errors: {
99
}
1010
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic

pkg/front_end/testcases/extension_types/issue52667.dart.strong.transformed.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static method main() → void {
3636
final synthesized self::FooBar /* erasure=self::Foo */ #0#0 = a;
3737
{
3838
final hoisted self::Foo a;
39-
if(let final self::Foo #t1 = a = #0#0 as{Unchecked} self::Foo in true) {
39+
if(let final dynamic #t1 = a = #0#0 as{Unchecked} self::Foo in true) {
4040
{
4141
core::print("FooBar ${a}");
4242
}

pkg/front_end/testcases/extension_types/pattern.dart.strong.transformed.expect

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ static method method(self::MyList<core::int> /* erasure=core::List<core::int> */
2828
hoisted has-declared-initializer core::int a;
2929
{
3030
final synthesized self::MyList<core::int> /* erasure=core::List<core::int> */ #0#0 = list;
31-
if(!(#0#0.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final core::int #t1 = a = #0#0.{core::List::[]}(0){(core::int) → core::int} in true)))
31+
if(!(#0#0.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t1 = a = #0#0.{core::List::[]}(0){(core::int) → core::int} in true)))
3232
throw{for-error-handling} new core::StateError::•("Pattern matching error");
3333
}
3434
hoisted has-declared-initializer core::bool b;
3535
{
3636
final synthesized self::MyMap<core::String, core::bool> /* erasure=core::Map<core::String, core::bool> */ #1#0 = map;
3737
synthesized core::bool? #1#3;
3838
synthesized core::bool #1#3#isSet = false;
39-
if(!((!((#1#3#isSet ?{core::bool?} #1#3{core::bool?} : let final core::bool #t2 = #1#3#isSet = true in #1#3 = #1#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?}) == null) || null is core::bool && #1#0.{core::Map::containsKey}(#C2){(core::Object?) → core::bool}) && (let final core::bool #t3 = b = let core::bool? #t4 = #1#3#isSet ?{core::bool?} #1#3{core::bool?} : let final core::bool #t5 = #1#3#isSet = true in #1#3 = #1#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?} in #t4 == null ?{core::bool} #t4 as{Unchecked} core::bool : #t4{core::bool} in true)))
39+
if(!((!((#1#3#isSet ?{core::bool?} #1#3{core::bool?} : let final dynamic #t2 = #1#3#isSet = true in #1#3 = #1#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?}) == null) || null is core::bool && #1#0.{core::Map::containsKey}(#C2){(core::Object?) → core::bool}) && (let final dynamic #t3 = b = let core::bool? #t4 = #1#3#isSet ?{core::bool?} #1#3{core::bool?} : let final dynamic #t5 = #1#3#isSet = true in #1#3 = #1#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?} in #t4 == null ?{core::bool} #t4 as{Unchecked} core::bool : #t4{core::bool} in true)))
4040
throw{for-error-handling} new core::StateError::•("Pattern matching error");
4141
}
4242
{
@@ -55,8 +55,8 @@ static method method(self::MyList<core::int> /* erasure=core::List<core::int> */
5555
synthesized core::bool #3#3#isSet = false;
5656
{
5757
hoisted core::bool d;
58-
if(!((#3#3#isSet ?{core::bool?} #3#3{core::bool?} : let final core::bool #t6 = #3#3#isSet = true in #3#3 = #3#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?}) == null) || null is core::bool && #3#0.{core::Map::containsKey}(#C2){(core::Object?) → core::bool}) {
59-
d = let core::bool? #t7 = #3#3#isSet ?{core::bool?} #3#3{core::bool?} : let final core::bool #t8 = #3#3#isSet = true in #3#3 = #3#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?} in #t7 == null ?{core::bool} #t7 as{Unchecked} core::bool : #t7{core::bool};
58+
if(!((#3#3#isSet ?{core::bool?} #3#3{core::bool?} : let final dynamic #t6 = #3#3#isSet = true in #3#3 = #3#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?}) == null) || null is core::bool && #3#0.{core::Map::containsKey}(#C2){(core::Object?) → core::bool}) {
59+
d = let core::bool? #t7 = #3#3#isSet ?{core::bool?} #3#3{core::bool?} : let final dynamic #t8 = #3#3#isSet = true in #3#3 = #3#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?} in #t7 == null ?{core::bool} #t7 as{Unchecked} core::bool : #t7{core::bool};
6060
{}
6161
}
6262
}
@@ -70,7 +70,7 @@ static method method(self::MyList<core::int> /* erasure=core::List<core::int> */
7070
{
7171
lowered hoisted core::int e#case#0;
7272
lowered hoisted core::int e#case#1;
73-
if((#4#1#isSet ?{core::int} #4#1{core::int} : let final core::bool #t10 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C1 && (let final core::int #t11 = e#case#0 = #4#0.{core::List::[]}(0){(core::int) → core::int} in true) && e#case#0.{core::num::>}(5){(core::num) → core::bool} && (let final core::int #t12 = #t9 = e#case#0 in true) || (#4#1#isSet ?{core::int} #4#1{core::int} : let final core::bool #t13 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C3 && (let final core::int #t14 = e#case#1 = #4#0.{core::List::[]}(1){(core::int) → core::int} in true) && e#case#1.{core::num::<}(5){(core::num) → core::bool} && (let final core::int #t15 = #t9 = e#case#1 in true)) {
73+
if((#4#1#isSet ?{core::int} #4#1{core::int} : let final dynamic #t10 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t11 = e#case#0 = #4#0.{core::List::[]}(0){(core::int) → core::int} in true) && e#case#0.{core::num::>}(5){(core::num) → core::bool} && (let final dynamic #t12 = #t9 = e#case#0 in true) || (#4#1#isSet ?{core::int} #4#1{core::int} : let final dynamic #t13 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C3 && (let final dynamic #t14 = e#case#1 = #4#0.{core::List::[]}(1){(core::int) → core::int} in true) && e#case#1.{core::num::<}(5){(core::num) → core::bool} && (let final dynamic #t15 = #t9 = e#case#1 in true)) {
7474
core::int e = #t9{core::int};
7575
{
7676
core::print(e);
@@ -85,7 +85,7 @@ static method method(self::MyList<core::int> /* erasure=core::List<core::int> */
8585
synthesized core::bool #5#3#isSet = false;
8686
{
8787
hoisted core::bool e;
88-
if((!((#5#3#isSet ?{core::bool?} #5#3{core::bool?} : let final core::bool #t16 = #5#3#isSet = true in #5#3 = #5#0.{core::Map::[]}(#C1){(core::Object?) → core::bool?}) == null) || null is core::bool && #5#0.{core::Map::containsKey}(#C1){(core::Object?) → core::bool}) && (let final core::bool #t17 = e = let core::bool? #t18 = #5#3#isSet ?{core::bool?} #5#3{core::bool?} : let final core::bool #t19 = #5#3#isSet = true in #5#3 = #5#0.{core::Map::[]}(#C1){(core::Object?) → core::bool?} in #t18 == null ?{core::bool} #t18 as{Unchecked} core::bool : #t18{core::bool} in true)) {
88+
if((!((#5#3#isSet ?{core::bool?} #5#3{core::bool?} : let final dynamic #t16 = #5#3#isSet = true in #5#3 = #5#0.{core::Map::[]}(#C1){(core::Object?) → core::bool?}) == null) || null is core::bool && #5#0.{core::Map::containsKey}(#C1){(core::Object?) → core::bool}) && (let final dynamic #t17 = e = let core::bool? #t18 = #5#3#isSet ?{core::bool?} #5#3{core::bool?} : let final dynamic #t19 = #5#3#isSet = true in #5#3 = #5#0.{core::Map::[]}(#C1){(core::Object?) → core::bool?} in #t18 == null ?{core::bool} #t18 as{Unchecked} core::bool : #t18{core::bool} in true)) {
8989
{
9090
core::print(e);
9191
}

pkg/front_end/testcases/extensions/deferred_explicit_access.dart.strong.transformed.expect

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ library;
88
// ^
99
//
1010
import self as self;
11-
import "dart:core" as core;
1211
import "deferred_explicit_access_lib.dart" as def;
12+
import "dart:core" as core;
1313

1414
import "org-dartlang-testcase:///deferred_explicit_access_lib.dart" deferred as prefix;
1515

1616
static method main() → dynamic async /* emittedValueType= dynamic */ {
1717
await LoadLibrary(prefix);
18-
self::expect(0, let final core::Object? #t1 = CheckLibraryIsLoaded(prefix) in def::Extension|staticField);
19-
self::expect(0, let final core::Object? #t2 = CheckLibraryIsLoaded(prefix) in def::Extension|get#property(0));
20-
self::expect(42, let final core::Object? #t3 = CheckLibraryIsLoaded(prefix) in let final core::int #t4 = 0 in let final core::int #t5 = 42 in let final void #t6 = def::Extension|set#property(#t4, #t5) in #t5);
21-
self::expect(84, let final core::Object? #t7 = CheckLibraryIsLoaded(prefix) in def::Extension|get#property(42));
22-
self::expect(85, let final core::Object? #t8 = CheckLibraryIsLoaded(prefix) in def::Extension|method(43));
23-
self::expect(42, let final core::Object? #t9 = CheckLibraryIsLoaded(prefix) in def::Extension|staticProperty);
24-
self::expect(87, let final core::Object? #t10 = CheckLibraryIsLoaded(prefix) in def::Extension|staticProperty = 87);
25-
self::expect(87, let final core::Object? #t11 = CheckLibraryIsLoaded(prefix) in def::Extension|staticMethod());
18+
self::expect(0, let final dynamic #t1 = CheckLibraryIsLoaded(prefix) in def::Extension|staticField);
19+
self::expect(0, let final dynamic #t2 = CheckLibraryIsLoaded(prefix) in def::Extension|get#property(0));
20+
self::expect(42, let final dynamic #t3 = CheckLibraryIsLoaded(prefix) in let final core::int #t4 = 0 in let final core::int #t5 = 42 in let final void #t6 = def::Extension|set#property(#t4, #t5) in #t5);
21+
self::expect(84, let final dynamic #t7 = CheckLibraryIsLoaded(prefix) in def::Extension|get#property(42));
22+
self::expect(85, let final dynamic #t8 = CheckLibraryIsLoaded(prefix) in def::Extension|method(43));
23+
self::expect(42, let final dynamic #t9 = CheckLibraryIsLoaded(prefix) in def::Extension|staticProperty);
24+
self::expect(87, let final dynamic #t10 = CheckLibraryIsLoaded(prefix) in def::Extension|staticProperty = 87);
25+
self::expect(87, let final dynamic #t11 = CheckLibraryIsLoaded(prefix) in def::Extension|staticMethod());
2626
}
2727
static method expect(dynamic expected, dynamic actual) → dynamic {
2828
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))

pkg/front_end/testcases/extensions/deferred_import_hidden.dart.strong.transformed.expect

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
library;
22
import self as self;
3-
import "dart:core" as core;
43
import "deferred_explicit_access_lib.dart" as def;
4+
import "dart:core" as core;
55

66
import "org-dartlang-testcase:///deferred_explicit_access_lib.dart" deferred as prefix hide Extension;
77

88
static method main() → dynamic async /* emittedValueType= dynamic */ {
99
await LoadLibrary(prefix);
10-
self::expect(0, let final core::Object? #t1 = CheckLibraryIsLoaded(prefix) in def::topLevelField);
11-
self::expect(42, let final core::Object? #t2 = CheckLibraryIsLoaded(prefix) in def::topLevelField = 42);
12-
self::expect(42, let final core::Object? #t3 = CheckLibraryIsLoaded(prefix) in def::topLevelField);
13-
self::expect(0, let final core::Object? #t4 = CheckLibraryIsLoaded(prefix) in def::topLevelProperty);
14-
self::expect(87, let final core::Object? #t5 = CheckLibraryIsLoaded(prefix) in def::topLevelProperty = 87);
15-
self::expect(87, let final core::Object? #t6 = CheckLibraryIsLoaded(prefix) in def::topLevelProperty);
16-
self::expect(87, let final core::Object? #t7 = CheckLibraryIsLoaded(prefix) in def::topLevelMethod());
10+
self::expect(0, let final dynamic #t1 = CheckLibraryIsLoaded(prefix) in def::topLevelField);
11+
self::expect(42, let final dynamic #t2 = CheckLibraryIsLoaded(prefix) in def::topLevelField = 42);
12+
self::expect(42, let final dynamic #t3 = CheckLibraryIsLoaded(prefix) in def::topLevelField);
13+
self::expect(0, let final dynamic #t4 = CheckLibraryIsLoaded(prefix) in def::topLevelProperty);
14+
self::expect(87, let final dynamic #t5 = CheckLibraryIsLoaded(prefix) in def::topLevelProperty = 87);
15+
self::expect(87, let final dynamic #t6 = CheckLibraryIsLoaded(prefix) in def::topLevelProperty);
16+
self::expect(87, let final dynamic #t7 = CheckLibraryIsLoaded(prefix) in def::topLevelMethod());
1717
}
1818
static method expect(dynamic expected, dynamic actual) → dynamic {
1919
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))

pkg/front_end/testcases/extensions/missing_toplevel.dart.strong.transformed.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extension Extension on self::Class {
2020
set setter = self::Extension|set#setter;
2121
}
2222
static field self::Class c = new self::Class::•();
23-
static field dynamic missingGetter = let final self::Class #t1 = self::c in let final core::int #t2 = invalid-expression "pkg/front_end/testcases/extensions/missing_toplevel.dart:13:23: Error: The getter 'setter' isn't defined for the class 'Class'.
23+
static field dynamic missingGetter = let final self::Class #t1 = self::c in let final dynamic #t2 = invalid-expression "pkg/front_end/testcases/extensions/missing_toplevel.dart:13:23: Error: The getter 'setter' isn't defined for the class 'Class'.
2424
- 'Class' is from 'pkg/front_end/testcases/extensions/missing_toplevel.dart'.
2525
Try correcting the name to the name of an existing getter, or defining a getter or field named 'setter'.
2626
var missingGetter = c.setter += 42;

pkg/front_end/testcases/general/check_deferred_allocation.dart.strong.transformed.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "org-dartlang-testcase:///deferred_lib.dart" deferred as lib;
77

88
static method main() → dynamic {}
99
static method test() → dynamic {
10-
core::print(let final core::Object? #t1 = CheckLibraryIsLoaded(lib) in new def::C::•());
10+
core::print(let final dynamic #t1 = CheckLibraryIsLoaded(lib) in new def::C::•());
1111
}
1212

1313
library;

pkg/front_end/testcases/general/check_deferred_before_args.dart.strong.transformed.expect

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
library;
22
import self as self;
3-
import "dart:core" as core;
43
import "deferred_lib.dart" as def;
4+
import "dart:core" as core;
55

66
import "org-dartlang-testcase:///deferred_lib.dart" deferred as lib;
77

88
static method main() → dynamic {}
99
static method test() → dynamic {
10-
let final core::Object? #t1 = CheckLibraryIsLoaded(lib) in def::x = self::m2() as{TypeError,ForDynamic} core::int;
11-
let final core::Object? #t2 = CheckLibraryIsLoaded(lib) in def::m(self::m2());
10+
let final dynamic #t1 = CheckLibraryIsLoaded(lib) in def::x = self::m2() as{TypeError,ForDynamic} core::int;
11+
let final dynamic #t2 = CheckLibraryIsLoaded(lib) in def::m(self::m2());
1212
}
1313
static method m2() → dynamic
1414
return 1;

0 commit comments

Comments
 (0)