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

Unified Diff: runtime/vm/kernel_binary_flowgraph.cc

Issue 2949493002: [kernel] Check type for list literals (Closed)
Patch Set: Address comments and fix issue with type_arguments representing dynamic (i.e. being null) Created 3 years, 6 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 | « no previous file | tests/language/language_kernel.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_binary_flowgraph.cc
diff --git a/runtime/vm/kernel_binary_flowgraph.cc b/runtime/vm/kernel_binary_flowgraph.cc
index 05abe524f5461cdf9b389471c383236ecd05fb0c..d32a7227aacbbf1ff71fbf5d5a583dcf7d3c0c3d 100644
--- a/runtime/vm/kernel_binary_flowgraph.cc
+++ b/runtime/vm/kernel_binary_flowgraph.cc
@@ -5511,15 +5511,26 @@ Fragment StreamingFlowGraphBuilder::BuildListLiteral(bool is_const,
instructions += Constant(Object::empty_array());
} else {
// The type arguments for CreateArray.
- instructions += Constant(TypeArguments::ZoneHandle(Z));
+ instructions += Constant(type_arguments);
instructions += IntConstant(length);
instructions += CreateArray();
+ AbstractType& list_type = AbstractType::ZoneHandle(Z);
+ if (I->type_checks()) {
+ if (type_arguments.IsNull()) {
+ // It was dynamic.
+ list_type = Object::dynamic_type().raw();
+ } else {
+ list_type = type_arguments.TypeAt(0);
+ }
+ }
LocalVariable* array = MakeTemporary();
for (intptr_t i = 0; i < length; ++i) {
instructions += LoadLocal(array);
instructions += IntConstant(i);
instructions += BuildExpression(); // read ith expression.
+ instructions += CheckAssignableInCheckedMode(
+ list_type, Symbols::ListLiteralElement());
instructions += StoreIndexed(kArrayCid);
instructions += Drop();
}
« no previous file with comments | « no previous file | tests/language/language_kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698