[cfe] Implement RecordLiteral.transformOrRemoveChildren

Closes #50004

Change-Id: Iaea68b563bd59bb3280bd6ffb86f18d50f3d2a4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260105
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther 2022-09-21 08:49:16 +00:00 committed by Commit Bot
parent 9f75d4426e
commit 281a8a5d2b
15 changed files with 110 additions and 12 deletions

View file

@ -0,0 +1,7 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
main() {
var r1 = (1, const [42]);
}

View file

@ -0,0 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
static method main() → dynamic {
(core::int, core::List<core::int>) r1 = (1, #C2);
}
constants {
#C1 = 42
#C2 = <core::int>[#C1]
}

View file

@ -0,0 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
static method main() → dynamic {
(core::int, core::List<core::int>) r1 = (1, #C2);
}
constants {
#C1 = 42
#C2 = <core::int>[#C1]
}

View file

@ -0,0 +1 @@
main() {}

View file

@ -0,0 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
static method main() → dynamic {
(core::int, core::List<core::int>) r1 = (1, #C2);
}
constants {
#C1 = 42
#C2 = <core::int*>[#C1]
}

View file

@ -0,0 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
static method main() → dynamic {
(core::int, core::List<core::int>) r1 = (1, #C2);
}
constants {
#C1 = 42
#C2 = <core::int*>[#C1]
}

View file

@ -0,0 +1,5 @@
library /*isNonNullableByDefault*/;
import self as self;
static method main() → dynamic
;

View file

@ -0,0 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
static method main() → dynamic {
(core::int, core::List<core::int>) r1 = (1, #C2);
}
constants {
#C1 = 42
#C2 = <core::int*>[#C1]
}

View file

@ -26,7 +26,7 @@ static method method() → dynamic {
(0, {b: 1});
({a: 0, b: 1});
let final core::int #t1 = 0 in (1, {a: #t1});
(core::int, core::String);
(#C1, #C2);
}
static method sorting() → dynamic {
({a: 0, b: 1, c: 2, d: 3});
@ -40,3 +40,8 @@ static method sorting() → dynamic {
let final core::int #t23 = 0 in let final core::int #t24 = 1 in let final core::int #t25 = 2 in (#t23, #t25, 3, {a: #t24, b: 4, c: 5});
let final core::int #t26 = 0 in let final core::int #t27 = 1 in let final core::int #t28 = 2 in (#t27, #t28, 3, {a: #t26, b: 4, c: 5});
}
constants {
#C1 = TypeLiteralConstant(core::int)
#C2 = TypeLiteralConstant(core::String)
}

View file

@ -26,7 +26,7 @@ static method method() → dynamic {
(0, {b: 1});
({a: 0, b: 1});
let final core::int #t1 = 0 in (1, {a: #t1});
(core::int, core::String);
(#C1, #C2);
}
static method sorting() → dynamic {
({a: 0, b: 1, c: 2, d: 3});
@ -41,11 +41,13 @@ static method sorting() → dynamic {
let final core::int #t26 = 0 in let final core::int #t27 = 1 in let final core::int #t28 = 2 in (#t27, #t28, 3, {a: #t26, b: 4, c: 5});
}
constants {
#C1 = TypeLiteralConstant(core::int)
#C2 = TypeLiteralConstant(core::String)
}
Extra constant evaluation status:
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:10:7 -> IntConstant(0)
Evaluated: TypeLiteral @ org-dartlang-testcase:///record_literal.dart:11:4 -> TypeLiteralConstant(int)
Evaluated: TypeLiteral @ org-dartlang-testcase:///record_literal.dart:11:9 -> TypeLiteralConstant(String)
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:16:7 -> IntConstant(0)
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:16:13 -> IntConstant(1)
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:16:19 -> IntConstant(2)
@ -73,4 +75,4 @@ Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:23:10 -> I
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:24:10 -> IntConstant(1)
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:24:13 -> IntConstant(2)
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:24:7 -> IntConstant(0)
Extra constant evaluation: evaluated: 75, effectively constant: 30
Extra constant evaluation: evaluated: 73, effectively constant: 28

View file

@ -26,7 +26,7 @@ static method method() → dynamic {
(0, {b: 1});
({a: 0, b: 1});
let final core::int #t1 = 0 in (1, {a: #t1});
(core::int, core::String);
(#C1, #C2);
}
static method sorting() → dynamic {
({a: 0, b: 1, c: 2, d: 3});
@ -40,3 +40,8 @@ static method sorting() → dynamic {
let final core::int #t23 = 0 in let final core::int #t24 = 1 in let final core::int #t25 = 2 in (#t23, #t25, 3, {a: #t24, b: 4, c: 5});
let final core::int #t26 = 0 in let final core::int #t27 = 1 in let final core::int #t28 = 2 in (#t27, #t28, 3, {a: #t26, b: 4, c: 5});
}
constants {
#C1 = TypeLiteralConstant(core::int*)
#C2 = TypeLiteralConstant(core::String*)
}

View file

@ -26,7 +26,7 @@ static method method() → dynamic {
(0, {b: 1});
({a: 0, b: 1});
let final core::int #t1 = 0 in (1, {a: #t1});
(core::int, core::String);
(#C1, #C2);
}
static method sorting() → dynamic {
({a: 0, b: 1, c: 2, d: 3});
@ -40,3 +40,8 @@ static method sorting() → dynamic {
let final core::int #t23 = 0 in let final core::int #t24 = 1 in let final core::int #t25 = 2 in (#t23, #t25, 3, {a: #t24, b: 4, c: 5});
let final core::int #t26 = 0 in let final core::int #t27 = 1 in let final core::int #t28 = 2 in (#t27, #t28, 3, {a: #t26, b: 4, c: 5});
}
constants {
#C1 = TypeLiteralConstant(core::int*)
#C2 = TypeLiteralConstant(core::String*)
}

View file

@ -26,7 +26,7 @@ static method method() → dynamic {
(0, {b: 1});
({a: 0, b: 1});
let final core::int #t1 = 0 in (1, {a: #t1});
(core::int, core::String);
(#C1, #C2);
}
static method sorting() → dynamic {
({a: 0, b: 1, c: 2, d: 3});
@ -41,11 +41,13 @@ static method sorting() → dynamic {
let final core::int #t26 = 0 in let final core::int #t27 = 1 in let final core::int #t28 = 2 in (#t27, #t28, 3, {a: #t26, b: 4, c: 5});
}
constants {
#C1 = TypeLiteralConstant(core::int*)
#C2 = TypeLiteralConstant(core::String*)
}
Extra constant evaluation status:
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:10:7 -> IntConstant(0)
Evaluated: TypeLiteral @ org-dartlang-testcase:///record_literal.dart:11:4 -> TypeLiteralConstant(int*)
Evaluated: TypeLiteral @ org-dartlang-testcase:///record_literal.dart:11:9 -> TypeLiteralConstant(String*)
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:16:7 -> IntConstant(0)
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:16:13 -> IntConstant(1)
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:16:19 -> IntConstant(2)
@ -73,4 +75,4 @@ Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:23:10 -> I
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:24:10 -> IntConstant(1)
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:24:13 -> IntConstant(2)
Evaluated: VariableGet @ org-dartlang-testcase:///record_literal.dart:24:7 -> IntConstant(0)
Extra constant evaluation: evaluated: 75, effectively constant: 30
Extra constant evaluation: evaluated: 73, effectively constant: 28

View file

@ -8728,7 +8728,12 @@ class RecordLiteral extends Expression {
}
@override
void transformOrRemoveChildren(RemovingTransformer v) {}
void transformOrRemoveChildren(RemovingTransformer v) {
v.transformExpressionList(positional, this);
v.transformNamedExpressionList(named, this);
recordType =
v.visitDartType(recordType, cannotRemoveSentinel) as RecordType;
}
@override
String toString() {