Skip to content

Commit 42d35c9

Browse files
johnniwintherCommit Queue
authored andcommitted
[cfe] Only set promoted type when different
This updates the creation of synthesized [VariableGet]s to only set the promoted type if there actually is a promotion, i.e. when the promoted type is different from the declared type. Change-Id: I3798f0dcc7ffec5052edaa7d941aba61215883ac Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443800 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Jens Johansen <[email protected]>
1 parent 30e292a commit 42d35c9

File tree

406 files changed

+1849
-1849
lines changed

Some content is hidden

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

406 files changed

+1849
-1849
lines changed

pkg/front_end/lib/src/type_inference/external_ast_helper.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ VariableGet createVariableGet(VariableDeclaration variable,
126126
{DartType? promotedType}) {
127127
return new VariableGet(variable)
128128
..fileOffset = variable.fileOffset
129-
..promotedType = promotedType;
129+
..promotedType = promotedType != variable.type ? promotedType : null;
130130
}
131131

132132
/// Creates a [VariableSet] of [variable] with the [value].

pkg/front_end/testcases/dart2js/issue53804.dart.strong.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 dynamic #t2 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?};
27+
f1 = #0#1#isSet ?{core::int?} #0#1 : 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 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?};
34+
if(#0#4#isSet ?{core::bool} #0#4 : let final dynamic #t3 = #0#4#isSet = true in #0#4 = (#0#1#isSet ?{core::int?} #0#1 : 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 : 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 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) {
41+
if((#0#4#isSet ?{core::bool} #0#4 : let final dynamic #t6 = #0#4#isSet = true in #0#4 = (#0#1#isSet ?{core::int?} #0#1 : let final dynamic #t7 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?}) == null) && (#0#2#isSet ?{core::double?} #0#2 : 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/dart2js/issue53804.dart.strong.modular.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 dynamic #t2 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?};
27+
f1 = #0#1#isSet ?{core::int?} #0#1 : 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 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?};
34+
if(#0#4#isSet ?{core::bool} #0#4 : let final dynamic #t3 = #0#4#isSet = true in #0#4 = (#0#1#isSet ?{core::int?} #0#1 : 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 : 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 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) {
41+
if((#0#4#isSet ?{core::bool} #0#4 : let final dynamic #t6 = #0#4#isSet = true in #0#4 = (#0#1#isSet ?{core::int?} #0#1 : let final dynamic #t7 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?}) == null) && (#0#2#isSet ?{core::double?} #0#2 : 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/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 dynamic #t2 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?};
27+
f1 = #0#1#isSet ?{core::int?} #0#1 : 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 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?};
34+
if(#0#4#isSet ?{core::bool} #0#4 : let final dynamic #t3 = #0#4#isSet = true in #0#4 = (#0#1#isSet ?{core::int?} #0#1 : 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 : 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 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) {
41+
if((#0#4#isSet ?{core::bool} #0#4 : let final dynamic #t6 = #0#4#isSet = true in #0#4 = (#0#1#isSet ?{core::int?} #0#1 : let final dynamic #t7 = #0#1#isSet = true in #0#1 = #0#0.$1{core::int?}) == null) && (#0#2#isSet ?{core::double?} #0#2 : 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/extension_types/pattern.dart.strong.expect

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static method method(self::MyList<core::int> /* erasure=core::List<core::int> */
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 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 = (#1#3#isSet ?{core::bool?} #1#3{core::bool?} : let final dynamic #t4 = #1#3#isSet = true in #1#3 = #1#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?}) as{Unchecked} core::bool in true)))
39+
if(!((!((#1#3#isSet ?{core::bool?} #1#3 : 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 = (#1#3#isSet ?{core::bool?} #1#3 : let final dynamic #t4 = #1#3#isSet = true in #1#3 = #1#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?}) as{Unchecked} 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 dynamic #t5 = #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 = (#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?}) as{Unchecked} core::bool;
58+
if(!((#3#3#isSet ?{core::bool?} #3#3 : let final dynamic #t5 = #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 = (#3#3#isSet ?{core::bool?} #3#3 : let final dynamic #t6 = #3#3#isSet = true in #3#3 = #3#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?}) as{Unchecked} 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 dynamic #t8 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t9 = 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 #t10 = #t7 = e#case#0 in true) || (#4#1#isSet ?{core::int} #4#1{core::int} : let final dynamic #t11 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C3 && (let final dynamic #t12 = 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 #t13 = #t7 = e#case#1 in true)) {
73+
if((#4#1#isSet ?{core::int} #4#1 : let final dynamic #t8 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t9 = 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 #t10 = #t7 = e#case#0 in true) || (#4#1#isSet ?{core::int} #4#1 : let final dynamic #t11 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C3 && (let final dynamic #t12 = 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 #t13 = #t7 = e#case#1 in true)) {
7474
core::int e = #t7{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 dynamic #t14 = #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 #t15 = e = (#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?}) as{Unchecked} core::bool in true)) {
88+
if((!((#5#3#isSet ?{core::bool?} #5#3 : let final dynamic #t14 = #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 #t15 = e = (#5#3#isSet ?{core::bool?} #5#3 : let final dynamic #t16 = #5#3#isSet = true in #5#3 = #5#0.{core::Map::[]}(#C1){(core::Object?) → core::bool?}) as{Unchecked} core::bool in true)) {
8989
{
9090
core::print(e);
9191
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static method method(self::MyList<core::int> /* erasure=core::List<core::int> */
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 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 = (#1#3#isSet ?{core::bool?} #1#3{core::bool?} : let final dynamic #t4 = #1#3#isSet = true in #1#3 = #1#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?}) as{Unchecked} core::bool in true)))
39+
if(!((!((#1#3#isSet ?{core::bool?} #1#3 : 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 = (#1#3#isSet ?{core::bool?} #1#3 : let final dynamic #t4 = #1#3#isSet = true in #1#3 = #1#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?}) as{Unchecked} 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 dynamic #t5 = #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 = (#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?}) as{Unchecked} core::bool;
58+
if(!((#3#3#isSet ?{core::bool?} #3#3 : let final dynamic #t5 = #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 = (#3#3#isSet ?{core::bool?} #3#3 : let final dynamic #t6 = #3#3#isSet = true in #3#3 = #3#0.{core::Map::[]}(#C2){(core::Object?) → core::bool?}) as{Unchecked} 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 dynamic #t8 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t9 = 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 #t10 = #t7 = e#case#0 in true) || (#4#1#isSet ?{core::int} #4#1{core::int} : let final dynamic #t11 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C3 && (let final dynamic #t12 = 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 #t13 = #t7 = e#case#1 in true)) {
73+
if((#4#1#isSet ?{core::int} #4#1 : let final dynamic #t8 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t9 = 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 #t10 = #t7 = e#case#0 in true) || (#4#1#isSet ?{core::int} #4#1 : let final dynamic #t11 = #4#1#isSet = true in #4#1 = #4#0.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C3 && (let final dynamic #t12 = 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 #t13 = #t7 = e#case#1 in true)) {
7474
core::int e = #t7{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 dynamic #t14 = #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 #t15 = e = (#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?}) as{Unchecked} core::bool in true)) {
88+
if((!((#5#3#isSet ?{core::bool?} #5#3 : let final dynamic #t14 = #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 #t15 = e = (#5#3#isSet ?{core::bool?} #5#3 : let final dynamic #t16 = #5#3#isSet = true in #5#3 = #5#0.{core::Map::[]}(#C1){(core::Object?) → core::bool?}) as{Unchecked} core::bool in true)) {
8989
{
9090
core::print(e);
9191
}

0 commit comments

Comments
 (0)