From 49a7fa1c116e1d4117d621458af1bdbcbc57a9d2 Mon Sep 17 00:00:00 2001 From: Dmitry Stefantsov Date: Tue, 26 Mar 2019 17:23:10 +0000 Subject: [PATCH] [cfe] Add inference and type checks for if-elements in lists and sets Change-Id: Iad4e6a6ed86e17f97f6bb7ad16f2bff20ab84fae Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97925 Reviewed-by: Kevin Millikin --- .../src/fasta/kernel/inference_visitor.dart | 183 +++--- .../src/fasta/kernel/kernel_shadow_ast.dart | 1 + .../control_flow_collection_inference.dart | 76 +++ ...ow_collection_inference.dart.legacy.expect | 572 ++++++++++++++++++ ...n_inference.dart.legacy.transformed.expect | 572 ++++++++++++++++++ ...w_collection_inference.dart.outline.expect | 12 + ...ow_collection_inference.dart.strong.expect | 514 ++++++++++++++++ ...n_inference.dart.strong.transformed.expect | 514 ++++++++++++++++ .../testcases/text_serialization.status | 1 + tests/co19_2/co19_2-kernel.status | 12 - tests/language_2/language_2_kernel.status | 4 - 11 files changed, 2345 insertions(+), 116 deletions(-) create mode 100644 pkg/front_end/testcases/control_flow_collection_inference.dart create mode 100644 pkg/front_end/testcases/control_flow_collection_inference.dart.legacy.expect create mode 100644 pkg/front_end/testcases/control_flow_collection_inference.dart.legacy.transformed.expect create mode 100644 pkg/front_end/testcases/control_flow_collection_inference.dart.outline.expect create mode 100644 pkg/front_end/testcases/control_flow_collection_inference.dart.strong.expect create mode 100644 pkg/front_end/testcases/control_flow_collection_inference.dart.strong.transformed.expect diff --git a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart index e0084e7eb5be7..5f2ac7ced4423 100644 --- a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart +++ b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart @@ -690,17 +690,25 @@ class InferenceVisitor extends BodyVisitor1 { return getSpreadElementType(spreadType, element.isNullAware) ?? const DynamicType(); } else if (element is IfElement) { - // TODO(kmillikin): Implement inference rules for if elements. inferrer.inferExpression(element.condition, inferrer.coreTypes.boolClass.rawType, typeChecksNeeded, isVoidAllowed: false); - inferElement(element.then, index, inferredTypeArgument, spreadTypes, - inferenceNeeded, typeChecksNeeded); + DartType thenType = inferElement(element.then, index, + inferredTypeArgument, spreadTypes, inferenceNeeded, typeChecksNeeded); + DartType otherwiseType; if (element.otherwise != null) { - inferElement(element.otherwise, index, inferredTypeArgument, - spreadTypes, inferenceNeeded, typeChecksNeeded); + otherwiseType = inferElement( + element.otherwise, + index, + inferredTypeArgument, + spreadTypes, + inferenceNeeded, + typeChecksNeeded); } - return const DynamicType(); + return otherwiseType == null + ? thenType + : inferrer.typeSchemaEnvironment + .getStandardUpperBound(thenType, otherwiseType); } else if (element is ForElement) { // TODO(kmillikin): Implement inference rules for for elements. for (VariableDeclaration declaration in element.variables) { @@ -751,6 +759,71 @@ class InferenceVisitor extends BodyVisitor1 { } } + void checkElement(Expression item, Expression parent, DartType typeArgument, + DartType actualType, DartType spreadType) { + if (item is SpreadElement) { + DartType spreadElementType = + getSpreadElementType(spreadType, item.isNullAware); + if (spreadElementType == null) { + if (spreadType is InterfaceType && + spreadType.classNode == inferrer.coreTypes.nullClass && + !item.isNullAware) { + parent.replaceChild( + item, + inferrer.helper.desugarSyntheticExpression(inferrer.helper + .buildProblem(messageNonNullAwareSpreadIsNull, + item.expression.fileOffset, 1))); + } else { + parent.replaceChild( + item, + inferrer.helper.desugarSyntheticExpression(inferrer.helper + .buildProblem( + templateSpreadTypeMismatch.withArguments(spreadType), + item.expression.fileOffset, + 1))); + } + } else if (spreadType is DynamicType) { + inferrer.ensureAssignable(inferrer.coreTypes.iterableClass.rawType, + spreadType, item.expression, item.expression.fileOffset); + } else if (spreadType is InterfaceType) { + if (!inferrer.isAssignable(typeArgument, spreadElementType)) { + parent.replaceChild( + item, + inferrer.helper.desugarSyntheticExpression(inferrer.helper + .buildProblem( + templateSpreadElementTypeMismatch.withArguments( + spreadElementType, typeArgument), + item.expression.fileOffset, + 1))); + } + } + } else if (item is IfElement) { + if (!inferrer.isAssignable(typeArgument, actualType)) { + int offset = + item.otherwise == null ? item.then.fileOffset : item.fileOffset; + parent.replaceChild( + item, + inferrer.helper.desugarSyntheticExpression(inferrer.helper + .buildProblem( + templateInvalidAssignment.withArguments( + actualType, typeArgument), + offset, + 1))); + } else { + checkElement(item.then, item, typeArgument, actualType, spreadType); + if (item.otherwise != null) { + checkElement( + item.otherwise, item, typeArgument, actualType, spreadType); + } + } + } else if (item is ForElement || item is ForInElement) { + // TODO(kmillikin): Insert type checks on loop elements. + } else { + inferrer.ensureAssignable(typeArgument, actualType, item, item.fileOffset, + isVoidAllowed: typeArgument is VoidType); + } + } + void visitListLiteralJudgment( ListLiteralJudgment node, DartType typeContext) { var listClass = inferrer.coreTypes.listClass; @@ -809,53 +882,8 @@ class InferenceVisitor extends BodyVisitor1 { } if (typeChecksNeeded) { for (int i = 0; i < node.expressions.length; i++) { - Expression item = node.expressions[i]; - if (item is SpreadElement) { - DartType spreadType = spreadTypes[i]; - DartType spreadElementType = - getSpreadElementType(spreadType, item.isNullAware); - if (spreadElementType == null) { - if (spreadType is InterfaceType && - spreadType.classNode == inferrer.coreTypes.nullClass && - !item.isNullAware) { - node.replaceChild( - node.expressions[i], - inferrer.helper.desugarSyntheticExpression(inferrer.helper - .buildProblem(messageNonNullAwareSpreadIsNull, - item.expression.fileOffset, 1))); - } else { - node.replaceChild( - node.expressions[i], - inferrer.helper.desugarSyntheticExpression(inferrer.helper - .buildProblem( - templateSpreadTypeMismatch.withArguments(spreadType), - item.expression.fileOffset, - 1))); - } - } else if (spreadType is DynamicType) { - inferrer.ensureAssignable(inferrer.coreTypes.iterableClass.rawType, - spreadType, item.expression, item.expression.fileOffset); - } else if (spreadType is InterfaceType) { - if (!inferrer.isAssignable(node.typeArgument, spreadElementType)) { - node.replaceChild( - node.expressions[i], - inferrer.helper.desugarSyntheticExpression(inferrer.helper - .buildProblem( - templateSpreadElementTypeMismatch.withArguments( - spreadElementType, node.typeArgument), - item.expression.fileOffset, - 1))); - } - } - } else if (item is IfElement) { - // TODO(kmillikin): Insert type checks on if elements. - } else if (item is ForElement || item is ForInElement) { - // TODO(kmillikin): Insert type checks on loop elements. - } else { - inferrer.ensureAssignable( - node.typeArgument, actualTypes[i], item, item.fileOffset, - isVoidAllowed: node.typeArgument is VoidType); - } + checkElement(node.expressions[i], node, node.typeArgument, + actualTypes[i], spreadTypes[i]); } } node.inferredType = new InterfaceType(listClass, [inferredTypeArgument]); @@ -1595,53 +1623,8 @@ class InferenceVisitor extends BodyVisitor1 { } if (typeChecksNeeded) { for (int i = 0; i < node.expressions.length; i++) { - Expression item = node.expressions[i]; - if (item is SpreadElement) { - DartType spreadType = spreadTypes[i]; - DartType spreadElementType = - getSpreadElementType(spreadType, item.isNullAware); - if (spreadElementType == null) { - if (spreadType is InterfaceType && - spreadType.classNode == inferrer.coreTypes.nullClass && - !item.isNullAware) { - node.replaceChild( - node.expressions[i], - inferrer.helper.desugarSyntheticExpression(inferrer.helper - .buildProblem(messageNonNullAwareSpreadIsNull, - item.expression.fileOffset, 1))); - } else { - node.replaceChild( - node.expressions[i], - inferrer.helper.desugarSyntheticExpression(inferrer.helper - .buildProblem( - templateSpreadTypeMismatch.withArguments(spreadType), - item.expression.fileOffset, - 1))); - } - } else if (spreadType is DynamicType) { - inferrer.ensureAssignable(inferrer.coreTypes.iterableClass.rawType, - spreadType, item.expression, item.expression.fileOffset); - } else if (spreadType is InterfaceType) { - if (!inferrer.isAssignable(node.typeArgument, spreadElementType)) { - node.replaceChild( - node.expressions[i], - inferrer.helper.desugarSyntheticExpression(inferrer.helper - .buildProblem( - templateSpreadElementTypeMismatch.withArguments( - spreadElementType, node.typeArgument), - item.expression.fileOffset, - 1))); - } - } - } else if (item is IfElement) { - // TODO(kmillikin): Insert type checks on if elements. - } else if (item is ForElement || item is ForInElement) { - // TODO(kmillikin): Insert type checks on loop elements. - } else { - inferrer.ensureAssignable(node.typeArgument, actualTypes[i], - node.expressions[i], node.expressions[i].fileOffset, - isVoidAllowed: node.typeArgument is VoidType); - } + checkElement(node.expressions[i], node, node.typeArgument, + actualTypes[i], spreadTypes[i]); } } node.inferredType = new InterfaceType(setClass, [inferredTypeArgument]); diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart index 9c46480af87ad..bf8098694d2f8 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart @@ -48,6 +48,7 @@ import '../fasta_codes.dart' templateForInLoopElementTypeNotAssignable, templateForInLoopTypeNotIterable, templateIntegerLiteralIsOutOfRange, + templateInvalidAssignment, templateSpreadElementTypeMismatch, templateSpreadMapEntryElementKeyTypeMismatch, templateSpreadMapEntryElementValueTypeMismatch, diff --git a/pkg/front_end/testcases/control_flow_collection_inference.dart b/pkg/front_end/testcases/control_flow_collection_inference.dart new file mode 100644 index 0000000000000..d80ab77ea08e1 --- /dev/null +++ b/pkg/front_end/testcases/control_flow_collection_inference.dart @@ -0,0 +1,76 @@ +// Copyright (c) 2019, 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. + +// Oracle is generic to test the inference in conditions of if-elements. +oracle([T t]) => true; + +testIfElement(dynamic dynVar, List listInt, List listDouble) { + var list10 = [if (oracle("foo")) 42]; + var set10 = {if (oracle("foo")) 42, null}; + var list11 = [if (oracle("foo")) dynVar]; + var set11 = {if (oracle("foo")) dynVar, null}; + var list12 = [if (oracle("foo")) [42]]; + var set12 = {if (oracle("foo")) [42], null}; + var list20 = [if (oracle("foo")) ...[42]]; + var set20 = {if (oracle("foo")) ...[42], null}; + var list21 = [if (oracle("foo")) ...[dynVar]]; + var set21 = {if (oracle("foo")) ...[dynVar], null}; + var list22 = [if (oracle("foo")) ...[[42]]]; + var set22 = {if (oracle("foo")) ...[[42]], null}; + var list30 = [if (oracle("foo")) if (oracle()) ...[42]]; + var set30 = {if (oracle("foo")) if (oracle()) ...[42], null}; + var list31 = [if (oracle("foo")) if (oracle()) ...[dynVar]]; + var set31 = {if (oracle("foo")) if (oracle()) ...[dynVar], null}; + var list33 = [if (oracle("foo")) if (oracle()) ...[[42]]]; + var set33 = {if (oracle("foo")) if (oracle()) ...[[42]], null}; + List> list40 = [if (oracle("foo")) ...[[]]]; + Set> set40 = {if (oracle("foo")) ...[[]], null}; + List> list41 = [if (oracle("foo")) ...{[]}]; + Set> set41 = {if (oracle("foo")) ...{[]}, null}; + List> list42 = [if (oracle("foo")) if (oracle()) ...[[]]]; + Set> set42 = {if (oracle("foo")) if (oracle()) ...[[]], null}; + List list50 = [if (oracle("foo")) ...[]]; + Set set50 = {if (oracle("foo")) ...[], null}; + List list51 = [if (oracle("foo")) ...{}]; + Set set51 = {if (oracle("foo")) ...{}, null}; + List list52 = [if (oracle("foo")) if (oracle()) ...[]]; + Set set52 = {if (oracle("foo")) if (oracle()) ...[], null}; + List> list60 = [if (oracle("foo")) ...[[]]]; + Set> set60 = {if (oracle("foo")) ...[[]], null}; + List> list61 = [if (oracle("foo")) if (oracle()) ...[[]]]; + Set> set61 = {if (oracle("foo")) if (oracle()) ...[[]], null}; + List> list70 = [if (oracle("foo")) []]; + Set> set70 = {if (oracle("foo")) [], null}; + List> list71 = [if (oracle("foo")) if (oracle()) []]; + Set> set71 = {if (oracle("foo")) if (oracle()) [], null}; + var list80 = [if (oracle("foo")) 42 else 3.14]; + var set80 = {if (oracle("foo")) 42 else 3.14, null}; + var list81 = [if (oracle("foo")) ...listInt else ...listDouble]; + var set81 = {if (oracle("foo")) ...listInt else ...listDouble, null}; + var list82 = [if (oracle("foo")) ...listInt else ...dynVar]; + var set82 = {if (oracle("foo")) ...listInt else ...dynVar, null}; + var list83 = [if (oracle("foo")) 42 else ...listDouble]; + var set83 = {if (oracle("foo")) ...listInt else 3.14, null}; + List list90 = [if (oracle("foo")) dynVar]; + Set set90 = {if (oracle("foo")) dynVar, null}; + List list91 = [if (oracle("foo")) ...dynVar]; + Set set91 = {if (oracle("foo")) ...dynVar, null}; +} + +testIfElementErrors(Map map) { + [if (oracle("foo")) "bar"]; + {if (oracle("foo")) "bar", null}; + [if (oracle("foo")) ...["bar"]]; + {if (oracle("foo")) ...["bar"], null}; + [if (oracle("foo")) ...map]; + {if (oracle("foo")) ...map, null}; + [if (oracle("foo")) 42 else 3.14]; + {if (oracle("foo")) 42 else 3.14, null}; + [if (oracle("foo")) ...map else 42]; + {if (oracle("foo")) ...map else 42, null}; + [if (oracle("foo")) 42 else ...map]; + {if (oracle("foo")) ...map else 42, null}; +} + +main() {} diff --git a/pkg/front_end/testcases/control_flow_collection_inference.dart.legacy.expect b/pkg/front_end/testcases/control_flow_collection_inference.dart.legacy.expect new file mode 100644 index 0000000000000..4cda5055e6afa --- /dev/null +++ b/pkg/front_end/testcases/control_flow_collection_inference.dart.legacy.expect @@ -0,0 +1,572 @@ +library; +// +// Problems in library: +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:9:17: Error: Unexpected token 'if'. +// var list10 = [if (oracle("foo")) 42]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:10:16: Error: Unexpected token 'if'. +// var set10 = {if (oracle("foo")) 42, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:11:17: Error: Unexpected token 'if'. +// var list11 = [if (oracle("foo")) dynVar]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:12:16: Error: Unexpected token 'if'. +// var set11 = {if (oracle("foo")) dynVar, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:13:17: Error: Unexpected token 'if'. +// var list12 = [if (oracle("foo")) [42]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:14:16: Error: Unexpected token 'if'. +// var set12 = {if (oracle("foo")) [42], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:15:36: Error: Unexpected token '...'. +// var list20 = [if (oracle("foo")) ...[42]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:15:17: Error: Unexpected token 'if'. +// var list20 = [if (oracle("foo")) ...[42]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:16:35: Error: Unexpected token '...'. +// var set20 = {if (oracle("foo")) ...[42], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:16:16: Error: Unexpected token 'if'. +// var set20 = {if (oracle("foo")) ...[42], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:17:36: Error: Unexpected token '...'. +// var list21 = [if (oracle("foo")) ...[dynVar]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:17:17: Error: Unexpected token 'if'. +// var list21 = [if (oracle("foo")) ...[dynVar]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:18:35: Error: Unexpected token '...'. +// var set21 = {if (oracle("foo")) ...[dynVar], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:18:16: Error: Unexpected token 'if'. +// var set21 = {if (oracle("foo")) ...[dynVar], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:19:36: Error: Unexpected token '...'. +// var list22 = [if (oracle("foo")) ...[[42]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:19:17: Error: Unexpected token 'if'. +// var list22 = [if (oracle("foo")) ...[[42]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:20:35: Error: Unexpected token '...'. +// var set22 = {if (oracle("foo")) ...[[42]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:20:16: Error: Unexpected token 'if'. +// var set22 = {if (oracle("foo")) ...[[42]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:21:50: Error: Unexpected token '...'. +// var list30 = [if (oracle("foo")) if (oracle()) ...[42]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:21:36: Error: Unexpected token 'if'. +// var list30 = [if (oracle("foo")) if (oracle()) ...[42]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:21:17: Error: Unexpected token 'if'. +// var list30 = [if (oracle("foo")) if (oracle()) ...[42]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:22:49: Error: Unexpected token '...'. +// var set30 = {if (oracle("foo")) if (oracle()) ...[42], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:22:35: Error: Unexpected token 'if'. +// var set30 = {if (oracle("foo")) if (oracle()) ...[42], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:22:16: Error: Unexpected token 'if'. +// var set30 = {if (oracle("foo")) if (oracle()) ...[42], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:23:50: Error: Unexpected token '...'. +// var list31 = [if (oracle("foo")) if (oracle()) ...[dynVar]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:23:36: Error: Unexpected token 'if'. +// var list31 = [if (oracle("foo")) if (oracle()) ...[dynVar]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:23:17: Error: Unexpected token 'if'. +// var list31 = [if (oracle("foo")) if (oracle()) ...[dynVar]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:24:49: Error: Unexpected token '...'. +// var set31 = {if (oracle("foo")) if (oracle()) ...[dynVar], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:24:35: Error: Unexpected token 'if'. +// var set31 = {if (oracle("foo")) if (oracle()) ...[dynVar], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:24:16: Error: Unexpected token 'if'. +// var set31 = {if (oracle("foo")) if (oracle()) ...[dynVar], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:25:50: Error: Unexpected token '...'. +// var list33 = [if (oracle("foo")) if (oracle()) ...[[42]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:25:36: Error: Unexpected token 'if'. +// var list33 = [if (oracle("foo")) if (oracle()) ...[[42]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:25:17: Error: Unexpected token 'if'. +// var list33 = [if (oracle("foo")) if (oracle()) ...[[42]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:26:49: Error: Unexpected token '...'. +// var set33 = {if (oracle("foo")) if (oracle()) ...[[42]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:26:35: Error: Unexpected token 'if'. +// var set33 = {if (oracle("foo")) if (oracle()) ...[[42]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:26:16: Error: Unexpected token 'if'. +// var set33 = {if (oracle("foo")) if (oracle()) ...[[42]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:27:48: Error: Unexpected token '...'. +// List> list40 = [if (oracle("foo")) ...[[]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:27:29: Error: Unexpected token 'if'. +// List> list40 = [if (oracle("foo")) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:28:46: Error: Unexpected token '...'. +// Set> set40 = {if (oracle("foo")) ...[[]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:28:27: Error: Unexpected token 'if'. +// Set> set40 = {if (oracle("foo")) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:29:48: Error: Unexpected token '...'. +// List> list41 = [if (oracle("foo")) ...{[]}]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:29:29: Error: Unexpected token 'if'. +// List> list41 = [if (oracle("foo")) ...{[]}]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:30:46: Error: Unexpected token '...'. +// Set> set41 = {if (oracle("foo")) ...{[]}, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:30:27: Error: Unexpected token 'if'. +// Set> set41 = {if (oracle("foo")) ...{[]}, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:31:62: Error: Unexpected token '...'. +// List> list42 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:31:48: Error: Unexpected token 'if'. +// List> list42 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:31:29: Error: Unexpected token 'if'. +// List> list42 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:32:60: Error: Unexpected token '...'. +// Set> set42 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:32:46: Error: Unexpected token 'if'. +// Set> set42 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:32:27: Error: Unexpected token 'if'. +// Set> set42 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:33:42: Error: Unexpected token '...'. +// List list50 = [if (oracle("foo")) ...[]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:33:23: Error: Unexpected token 'if'. +// List list50 = [if (oracle("foo")) ...[]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:34:40: Error: Unexpected token '...'. +// Set set50 = {if (oracle("foo")) ...[], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:34:21: Error: Unexpected token 'if'. +// Set set50 = {if (oracle("foo")) ...[], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:35:42: Error: Unexpected token '...'. +// List list51 = [if (oracle("foo")) ...{}]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:35:23: Error: Unexpected token 'if'. +// List list51 = [if (oracle("foo")) ...{}]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:36:40: Error: Unexpected token '...'. +// Set set51 = {if (oracle("foo")) ...{}, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:36:21: Error: Unexpected token 'if'. +// Set set51 = {if (oracle("foo")) ...{}, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:37:56: Error: Unexpected token '...'. +// List list52 = [if (oracle("foo")) if (oracle()) ...[]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:37:42: Error: Unexpected token 'if'. +// List list52 = [if (oracle("foo")) if (oracle()) ...[]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:37:23: Error: Unexpected token 'if'. +// List list52 = [if (oracle("foo")) if (oracle()) ...[]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:38:54: Error: Unexpected token '...'. +// Set set52 = {if (oracle("foo")) if (oracle()) ...[], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:38:40: Error: Unexpected token 'if'. +// Set set52 = {if (oracle("foo")) if (oracle()) ...[], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:38:21: Error: Unexpected token 'if'. +// Set set52 = {if (oracle("foo")) if (oracle()) ...[], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:39:48: Error: Unexpected token '...'. +// List> list60 = [if (oracle("foo")) ...[[]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:39:29: Error: Unexpected token 'if'. +// List> list60 = [if (oracle("foo")) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:40:46: Error: Unexpected token '...'. +// Set> set60 = {if (oracle("foo")) ...[[]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:40:27: Error: Unexpected token 'if'. +// Set> set60 = {if (oracle("foo")) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:41:62: Error: Unexpected token '...'. +// List> list61 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:41:48: Error: Unexpected token 'if'. +// List> list61 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:41:29: Error: Unexpected token 'if'. +// List> list61 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:42:60: Error: Unexpected token '...'. +// Set> set61 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:42:46: Error: Unexpected token 'if'. +// Set> set61 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:42:27: Error: Unexpected token 'if'. +// Set> set61 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:43:29: Error: Unexpected token 'if'. +// List> list70 = [if (oracle("foo")) []]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:44:27: Error: Unexpected token 'if'. +// Set> set70 = {if (oracle("foo")) [], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:45:48: Error: Unexpected token 'if'. +// List> list71 = [if (oracle("foo")) if (oracle()) []]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:45:29: Error: Unexpected token 'if'. +// List> list71 = [if (oracle("foo")) if (oracle()) []]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:46:46: Error: Unexpected token 'if'. +// Set> set71 = {if (oracle("foo")) if (oracle()) [], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:46:27: Error: Unexpected token 'if'. +// Set> set71 = {if (oracle("foo")) if (oracle()) [], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:47:17: Error: Unexpected token 'if'. +// var list80 = [if (oracle("foo")) 42 else 3.14]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:48:16: Error: Unexpected token 'if'. +// var set80 = {if (oracle("foo")) 42 else 3.14, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:49:36: Error: Unexpected token '...'. +// var list81 = [if (oracle("foo")) ...listInt else ...listDouble]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:49:52: Error: Unexpected token '...'. +// var list81 = [if (oracle("foo")) ...listInt else ...listDouble]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:49:17: Error: Unexpected token 'if'. +// var list81 = [if (oracle("foo")) ...listInt else ...listDouble]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:50:35: Error: Unexpected token '...'. +// var set81 = {if (oracle("foo")) ...listInt else ...listDouble, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:50:51: Error: Unexpected token '...'. +// var set81 = {if (oracle("foo")) ...listInt else ...listDouble, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:50:16: Error: Unexpected token 'if'. +// var set81 = {if (oracle("foo")) ...listInt else ...listDouble, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:51:36: Error: Unexpected token '...'. +// var list82 = [if (oracle("foo")) ...listInt else ...dynVar]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:51:52: Error: Unexpected token '...'. +// var list82 = [if (oracle("foo")) ...listInt else ...dynVar]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:51:17: Error: Unexpected token 'if'. +// var list82 = [if (oracle("foo")) ...listInt else ...dynVar]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:52:35: Error: Unexpected token '...'. +// var set82 = {if (oracle("foo")) ...listInt else ...dynVar, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:52:51: Error: Unexpected token '...'. +// var set82 = {if (oracle("foo")) ...listInt else ...dynVar, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:52:16: Error: Unexpected token 'if'. +// var set82 = {if (oracle("foo")) ...listInt else ...dynVar, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:53:44: Error: Unexpected token '...'. +// var list83 = [if (oracle("foo")) 42 else ...listDouble]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:53:17: Error: Unexpected token 'if'. +// var list83 = [if (oracle("foo")) 42 else ...listDouble]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:54:35: Error: Unexpected token '...'. +// var set83 = {if (oracle("foo")) ...listInt else 3.14, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:54:16: Error: Unexpected token 'if'. +// var set83 = {if (oracle("foo")) ...listInt else 3.14, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:55:23: Error: Unexpected token 'if'. +// List list90 = [if (oracle("foo")) dynVar]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:56:21: Error: Unexpected token 'if'. +// Set set90 = {if (oracle("foo")) dynVar, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:57:42: Error: Unexpected token '...'. +// List list91 = [if (oracle("foo")) ...dynVar]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:57:23: Error: Unexpected token 'if'. +// List list91 = [if (oracle("foo")) ...dynVar]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:58:40: Error: Unexpected token '...'. +// Set set91 = {if (oracle("foo")) ...dynVar, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:58:21: Error: Unexpected token 'if'. +// Set set91 = {if (oracle("foo")) ...dynVar, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:62:9: Error: Unexpected token 'if'. +// [if (oracle("foo")) "bar"]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:63:9: Error: Unexpected token 'if'. +// {if (oracle("foo")) "bar", null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:64:28: Error: Unexpected token '...'. +// [if (oracle("foo")) ...["bar"]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:64:9: Error: Unexpected token 'if'. +// [if (oracle("foo")) ...["bar"]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:65:28: Error: Unexpected token '...'. +// {if (oracle("foo")) ...["bar"], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:65:9: Error: Unexpected token 'if'. +// {if (oracle("foo")) ...["bar"], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:66:28: Error: Unexpected token '...'. +// [if (oracle("foo")) ...map]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:66:9: Error: Unexpected token 'if'. +// [if (oracle("foo")) ...map]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:67:28: Error: Unexpected token '...'. +// {if (oracle("foo")) ...map, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:67:9: Error: Unexpected token 'if'. +// {if (oracle("foo")) ...map, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:68:12: Error: Unexpected token 'if'. +// [if (oracle("foo")) 42 else 3.14]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:69:12: Error: Unexpected token 'if'. +// {if (oracle("foo")) 42 else 3.14, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:70:28: Error: Unexpected token '...'. +// [if (oracle("foo")) ...map else 42]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:70:9: Error: Unexpected token 'if'. +// [if (oracle("foo")) ...map else 42]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:71:28: Error: Unexpected token '...'. +// {if (oracle("foo")) ...map else 42, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:71:9: Error: Unexpected token 'if'. +// {if (oracle("foo")) ...map else 42, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:72:36: Error: Unexpected token '...'. +// [if (oracle("foo")) 42 else ...map]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:72:9: Error: Unexpected token 'if'. +// [if (oracle("foo")) 42 else ...map]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:73:28: Error: Unexpected token '...'. +// {if (oracle("foo")) ...map else 42, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:73:9: Error: Unexpected token 'if'. +// {if (oracle("foo")) ...map else 42, null}; +// ^^ +// +import self as self; +import "dart:core" as core; + +static method oracle([self::oracle::T t = null]) → dynamic + return true; +static method testIfElement(dynamic dynVar, core::List listInt, core::List listDouble) → dynamic { + dynamic list10 = []; + dynamic set10 = {null}; + dynamic list11 = []; + dynamic set11 = {null}; + dynamic list12 = []; + dynamic set12 = {null}; + dynamic list20 = []; + dynamic set20 = {null}; + dynamic list21 = []; + dynamic set21 = {null}; + dynamic list22 = []; + dynamic set22 = {null}; + dynamic list30 = []; + dynamic set30 = {null}; + dynamic list31 = []; + dynamic set31 = {null}; + dynamic list33 = []; + dynamic set33 = {null}; + core::List> list40 = []; + core::Set> set40 = {null}; + core::List> list41 = []; + core::Set> set41 = {null}; + core::List> list42 = []; + core::Set> set42 = {null}; + core::List list50 = []; + core::Set set50 = {null}; + core::List list51 = []; + core::Set set51 = {null}; + core::List list52 = []; + core::Set set52 = {null}; + core::List> list60 = []; + core::Set> set60 = {null}; + core::List> list61 = []; + core::Set> set61 = {null}; + core::List> list70 = []; + core::Set> set70 = {null}; + core::List> list71 = []; + core::Set> set71 = {null}; + dynamic list80 = []; + dynamic set80 = {null}; + dynamic list81 = []; + dynamic set81 = {null}; + dynamic list82 = []; + dynamic set82 = {null}; + dynamic list83 = []; + dynamic set83 = {null}; + core::List list90 = []; + core::Set set90 = {null}; + core::List list91 = []; + core::Set set91 = {null}; +} +static method testIfElementErrors(core::Map map) → dynamic { + []; + {null}; + []; + {null}; + []; + {null}; + []; + {null}; + []; + {null}; + []; + {null}; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/control_flow_collection_inference.dart.legacy.transformed.expect b/pkg/front_end/testcases/control_flow_collection_inference.dart.legacy.transformed.expect new file mode 100644 index 0000000000000..4cda5055e6afa --- /dev/null +++ b/pkg/front_end/testcases/control_flow_collection_inference.dart.legacy.transformed.expect @@ -0,0 +1,572 @@ +library; +// +// Problems in library: +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:9:17: Error: Unexpected token 'if'. +// var list10 = [if (oracle("foo")) 42]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:10:16: Error: Unexpected token 'if'. +// var set10 = {if (oracle("foo")) 42, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:11:17: Error: Unexpected token 'if'. +// var list11 = [if (oracle("foo")) dynVar]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:12:16: Error: Unexpected token 'if'. +// var set11 = {if (oracle("foo")) dynVar, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:13:17: Error: Unexpected token 'if'. +// var list12 = [if (oracle("foo")) [42]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:14:16: Error: Unexpected token 'if'. +// var set12 = {if (oracle("foo")) [42], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:15:36: Error: Unexpected token '...'. +// var list20 = [if (oracle("foo")) ...[42]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:15:17: Error: Unexpected token 'if'. +// var list20 = [if (oracle("foo")) ...[42]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:16:35: Error: Unexpected token '...'. +// var set20 = {if (oracle("foo")) ...[42], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:16:16: Error: Unexpected token 'if'. +// var set20 = {if (oracle("foo")) ...[42], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:17:36: Error: Unexpected token '...'. +// var list21 = [if (oracle("foo")) ...[dynVar]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:17:17: Error: Unexpected token 'if'. +// var list21 = [if (oracle("foo")) ...[dynVar]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:18:35: Error: Unexpected token '...'. +// var set21 = {if (oracle("foo")) ...[dynVar], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:18:16: Error: Unexpected token 'if'. +// var set21 = {if (oracle("foo")) ...[dynVar], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:19:36: Error: Unexpected token '...'. +// var list22 = [if (oracle("foo")) ...[[42]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:19:17: Error: Unexpected token 'if'. +// var list22 = [if (oracle("foo")) ...[[42]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:20:35: Error: Unexpected token '...'. +// var set22 = {if (oracle("foo")) ...[[42]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:20:16: Error: Unexpected token 'if'. +// var set22 = {if (oracle("foo")) ...[[42]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:21:50: Error: Unexpected token '...'. +// var list30 = [if (oracle("foo")) if (oracle()) ...[42]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:21:36: Error: Unexpected token 'if'. +// var list30 = [if (oracle("foo")) if (oracle()) ...[42]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:21:17: Error: Unexpected token 'if'. +// var list30 = [if (oracle("foo")) if (oracle()) ...[42]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:22:49: Error: Unexpected token '...'. +// var set30 = {if (oracle("foo")) if (oracle()) ...[42], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:22:35: Error: Unexpected token 'if'. +// var set30 = {if (oracle("foo")) if (oracle()) ...[42], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:22:16: Error: Unexpected token 'if'. +// var set30 = {if (oracle("foo")) if (oracle()) ...[42], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:23:50: Error: Unexpected token '...'. +// var list31 = [if (oracle("foo")) if (oracle()) ...[dynVar]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:23:36: Error: Unexpected token 'if'. +// var list31 = [if (oracle("foo")) if (oracle()) ...[dynVar]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:23:17: Error: Unexpected token 'if'. +// var list31 = [if (oracle("foo")) if (oracle()) ...[dynVar]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:24:49: Error: Unexpected token '...'. +// var set31 = {if (oracle("foo")) if (oracle()) ...[dynVar], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:24:35: Error: Unexpected token 'if'. +// var set31 = {if (oracle("foo")) if (oracle()) ...[dynVar], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:24:16: Error: Unexpected token 'if'. +// var set31 = {if (oracle("foo")) if (oracle()) ...[dynVar], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:25:50: Error: Unexpected token '...'. +// var list33 = [if (oracle("foo")) if (oracle()) ...[[42]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:25:36: Error: Unexpected token 'if'. +// var list33 = [if (oracle("foo")) if (oracle()) ...[[42]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:25:17: Error: Unexpected token 'if'. +// var list33 = [if (oracle("foo")) if (oracle()) ...[[42]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:26:49: Error: Unexpected token '...'. +// var set33 = {if (oracle("foo")) if (oracle()) ...[[42]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:26:35: Error: Unexpected token 'if'. +// var set33 = {if (oracle("foo")) if (oracle()) ...[[42]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:26:16: Error: Unexpected token 'if'. +// var set33 = {if (oracle("foo")) if (oracle()) ...[[42]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:27:48: Error: Unexpected token '...'. +// List> list40 = [if (oracle("foo")) ...[[]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:27:29: Error: Unexpected token 'if'. +// List> list40 = [if (oracle("foo")) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:28:46: Error: Unexpected token '...'. +// Set> set40 = {if (oracle("foo")) ...[[]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:28:27: Error: Unexpected token 'if'. +// Set> set40 = {if (oracle("foo")) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:29:48: Error: Unexpected token '...'. +// List> list41 = [if (oracle("foo")) ...{[]}]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:29:29: Error: Unexpected token 'if'. +// List> list41 = [if (oracle("foo")) ...{[]}]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:30:46: Error: Unexpected token '...'. +// Set> set41 = {if (oracle("foo")) ...{[]}, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:30:27: Error: Unexpected token 'if'. +// Set> set41 = {if (oracle("foo")) ...{[]}, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:31:62: Error: Unexpected token '...'. +// List> list42 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:31:48: Error: Unexpected token 'if'. +// List> list42 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:31:29: Error: Unexpected token 'if'. +// List> list42 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:32:60: Error: Unexpected token '...'. +// Set> set42 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:32:46: Error: Unexpected token 'if'. +// Set> set42 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:32:27: Error: Unexpected token 'if'. +// Set> set42 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:33:42: Error: Unexpected token '...'. +// List list50 = [if (oracle("foo")) ...[]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:33:23: Error: Unexpected token 'if'. +// List list50 = [if (oracle("foo")) ...[]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:34:40: Error: Unexpected token '...'. +// Set set50 = {if (oracle("foo")) ...[], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:34:21: Error: Unexpected token 'if'. +// Set set50 = {if (oracle("foo")) ...[], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:35:42: Error: Unexpected token '...'. +// List list51 = [if (oracle("foo")) ...{}]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:35:23: Error: Unexpected token 'if'. +// List list51 = [if (oracle("foo")) ...{}]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:36:40: Error: Unexpected token '...'. +// Set set51 = {if (oracle("foo")) ...{}, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:36:21: Error: Unexpected token 'if'. +// Set set51 = {if (oracle("foo")) ...{}, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:37:56: Error: Unexpected token '...'. +// List list52 = [if (oracle("foo")) if (oracle()) ...[]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:37:42: Error: Unexpected token 'if'. +// List list52 = [if (oracle("foo")) if (oracle()) ...[]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:37:23: Error: Unexpected token 'if'. +// List list52 = [if (oracle("foo")) if (oracle()) ...[]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:38:54: Error: Unexpected token '...'. +// Set set52 = {if (oracle("foo")) if (oracle()) ...[], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:38:40: Error: Unexpected token 'if'. +// Set set52 = {if (oracle("foo")) if (oracle()) ...[], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:38:21: Error: Unexpected token 'if'. +// Set set52 = {if (oracle("foo")) if (oracle()) ...[], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:39:48: Error: Unexpected token '...'. +// List> list60 = [if (oracle("foo")) ...[[]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:39:29: Error: Unexpected token 'if'. +// List> list60 = [if (oracle("foo")) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:40:46: Error: Unexpected token '...'. +// Set> set60 = {if (oracle("foo")) ...[[]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:40:27: Error: Unexpected token 'if'. +// Set> set60 = {if (oracle("foo")) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:41:62: Error: Unexpected token '...'. +// List> list61 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:41:48: Error: Unexpected token 'if'. +// List> list61 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:41:29: Error: Unexpected token 'if'. +// List> list61 = [if (oracle("foo")) if (oracle()) ...[[]]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:42:60: Error: Unexpected token '...'. +// Set> set61 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:42:46: Error: Unexpected token 'if'. +// Set> set61 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:42:27: Error: Unexpected token 'if'. +// Set> set61 = {if (oracle("foo")) if (oracle()) ...[[]], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:43:29: Error: Unexpected token 'if'. +// List> list70 = [if (oracle("foo")) []]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:44:27: Error: Unexpected token 'if'. +// Set> set70 = {if (oracle("foo")) [], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:45:48: Error: Unexpected token 'if'. +// List> list71 = [if (oracle("foo")) if (oracle()) []]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:45:29: Error: Unexpected token 'if'. +// List> list71 = [if (oracle("foo")) if (oracle()) []]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:46:46: Error: Unexpected token 'if'. +// Set> set71 = {if (oracle("foo")) if (oracle()) [], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:46:27: Error: Unexpected token 'if'. +// Set> set71 = {if (oracle("foo")) if (oracle()) [], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:47:17: Error: Unexpected token 'if'. +// var list80 = [if (oracle("foo")) 42 else 3.14]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:48:16: Error: Unexpected token 'if'. +// var set80 = {if (oracle("foo")) 42 else 3.14, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:49:36: Error: Unexpected token '...'. +// var list81 = [if (oracle("foo")) ...listInt else ...listDouble]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:49:52: Error: Unexpected token '...'. +// var list81 = [if (oracle("foo")) ...listInt else ...listDouble]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:49:17: Error: Unexpected token 'if'. +// var list81 = [if (oracle("foo")) ...listInt else ...listDouble]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:50:35: Error: Unexpected token '...'. +// var set81 = {if (oracle("foo")) ...listInt else ...listDouble, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:50:51: Error: Unexpected token '...'. +// var set81 = {if (oracle("foo")) ...listInt else ...listDouble, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:50:16: Error: Unexpected token 'if'. +// var set81 = {if (oracle("foo")) ...listInt else ...listDouble, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:51:36: Error: Unexpected token '...'. +// var list82 = [if (oracle("foo")) ...listInt else ...dynVar]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:51:52: Error: Unexpected token '...'. +// var list82 = [if (oracle("foo")) ...listInt else ...dynVar]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:51:17: Error: Unexpected token 'if'. +// var list82 = [if (oracle("foo")) ...listInt else ...dynVar]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:52:35: Error: Unexpected token '...'. +// var set82 = {if (oracle("foo")) ...listInt else ...dynVar, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:52:51: Error: Unexpected token '...'. +// var set82 = {if (oracle("foo")) ...listInt else ...dynVar, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:52:16: Error: Unexpected token 'if'. +// var set82 = {if (oracle("foo")) ...listInt else ...dynVar, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:53:44: Error: Unexpected token '...'. +// var list83 = [if (oracle("foo")) 42 else ...listDouble]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:53:17: Error: Unexpected token 'if'. +// var list83 = [if (oracle("foo")) 42 else ...listDouble]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:54:35: Error: Unexpected token '...'. +// var set83 = {if (oracle("foo")) ...listInt else 3.14, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:54:16: Error: Unexpected token 'if'. +// var set83 = {if (oracle("foo")) ...listInt else 3.14, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:55:23: Error: Unexpected token 'if'. +// List list90 = [if (oracle("foo")) dynVar]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:56:21: Error: Unexpected token 'if'. +// Set set90 = {if (oracle("foo")) dynVar, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:57:42: Error: Unexpected token '...'. +// List list91 = [if (oracle("foo")) ...dynVar]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:57:23: Error: Unexpected token 'if'. +// List list91 = [if (oracle("foo")) ...dynVar]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:58:40: Error: Unexpected token '...'. +// Set set91 = {if (oracle("foo")) ...dynVar, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:58:21: Error: Unexpected token 'if'. +// Set set91 = {if (oracle("foo")) ...dynVar, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:62:9: Error: Unexpected token 'if'. +// [if (oracle("foo")) "bar"]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:63:9: Error: Unexpected token 'if'. +// {if (oracle("foo")) "bar", null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:64:28: Error: Unexpected token '...'. +// [if (oracle("foo")) ...["bar"]]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:64:9: Error: Unexpected token 'if'. +// [if (oracle("foo")) ...["bar"]]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:65:28: Error: Unexpected token '...'. +// {if (oracle("foo")) ...["bar"], null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:65:9: Error: Unexpected token 'if'. +// {if (oracle("foo")) ...["bar"], null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:66:28: Error: Unexpected token '...'. +// [if (oracle("foo")) ...map]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:66:9: Error: Unexpected token 'if'. +// [if (oracle("foo")) ...map]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:67:28: Error: Unexpected token '...'. +// {if (oracle("foo")) ...map, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:67:9: Error: Unexpected token 'if'. +// {if (oracle("foo")) ...map, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:68:12: Error: Unexpected token 'if'. +// [if (oracle("foo")) 42 else 3.14]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:69:12: Error: Unexpected token 'if'. +// {if (oracle("foo")) 42 else 3.14, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:70:28: Error: Unexpected token '...'. +// [if (oracle("foo")) ...map else 42]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:70:9: Error: Unexpected token 'if'. +// [if (oracle("foo")) ...map else 42]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:71:28: Error: Unexpected token '...'. +// {if (oracle("foo")) ...map else 42, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:71:9: Error: Unexpected token 'if'. +// {if (oracle("foo")) ...map else 42, null}; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:72:36: Error: Unexpected token '...'. +// [if (oracle("foo")) 42 else ...map]; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:72:9: Error: Unexpected token 'if'. +// [if (oracle("foo")) 42 else ...map]; +// ^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:73:28: Error: Unexpected token '...'. +// {if (oracle("foo")) ...map else 42, null}; +// ^^^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:73:9: Error: Unexpected token 'if'. +// {if (oracle("foo")) ...map else 42, null}; +// ^^ +// +import self as self; +import "dart:core" as core; + +static method oracle([self::oracle::T t = null]) → dynamic + return true; +static method testIfElement(dynamic dynVar, core::List listInt, core::List listDouble) → dynamic { + dynamic list10 = []; + dynamic set10 = {null}; + dynamic list11 = []; + dynamic set11 = {null}; + dynamic list12 = []; + dynamic set12 = {null}; + dynamic list20 = []; + dynamic set20 = {null}; + dynamic list21 = []; + dynamic set21 = {null}; + dynamic list22 = []; + dynamic set22 = {null}; + dynamic list30 = []; + dynamic set30 = {null}; + dynamic list31 = []; + dynamic set31 = {null}; + dynamic list33 = []; + dynamic set33 = {null}; + core::List> list40 = []; + core::Set> set40 = {null}; + core::List> list41 = []; + core::Set> set41 = {null}; + core::List> list42 = []; + core::Set> set42 = {null}; + core::List list50 = []; + core::Set set50 = {null}; + core::List list51 = []; + core::Set set51 = {null}; + core::List list52 = []; + core::Set set52 = {null}; + core::List> list60 = []; + core::Set> set60 = {null}; + core::List> list61 = []; + core::Set> set61 = {null}; + core::List> list70 = []; + core::Set> set70 = {null}; + core::List> list71 = []; + core::Set> set71 = {null}; + dynamic list80 = []; + dynamic set80 = {null}; + dynamic list81 = []; + dynamic set81 = {null}; + dynamic list82 = []; + dynamic set82 = {null}; + dynamic list83 = []; + dynamic set83 = {null}; + core::List list90 = []; + core::Set set90 = {null}; + core::List list91 = []; + core::Set set91 = {null}; +} +static method testIfElementErrors(core::Map map) → dynamic { + []; + {null}; + []; + {null}; + []; + {null}; + []; + {null}; + []; + {null}; + []; + {null}; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/control_flow_collection_inference.dart.outline.expect b/pkg/front_end/testcases/control_flow_collection_inference.dart.outline.expect new file mode 100644 index 0000000000000..c6ed704263694 --- /dev/null +++ b/pkg/front_end/testcases/control_flow_collection_inference.dart.outline.expect @@ -0,0 +1,12 @@ +library; +import self as self; +import "dart:core" as core; + +static method oracle([self::oracle::T t]) → dynamic + ; +static method testIfElement(dynamic dynVar, core::List listInt, core::List listDouble) → dynamic + ; +static method testIfElementErrors(core::Map map) → dynamic + ; +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/control_flow_collection_inference.dart.strong.expect b/pkg/front_end/testcases/control_flow_collection_inference.dart.strong.expect new file mode 100644 index 0000000000000..e357217e5e86b --- /dev/null +++ b/pkg/front_end/testcases/control_flow_collection_inference.dart.strong.expect @@ -0,0 +1,514 @@ +library; +// +// Problems in library: +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:62:28: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +// Try changing the type of the left hand side, or casting the right hand side to 'int'. +// [if (oracle("foo")) "bar"]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:63:28: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +// Try changing the type of the left hand side, or casting the right hand side to 'int'. +// {if (oracle("foo")) "bar", null}; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:64:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +// Try changing the type of the left hand side, or casting the right hand side to 'int'. +// [if (oracle("foo")) ...["bar"]]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:65:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +// Try changing the type of the left hand side, or casting the right hand side to 'int'. +// {if (oracle("foo")) ...["bar"], null}; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:66:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// [if (oracle("foo")) ...map]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:67:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// {if (oracle("foo")) ...map, null}; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:68:12: Error: A value of type 'num' can't be assigned to a variable of type 'String'. +// Try changing the type of the left hand side, or casting the right hand side to 'String'. +// [if (oracle("foo")) 42 else 3.14]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:69:12: Error: A value of type 'num' can't be assigned to a variable of type 'String'. +// Try changing the type of the left hand side, or casting the right hand side to 'String'. +// {if (oracle("foo")) 42 else 3.14, null}; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:70:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// [if (oracle("foo")) ...map else 42]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:71:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// {if (oracle("foo")) ...map else 42, null}; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:72:39: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// [if (oracle("foo")) 42 else ...map]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:73:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// {if (oracle("foo")) ...map else 42, null}; +// ^ +// +import self as self; +import "dart:core" as core; +import "dart:collection" as col; + +static method oracle([self::oracle::T t = null]) → dynamic + return true; +static method testIfElement(dynamic dynVar, core::List listInt, core::List listDouble) → dynamic { + core::List list10 = block { + final core::List #t1 = []; + if(self::oracle("foo")) + #t1.{core::List::add}(42); + } =>#t1; + core::Set set10 = block { + final core::Set #t2 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t2.{core::Set::add}(42); + #t2.{core::Set::add}(null); + } =>#t2; + core::List list11 = block { + final core::List #t3 = []; + if(self::oracle("foo")) + #t3.{core::List::add}(dynVar); + } =>#t3; + core::Set set11 = block { + final core::Set #t4 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t4.{core::Set::add}(dynVar); + #t4.{core::Set::add}(null); + } =>#t4; + core::List> list12 = block { + final core::List> #t5 = >[]; + if(self::oracle("foo")) + #t5.{core::List::add}([42]); + } =>#t5; + core::Set> set12 = block { + final core::Set> #t6 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + #t6.{core::Set::add}([42]); + #t6.{core::Set::add}(null); + } =>#t6; + core::List list20 = block { + final core::List #t7 = []; + if(self::oracle("foo")) + for (final core::int #t8 in [42]) + #t7.{core::List::add}(#t8); + } =>#t7; + core::Set set20 = block { + final core::Set #t9 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::int #t10 in [42]) + #t9.{core::Set::add}(#t10); + #t9.{core::Set::add}(null); + } =>#t9; + core::List list21 = block { + final core::List #t11 = []; + if(self::oracle("foo")) + for (final dynamic #t12 in [dynVar]) + #t11.{core::List::add}(#t12); + } =>#t11; + core::Set set21 = block { + final core::Set #t13 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final dynamic #t14 in [dynVar]) + #t13.{core::Set::add}(#t14); + #t13.{core::Set::add}(null); + } =>#t13; + core::List> list22 = block { + final core::List> #t15 = >[]; + if(self::oracle("foo")) + for (final core::List #t16 in >[[42]]) + #t15.{core::List::add}(#t16); + } =>#t15; + core::Set> set22 = block { + final core::Set> #t17 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + for (final core::List #t18 in >[[42]]) + #t17.{core::Set::add}(#t18); + #t17.{core::Set::add}(null); + } =>#t17; + core::List list30 = block { + final core::List #t19 = []; + if(self::oracle("foo")) + if(self::oracle()) + for (final core::int #t20 in [42]) + #t19.{core::List::add}(#t20); + } =>#t19; + core::Set set30 = block { + final core::Set #t21 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + if(self::oracle()) + for (final core::int #t22 in [42]) + #t21.{core::Set::add}(#t22); + #t21.{core::Set::add}(null); + } =>#t21; + core::List list31 = block { + final core::List #t23 = []; + if(self::oracle("foo")) + if(self::oracle()) + for (final dynamic #t24 in [dynVar]) + #t23.{core::List::add}(#t24); + } =>#t23; + core::Set set31 = block { + final core::Set #t25 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + if(self::oracle()) + for (final dynamic #t26 in [dynVar]) + #t25.{core::Set::add}(#t26); + #t25.{core::Set::add}(null); + } =>#t25; + core::List> list33 = block { + final core::List> #t27 = >[]; + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t28 in >[[42]]) + #t27.{core::List::add}(#t28); + } =>#t27; + core::Set> set33 = block { + final core::Set> #t29 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t30 in >[[42]]) + #t29.{core::Set::add}(#t30); + #t29.{core::Set::add}(null); + } =>#t29; + core::List> list40 = block { + final core::List> #t31 = >[]; + if(self::oracle("foo")) + for (final core::List #t32 in >[[]]) + #t31.{core::List::add}(#t32); + } =>#t31; + core::Set> set40 = block { + final core::Set> #t33 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + for (final core::List #t34 in >[[]]) + #t33.{core::Set::add}(#t34); + #t33.{core::Set::add}(null); + } =>#t33; + core::List> list41 = block { + final core::List> #t35 = >[]; + if(self::oracle("foo")) + for (final core::List #t36 in let final core::Set> #t37 = col::LinkedHashSet::•>() in let final dynamic #t38 = #t37.{core::Set::add}([]) in #t37) + #t35.{core::List::add}(#t36); + } =>#t35; + core::Set> set41 = block { + final core::Set> #t39 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + for (final core::List #t40 in let final core::Set> #t41 = col::LinkedHashSet::•>() in let final dynamic #t42 = #t41.{core::Set::add}([]) in #t41) + #t39.{core::Set::add}(#t40); + #t39.{core::Set::add}(null); + } =>#t39; + core::List> list42 = block { + final core::List> #t43 = >[]; + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t44 in >[[]]) + #t43.{core::List::add}(#t44); + } =>#t43; + core::Set> set42 = block { + final core::Set> #t45 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t46 in >[[]]) + #t45.{core::Set::add}(#t46); + #t45.{core::Set::add}(null); + } =>#t45; + core::List list50 = block { + final core::List #t47 = []; + if(self::oracle("foo")) + for (final core::int #t48 in []) + #t47.{core::List::add}(#t48); + } =>#t47; + core::Set set50 = block { + final core::Set #t49 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::int #t50 in []) + #t49.{core::Set::add}(#t50); + #t49.{core::Set::add}(null); + } =>#t49; + core::List list51 = block { + final core::List #t51 = []; + if(self::oracle("foo")) + for (final core::int #t52 in let final core::Set #t53 = col::LinkedHashSet::•() in #t53) + #t51.{core::List::add}(#t52); + } =>#t51; + core::Set set51 = block { + final core::Set #t54 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::int #t55 in let final core::Set #t56 = col::LinkedHashSet::•() in #t56) + #t54.{core::Set::add}(#t55); + #t54.{core::Set::add}(null); + } =>#t54; + core::List list52 = block { + final core::List #t57 = []; + if(self::oracle("foo")) + if(self::oracle()) + for (final core::int #t58 in []) + #t57.{core::List::add}(#t58); + } =>#t57; + core::Set set52 = block { + final core::Set #t59 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + if(self::oracle()) + for (final core::int #t60 in []) + #t59.{core::Set::add}(#t60); + #t59.{core::Set::add}(null); + } =>#t59; + core::List> list60 = block { + final core::List> #t61 = >[]; + if(self::oracle("foo")) + for (final core::List #t62 in >[[]]) + #t61.{core::List::add}(#t62); + } =>#t61; + core::Set> set60 = block { + final core::Set> #t63 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + for (final core::List #t64 in >[[]]) + #t63.{core::Set::add}(#t64); + #t63.{core::Set::add}(null); + } =>#t63; + core::List> list61 = block { + final core::List> #t65 = >[]; + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t66 in >[[]]) + #t65.{core::List::add}(#t66); + } =>#t65; + core::Set> set61 = block { + final core::Set> #t67 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t68 in >[[]]) + #t67.{core::Set::add}(#t68); + #t67.{core::Set::add}(null); + } =>#t67; + core::List> list70 = block { + final core::List> #t69 = >[]; + if(self::oracle("foo")) + #t69.{core::List::add}([]); + } =>#t69; + core::Set> set70 = block { + final core::Set> #t70 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + #t70.{core::Set::add}([]); + #t70.{core::Set::add}(null); + } =>#t70; + core::List> list71 = block { + final core::List> #t71 = >[]; + if(self::oracle("foo")) + if(self::oracle()) + #t71.{core::List::add}([]); + } =>#t71; + core::Set> set71 = block { + final core::Set> #t72 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + if(self::oracle()) + #t72.{core::Set::add}([]); + #t72.{core::Set::add}(null); + } =>#t72; + core::List list80 = block { + final core::List #t73 = []; + if(self::oracle("foo")) + #t73.{core::List::add}(42); + else + #t73.{core::List::add}(3.14); + } =>#t73; + core::Set set80 = block { + final core::Set #t74 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t74.{core::Set::add}(42); + else + #t74.{core::Set::add}(3.14); + #t74.{core::Set::add}(null); + } =>#t74; + core::List list81 = block { + final core::List #t75 = []; + if(self::oracle("foo")) + for (final core::num #t76 in listInt) + #t75.{core::List::add}(#t76); + else + for (final core::num #t77 in listDouble) + #t75.{core::List::add}(#t77); + } =>#t75; + core::Set set81 = block { + final core::Set #t78 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::num #t79 in listInt) + #t78.{core::Set::add}(#t79); + else + for (final core::num #t80 in listDouble) + #t78.{core::Set::add}(#t80); + #t78.{core::Set::add}(null); + } =>#t78; + core::List list82 = block { + final core::List #t81 = []; + if(self::oracle("foo")) + for (final dynamic #t82 in listInt as{TypeError} core::Iterable) + #t81.{core::List::add}(#t82); + else + for (final dynamic #t83 in dynVar as{TypeError} core::Iterable) + #t81.{core::List::add}(#t83); + } =>#t81; + core::Set set82 = block { + final core::Set #t84 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final dynamic #t85 in listInt as{TypeError} core::Iterable) + #t84.{core::Set::add}(#t85); + else + for (final dynamic #t86 in dynVar as{TypeError} core::Iterable) + #t84.{core::Set::add}(#t86); + #t84.{core::Set::add}(null); + } =>#t84; + core::List list83 = block { + final core::List #t87 = []; + if(self::oracle("foo")) + #t87.{core::List::add}(42); + else + for (final core::num #t88 in listDouble) + #t87.{core::List::add}(#t88); + } =>#t87; + core::Set set83 = block { + final core::Set #t89 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::num #t90 in listInt) + #t89.{core::Set::add}(#t90); + else + #t89.{core::Set::add}(3.14); + #t89.{core::Set::add}(null); + } =>#t89; + core::List list90 = block { + final core::List #t91 = []; + if(self::oracle("foo")) + #t91.{core::List::add}(dynVar as{TypeError} core::int); + } =>#t91; + core::Set set90 = block { + final core::Set #t92 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t92.{core::Set::add}(dynVar as{TypeError} core::int); + #t92.{core::Set::add}(null); + } =>#t92; + core::List list91 = block { + final core::List #t93 = []; + if(self::oracle("foo")) + for (final core::int #t94 in dynVar as{TypeError} core::Iterable) + #t93.{core::List::add}(#t94); + } =>#t93; + core::Set set91 = block { + final core::Set #t95 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::int #t96 in dynVar as{TypeError} core::Iterable) + #t95.{core::Set::add}(#t96); + #t95.{core::Set::add}(null); + } =>#t95; +} +static method testIfElementErrors(core::Map map) → dynamic { + [invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:62:28: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +Try changing the type of the left hand side, or casting the right hand side to 'int'. + [if (oracle(\"foo\")) \"bar\"]; + ^"]; + let final core::Set #t97 = col::LinkedHashSet::•() in let final dynamic #t98 = #t97.{core::Set::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:63:28: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +Try changing the type of the left hand side, or casting the right hand side to 'int'. + {if (oracle(\"foo\")) \"bar\", null}; + ^") in let final dynamic #t99 = #t97.{core::Set::add}(null) in #t97; + block { + final core::List #t100 = []; + if(self::oracle("foo")) + for (final core::int #t101 in [let final #t102 = invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:64:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +Try changing the type of the left hand side, or casting the right hand side to 'int'. + [if (oracle(\"foo\")) ...[\"bar\"]]; + ^" in "bar" as{TypeError} core::int]) + #t100.{core::List::add}(#t101); + } =>#t100; + block { + final core::Set #t103 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::int #t104 in [let final #t105 = invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:65:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +Try changing the type of the left hand side, or casting the right hand side to 'int'. + {if (oracle(\"foo\")) ...[\"bar\"], null}; + ^" in "bar" as{TypeError} core::int]) + #t103.{core::Set::add}(#t104); + #t103.{core::Set::add}(null); + } =>#t103; + block { + final core::List #t106 = []; + if(self::oracle("foo")) + #t106.{core::List::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:66:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + [if (oracle(\"foo\")) ...map]; + ^"); + } =>#t106; + block { + final core::Set #t107 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t107.{core::Set::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:67:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + {if (oracle(\"foo\")) ...map, null}; + ^"); + #t107.{core::Set::add}(null); + } =>#t107; + [invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:68:12: Error: A value of type 'num' can't be assigned to a variable of type 'String'. +Try changing the type of the left hand side, or casting the right hand side to 'String'. + [if (oracle(\"foo\")) 42 else 3.14]; + ^"]; + let final core::Set #t108 = col::LinkedHashSet::•() in let final dynamic #t109 = #t108.{core::Set::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:69:12: Error: A value of type 'num' can't be assigned to a variable of type 'String'. +Try changing the type of the left hand side, or casting the right hand side to 'String'. + {if (oracle(\"foo\")) 42 else 3.14, null}; + ^") in let final dynamic #t110 = #t108.{core::Set::add}(null) in #t108; + block { + final core::List #t111 = []; + if(self::oracle("foo")) + #t111.{core::List::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:70:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + [if (oracle(\"foo\")) ...map else 42]; + ^"); + else + #t111.{core::List::add}(42 as{TypeError} core::int); + } =>#t111; + block { + final core::Set #t112 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t112.{core::Set::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:71:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + {if (oracle(\"foo\")) ...map else 42, null}; + ^"); + else + #t112.{core::Set::add}(42 as{TypeError} core::int); + #t112.{core::Set::add}(null); + } =>#t112; + block { + final core::List #t113 = []; + if(self::oracle("foo")) + #t113.{core::List::add}(42 as{TypeError} core::int); + else + #t113.{core::List::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:72:39: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + [if (oracle(\"foo\")) 42 else ...map]; + ^"); + } =>#t113; + block { + final core::Set #t114 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t114.{core::Set::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:73:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + {if (oracle(\"foo\")) ...map else 42, null}; + ^"); + else + #t114.{core::Set::add}(42 as{TypeError} core::int); + #t114.{core::Set::add}(null); + } =>#t114; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/control_flow_collection_inference.dart.strong.transformed.expect b/pkg/front_end/testcases/control_flow_collection_inference.dart.strong.transformed.expect new file mode 100644 index 0000000000000..d41b4737170e8 --- /dev/null +++ b/pkg/front_end/testcases/control_flow_collection_inference.dart.strong.transformed.expect @@ -0,0 +1,514 @@ +library; +// +// Problems in library: +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:62:28: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +// Try changing the type of the left hand side, or casting the right hand side to 'int'. +// [if (oracle("foo")) "bar"]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:63:28: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +// Try changing the type of the left hand side, or casting the right hand side to 'int'. +// {if (oracle("foo")) "bar", null}; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:64:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +// Try changing the type of the left hand side, or casting the right hand side to 'int'. +// [if (oracle("foo")) ...["bar"]]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:65:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +// Try changing the type of the left hand side, or casting the right hand side to 'int'. +// {if (oracle("foo")) ...["bar"], null}; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:66:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// [if (oracle("foo")) ...map]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:67:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// {if (oracle("foo")) ...map, null}; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:68:12: Error: A value of type 'num' can't be assigned to a variable of type 'String'. +// Try changing the type of the left hand side, or casting the right hand side to 'String'. +// [if (oracle("foo")) 42 else 3.14]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:69:12: Error: A value of type 'num' can't be assigned to a variable of type 'String'. +// Try changing the type of the left hand side, or casting the right hand side to 'String'. +// {if (oracle("foo")) 42 else 3.14, null}; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:70:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// [if (oracle("foo")) ...map else 42]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:71:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// {if (oracle("foo")) ...map else 42, null}; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:72:39: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// [if (oracle("foo")) 42 else ...map]; +// ^ +// +// pkg/front_end/testcases/control_flow_collection_inference.dart:73:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. +// - 'Map' is from 'dart:core'. +// {if (oracle("foo")) ...map else 42, null}; +// ^ +// +import self as self; +import "dart:core" as core; +import "dart:collection" as col; + +static method oracle([self::oracle::T t = null]) → dynamic + return true; +static method testIfElement(dynamic dynVar, core::List listInt, core::List listDouble) → dynamic { + core::List list10 = block { + final core::List #t1 = []; + if(self::oracle("foo")) + #t1.{core::List::add}(42); + } =>#t1; + core::Set set10 = block { + final core::Set #t2 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t2.{core::Set::add}(42); + #t2.{core::Set::add}(null); + } =>#t2; + core::List list11 = block { + final core::List #t3 = []; + if(self::oracle("foo")) + #t3.{core::List::add}(dynVar); + } =>#t3; + core::Set set11 = block { + final core::Set #t4 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t4.{core::Set::add}(dynVar); + #t4.{core::Set::add}(null); + } =>#t4; + core::List> list12 = block { + final core::List> #t5 = >[]; + if(self::oracle("foo")) + #t5.{core::List::add}([42]); + } =>#t5; + core::Set> set12 = block { + final core::Set> #t6 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + #t6.{core::Set::add}([42]); + #t6.{core::Set::add}(null); + } =>#t6; + core::List list20 = block { + final core::List #t7 = []; + if(self::oracle("foo")) + for (final core::int #t8 in [42]) + #t7.{core::List::add}(#t8); + } =>#t7; + core::Set set20 = block { + final core::Set #t9 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::int #t10 in [42]) + #t9.{core::Set::add}(#t10); + #t9.{core::Set::add}(null); + } =>#t9; + core::List list21 = block { + final core::List #t11 = []; + if(self::oracle("foo")) + for (final dynamic #t12 in [dynVar]) + #t11.{core::List::add}(#t12); + } =>#t11; + core::Set set21 = block { + final core::Set #t13 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final dynamic #t14 in [dynVar]) + #t13.{core::Set::add}(#t14); + #t13.{core::Set::add}(null); + } =>#t13; + core::List> list22 = block { + final core::List> #t15 = >[]; + if(self::oracle("foo")) + for (final core::List #t16 in >[[42]]) + #t15.{core::List::add}(#t16); + } =>#t15; + core::Set> set22 = block { + final core::Set> #t17 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + for (final core::List #t18 in >[[42]]) + #t17.{core::Set::add}(#t18); + #t17.{core::Set::add}(null); + } =>#t17; + core::List list30 = block { + final core::List #t19 = []; + if(self::oracle("foo")) + if(self::oracle()) + for (final core::int #t20 in [42]) + #t19.{core::List::add}(#t20); + } =>#t19; + core::Set set30 = block { + final core::Set #t21 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + if(self::oracle()) + for (final core::int #t22 in [42]) + #t21.{core::Set::add}(#t22); + #t21.{core::Set::add}(null); + } =>#t21; + core::List list31 = block { + final core::List #t23 = []; + if(self::oracle("foo")) + if(self::oracle()) + for (final dynamic #t24 in [dynVar]) + #t23.{core::List::add}(#t24); + } =>#t23; + core::Set set31 = block { + final core::Set #t25 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + if(self::oracle()) + for (final dynamic #t26 in [dynVar]) + #t25.{core::Set::add}(#t26); + #t25.{core::Set::add}(null); + } =>#t25; + core::List> list33 = block { + final core::List> #t27 = >[]; + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t28 in >[[42]]) + #t27.{core::List::add}(#t28); + } =>#t27; + core::Set> set33 = block { + final core::Set> #t29 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t30 in >[[42]]) + #t29.{core::Set::add}(#t30); + #t29.{core::Set::add}(null); + } =>#t29; + core::List> list40 = block { + final core::List> #t31 = >[]; + if(self::oracle("foo")) + for (final core::List #t32 in >[[]]) + #t31.{core::List::add}(#t32); + } =>#t31; + core::Set> set40 = block { + final core::Set> #t33 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + for (final core::List #t34 in >[[]]) + #t33.{core::Set::add}(#t34); + #t33.{core::Set::add}(null); + } =>#t33; + core::List> list41 = block { + final core::List> #t35 = >[]; + if(self::oracle("foo")) + for (final core::List #t36 in let final core::Set> #t37 = col::LinkedHashSet::•>() in let final core::bool #t38 = #t37.{core::Set::add}([]) in #t37) + #t35.{core::List::add}(#t36); + } =>#t35; + core::Set> set41 = block { + final core::Set> #t39 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + for (final core::List #t40 in let final core::Set> #t41 = col::LinkedHashSet::•>() in let final core::bool #t42 = #t41.{core::Set::add}([]) in #t41) + #t39.{core::Set::add}(#t40); + #t39.{core::Set::add}(null); + } =>#t39; + core::List> list42 = block { + final core::List> #t43 = >[]; + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t44 in >[[]]) + #t43.{core::List::add}(#t44); + } =>#t43; + core::Set> set42 = block { + final core::Set> #t45 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t46 in >[[]]) + #t45.{core::Set::add}(#t46); + #t45.{core::Set::add}(null); + } =>#t45; + core::List list50 = block { + final core::List #t47 = []; + if(self::oracle("foo")) + for (final core::int #t48 in []) + #t47.{core::List::add}(#t48); + } =>#t47; + core::Set set50 = block { + final core::Set #t49 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::int #t50 in []) + #t49.{core::Set::add}(#t50); + #t49.{core::Set::add}(null); + } =>#t49; + core::List list51 = block { + final core::List #t51 = []; + if(self::oracle("foo")) + for (final core::int #t52 in let final core::Set #t53 = col::LinkedHashSet::•() in #t53) + #t51.{core::List::add}(#t52); + } =>#t51; + core::Set set51 = block { + final core::Set #t54 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::int #t55 in let final core::Set #t56 = col::LinkedHashSet::•() in #t56) + #t54.{core::Set::add}(#t55); + #t54.{core::Set::add}(null); + } =>#t54; + core::List list52 = block { + final core::List #t57 = []; + if(self::oracle("foo")) + if(self::oracle()) + for (final core::int #t58 in []) + #t57.{core::List::add}(#t58); + } =>#t57; + core::Set set52 = block { + final core::Set #t59 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + if(self::oracle()) + for (final core::int #t60 in []) + #t59.{core::Set::add}(#t60); + #t59.{core::Set::add}(null); + } =>#t59; + core::List> list60 = block { + final core::List> #t61 = >[]; + if(self::oracle("foo")) + for (final core::List #t62 in >[[]]) + #t61.{core::List::add}(#t62); + } =>#t61; + core::Set> set60 = block { + final core::Set> #t63 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + for (final core::List #t64 in >[[]]) + #t63.{core::Set::add}(#t64); + #t63.{core::Set::add}(null); + } =>#t63; + core::List> list61 = block { + final core::List> #t65 = >[]; + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t66 in >[[]]) + #t65.{core::List::add}(#t66); + } =>#t65; + core::Set> set61 = block { + final core::Set> #t67 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + if(self::oracle()) + for (final core::List #t68 in >[[]]) + #t67.{core::Set::add}(#t68); + #t67.{core::Set::add}(null); + } =>#t67; + core::List> list70 = block { + final core::List> #t69 = >[]; + if(self::oracle("foo")) + #t69.{core::List::add}([]); + } =>#t69; + core::Set> set70 = block { + final core::Set> #t70 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + #t70.{core::Set::add}([]); + #t70.{core::Set::add}(null); + } =>#t70; + core::List> list71 = block { + final core::List> #t71 = >[]; + if(self::oracle("foo")) + if(self::oracle()) + #t71.{core::List::add}([]); + } =>#t71; + core::Set> set71 = block { + final core::Set> #t72 = col::LinkedHashSet::•>(); + if(self::oracle("foo")) + if(self::oracle()) + #t72.{core::Set::add}([]); + #t72.{core::Set::add}(null); + } =>#t72; + core::List list80 = block { + final core::List #t73 = []; + if(self::oracle("foo")) + #t73.{core::List::add}(42); + else + #t73.{core::List::add}(3.14); + } =>#t73; + core::Set set80 = block { + final core::Set #t74 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t74.{core::Set::add}(42); + else + #t74.{core::Set::add}(3.14); + #t74.{core::Set::add}(null); + } =>#t74; + core::List list81 = block { + final core::List #t75 = []; + if(self::oracle("foo")) + for (final core::num #t76 in listInt) + #t75.{core::List::add}(#t76); + else + for (final core::num #t77 in listDouble) + #t75.{core::List::add}(#t77); + } =>#t75; + core::Set set81 = block { + final core::Set #t78 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::num #t79 in listInt) + #t78.{core::Set::add}(#t79); + else + for (final core::num #t80 in listDouble) + #t78.{core::Set::add}(#t80); + #t78.{core::Set::add}(null); + } =>#t78; + core::List list82 = block { + final core::List #t81 = []; + if(self::oracle("foo")) + for (final dynamic #t82 in listInt as{TypeError} core::Iterable) + #t81.{core::List::add}(#t82); + else + for (final dynamic #t83 in dynVar as{TypeError} core::Iterable) + #t81.{core::List::add}(#t83); + } =>#t81; + core::Set set82 = block { + final core::Set #t84 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final dynamic #t85 in listInt as{TypeError} core::Iterable) + #t84.{core::Set::add}(#t85); + else + for (final dynamic #t86 in dynVar as{TypeError} core::Iterable) + #t84.{core::Set::add}(#t86); + #t84.{core::Set::add}(null); + } =>#t84; + core::List list83 = block { + final core::List #t87 = []; + if(self::oracle("foo")) + #t87.{core::List::add}(42); + else + for (final core::num #t88 in listDouble) + #t87.{core::List::add}(#t88); + } =>#t87; + core::Set set83 = block { + final core::Set #t89 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::num #t90 in listInt) + #t89.{core::Set::add}(#t90); + else + #t89.{core::Set::add}(3.14); + #t89.{core::Set::add}(null); + } =>#t89; + core::List list90 = block { + final core::List #t91 = []; + if(self::oracle("foo")) + #t91.{core::List::add}(dynVar as{TypeError} core::int); + } =>#t91; + core::Set set90 = block { + final core::Set #t92 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t92.{core::Set::add}(dynVar as{TypeError} core::int); + #t92.{core::Set::add}(null); + } =>#t92; + core::List list91 = block { + final core::List #t93 = []; + if(self::oracle("foo")) + for (final core::int #t94 in dynVar as{TypeError} core::Iterable) + #t93.{core::List::add}(#t94); + } =>#t93; + core::Set set91 = block { + final core::Set #t95 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::int #t96 in dynVar as{TypeError} core::Iterable) + #t95.{core::Set::add}(#t96); + #t95.{core::Set::add}(null); + } =>#t95; +} +static method testIfElementErrors(core::Map map) → dynamic { + [invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:62:28: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +Try changing the type of the left hand side, or casting the right hand side to 'int'. + [if (oracle(\"foo\")) \"bar\"]; + ^"]; + let final core::Set #t97 = col::LinkedHashSet::•() in let final core::bool #t98 = #t97.{core::Set::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:63:28: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +Try changing the type of the left hand side, or casting the right hand side to 'int'. + {if (oracle(\"foo\")) \"bar\", null}; + ^") in let final core::bool #t99 = #t97.{core::Set::add}(null) in #t97; + block { + final core::List #t100 = []; + if(self::oracle("foo")) + for (final core::int #t101 in [let final #t102 = invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:64:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +Try changing the type of the left hand side, or casting the right hand side to 'int'. + [if (oracle(\"foo\")) ...[\"bar\"]]; + ^" in "bar" as{TypeError} core::int]) + #t100.{core::List::add}(#t101); + } =>#t100; + block { + final core::Set #t103 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + for (final core::int #t104 in [let final #t105 = invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:65:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'. +Try changing the type of the left hand side, or casting the right hand side to 'int'. + {if (oracle(\"foo\")) ...[\"bar\"], null}; + ^" in "bar" as{TypeError} core::int]) + #t103.{core::Set::add}(#t104); + #t103.{core::Set::add}(null); + } =>#t103; + block { + final core::List #t106 = []; + if(self::oracle("foo")) + #t106.{core::List::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:66:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + [if (oracle(\"foo\")) ...map]; + ^"); + } =>#t106; + block { + final core::Set #t107 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t107.{core::Set::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:67:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + {if (oracle(\"foo\")) ...map, null}; + ^"); + #t107.{core::Set::add}(null); + } =>#t107; + [invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:68:12: Error: A value of type 'num' can't be assigned to a variable of type 'String'. +Try changing the type of the left hand side, or casting the right hand side to 'String'. + [if (oracle(\"foo\")) 42 else 3.14]; + ^"]; + let final core::Set #t108 = col::LinkedHashSet::•() in let final core::bool #t109 = #t108.{core::Set::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:69:12: Error: A value of type 'num' can't be assigned to a variable of type 'String'. +Try changing the type of the left hand side, or casting the right hand side to 'String'. + {if (oracle(\"foo\")) 42 else 3.14, null}; + ^") in let final core::bool #t110 = #t108.{core::Set::add}(null) in #t108; + block { + final core::List #t111 = []; + if(self::oracle("foo")) + #t111.{core::List::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:70:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + [if (oracle(\"foo\")) ...map else 42]; + ^"); + else + #t111.{core::List::add}(42 as{TypeError} core::int); + } =>#t111; + block { + final core::Set #t112 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t112.{core::Set::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:71:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + {if (oracle(\"foo\")) ...map else 42, null}; + ^"); + else + #t112.{core::Set::add}(42 as{TypeError} core::int); + #t112.{core::Set::add}(null); + } =>#t112; + block { + final core::List #t113 = []; + if(self::oracle("foo")) + #t113.{core::List::add}(42 as{TypeError} core::int); + else + #t113.{core::List::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:72:39: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + [if (oracle(\"foo\")) 42 else ...map]; + ^"); + } =>#t113; + block { + final core::Set #t114 = col::LinkedHashSet::•(); + if(self::oracle("foo")) + #t114.{core::Set::add}(invalid-expression "pkg/front_end/testcases/control_flow_collection_inference.dart:73:31: Error: Unexpected type 'Map' of a spread. Expected 'dynamic' or an Iterable. + - 'Map' is from 'dart:core'. + {if (oracle(\"foo\")) ...map else 42, null}; + ^"); + else + #t114.{core::Set::add}(42 as{TypeError} core::int); + #t114.{core::Set::add}(null); + } =>#t114; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status index 39e7a5b0e319d..99d0a1fcbdc57 100644 --- a/pkg/front_end/testcases/text_serialization.status +++ b/pkg/front_end/testcases/text_serialization.status @@ -68,6 +68,7 @@ constructor_initializer_invalid: TextSerializationFailure # Was: RuntimeError # continue_inference_after_error: TextSerializationFailure # Was: Pass continue_inference_after_error_lib: TextSerializationFailure # Was: Pass control_flow_collection: TextSerializationFailure +control_flow_collection_inference: TextSerializationFailure covariant_generic: TextSerializationFailure # Was: RuntimeError cycles: TextSerializationFailure # Was: Pass default_values: TextSerializationFailure # Was: Pass diff --git a/tests/co19_2/co19_2-kernel.status b/tests/co19_2/co19_2-kernel.status index 260821a0d1fde..f5af9d6788700 100644 --- a/tests/co19_2/co19_2-kernel.status +++ b/tests/co19_2/co19_2-kernel.status @@ -134,9 +134,6 @@ LanguageFeatures/Control-flow-collections/const_collections_A07_t01: CompileTime LanguageFeatures/Control-flow-collections/const_collections_A07_t02: CompileTimeError LanguageFeatures/Control-flow-collections/dynamic_semantics_map_A03_t01: CompileTimeError LanguageFeatures/Control-flow-collections/dynamic_semantics_set_A03_t01: CompileTimeError -LanguageFeatures/Control-flow-collections/static_errors_A01_t01/01: MissingCompileTimeError -LanguageFeatures/Control-flow-collections/static_errors_A01_t01/02: MissingCompileTimeError -LanguageFeatures/Control-flow-collections/static_errors_A01_t01/03: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_errors_A01_t01/04: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_errors_A01_t01/05: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_errors_A02_t01/01: MissingCompileTimeError @@ -154,18 +151,10 @@ LanguageFeatures/Control-flow-collections/static_errors_A04_t01/02: MissingCompi LanguageFeatures/Control-flow-collections/static_errors_A04_t01/03: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_errors_A04_t01/04: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_errors_A11_t01: MissingCompileTimeError -LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/01: MissingCompileTimeError -LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/02: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/03: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/04: MissingCompileTimeError -LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/05: MissingCompileTimeError -LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/06: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/07: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/08: MissingCompileTimeError -LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/09: MissingCompileTimeError -LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/10: MissingCompileTimeError -LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/11: MissingCompileTimeError -LanguageFeatures/Control-flow-collections/static_semantics_A01_t02/12: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_semantics_A02_t02/05: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_semantics_A02_t02/06: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_semantics_A02_t02/07: MissingCompileTimeError @@ -183,7 +172,6 @@ LanguageFeatures/Control-flow-collections/static_semantics_A02_t02/22: MissingCo LanguageFeatures/Control-flow-collections/static_semantics_A02_t02/23: MissingCompileTimeError LanguageFeatures/Control-flow-collections/static_semantics_A02_t02/24: MissingCompileTimeError LanguageFeatures/Control-flow-collections/syntax_A02_t01: CompileTimeError -LanguageFeatures/Control-flow-collections/syntax_A03_t01/02: MissingCompileTimeError LanguageFeatures/Control-flow-collections/syntax_A03_t01/03: MissingCompileTimeError LanguageFeatures/Control-flow-collections/type_inference_A06_t01: CompileTimeError LanguageFeatures/Control-flow-collections/type_promotion_A01_t01: CompileTimeError diff --git a/tests/language_2/language_2_kernel.status b/tests/language_2/language_2_kernel.status index fd81b5e7ee814..c885ed910a293 100644 --- a/tests/language_2/language_2_kernel.status +++ b/tests/language_2/language_2_kernel.status @@ -240,10 +240,8 @@ control_flow_collections/syntax_test: CompileTimeError control_flow_collections/type_error_test/00: MissingCompileTimeError control_flow_collections/type_error_test/01: MissingCompileTimeError control_flow_collections/type_error_test/02: MissingCompileTimeError -control_flow_collections/type_error_test/06: MissingCompileTimeError control_flow_collections/type_error_test/07: MissingCompileTimeError control_flow_collections/type_error_test/08: MissingCompileTimeError -control_flow_collections/type_error_test/09: MissingCompileTimeError control_flow_collections/type_error_test/10: MissingCompileTimeError control_flow_collections/type_error_test/11: MissingCompileTimeError control_flow_collections/type_error_test/12: MissingCompileTimeError @@ -641,8 +639,6 @@ spread_collections/type_error_test/00: DartkCrash spread_collections/type_error_test/02: DartkCrash spread_collections/type_error_test/03: DartkCrash spread_collections/type_error_test/05: DartkCrash -spread_collections/type_error_test/06: DartkCrash -spread_collections/type_error_test/09: DartkCrash vm/bool_check_stack_traces_test/02: Pass vm/causal_async_exception_stack2_test: RuntimeError # Please triage vm/causal_async_exception_stack_test: RuntimeError # Please triage