diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart index 276b71e091b..c3af5339c9f 100644 --- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart +++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart @@ -6379,14 +6379,6 @@ const MessageCode messageNonInstanceTypeVariableUse = const MessageCode( analyzerCodes: ["TYPE_PARAMETER_REFERENCED_BY_STATIC"], message: r"""Can only use type variables in instance methods."""); -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const Code codeNonNullAwareSpreadIsNull = messageNonNullAwareSpreadIsNull; - -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const MessageCode messageNonNullAwareSpreadIsNull = const MessageCode( - "NonNullAwareSpreadIsNull", - message: r"""Can't spread a value with static type Null."""); - // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const Template templateNonNullableLateDefinitelyAssignedError = diff --git a/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart b/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart index 7bb345392ce..6927bdd7183 100644 --- a/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart +++ b/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart @@ -2196,6 +2196,33 @@ Message _withArgumentsMixinInferenceNoMatchingClass( arguments: {'name': name, 'name2': name2, 'type': _type}); } +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Template + templateNonNullAwareSpreadIsNull = const Template< + Message Function(DartType _type, bool isNonNullableByDefault)>( + messageTemplate: r"""Can't spread a value with static type '#type'.""", + withArguments: _withArgumentsNonNullAwareSpreadIsNull); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code + codeNonNullAwareSpreadIsNull = + const Code( + "NonNullAwareSpreadIsNull", + templateNonNullAwareSpreadIsNull, +); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +Message _withArgumentsNonNullAwareSpreadIsNull( + DartType _type, bool isNonNullableByDefault) { + TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault); + List typeParts = labeler.labelType(_type); + String type = typeParts.join(); + return new Message(codeNonNullAwareSpreadIsNull, + message: """Can't spread a value with static type '${type}'.""" + + labeler.originMessages, + arguments: {'type': _type}); +} + // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const Template< Message Function( 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 d9bdf4b4978..8ed64425338 100644 --- a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart +++ b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart @@ -1328,21 +1328,27 @@ class InferenceVisitor } DartType getSpreadElementType(DartType spreadType, bool isNullAware) { - if (spreadType is InterfaceType) { - if (spreadType.classNode == inferrer.coreTypes.nullClass) { - if (inferrer.isNonNullableByDefault) { - return isNullAware ? const NeverType(Nullability.nonNullable) : null; - } else { - return isNullAware ? spreadType : null; - } + DartType typeBound = inferrer.resolveTypeParameter(spreadType); + if (inferrer.coreTypes.isNull(typeBound)) { + if (inferrer.isNonNullableByDefault) { + return isNullAware ? const NeverType(Nullability.nonNullable) : null; + } else { + return isNullAware ? inferrer.coreTypes.nullType : null; } + } + if (typeBound is InterfaceType) { List supertypeArguments = inferrer.typeSchemaEnvironment .getTypeArgumentsAsInstanceOf( - spreadType, inferrer.coreTypes.iterableClass); - if (supertypeArguments == null) return null; + typeBound, inferrer.coreTypes.iterableClass); + if (supertypeArguments == null) { + return null; + } return supertypeArguments.single; + } else if (spreadType is DynamicType) { + return const DynamicType(); + } else if (inferrer.coreTypes.isBottom(spreadType)) { + return const NeverType(Nullability.nonNullable); } - if (spreadType is DynamicType) return const DynamicType(); return null; } @@ -1374,11 +1380,12 @@ class InferenceVisitor DartType spreadElementType = getSpreadElementType(spreadType, element.isNullAware); if (spreadElementType == null) { - if (spreadType is InterfaceType && - spreadType.classNode == inferrer.coreTypes.nullClass && + if (inferrer.coreTypes + .isNull(inferrer.resolveTypeParameter(spreadType)) && !element.isNullAware) { replacement = inferrer.helper.buildProblem( - messageNonNullAwareSpreadIsNull, + templateNonNullAwareSpreadIsNull.withArguments( + spreadType, inferrer.isNonNullableByDefault), element.expression.fileOffset, 1); } else { @@ -1734,28 +1741,28 @@ class InferenceVisitor // is a function type, the original values in output are preserved. void storeSpreadMapEntryElementTypes(DartType spreadMapEntryType, bool isNullAware, List output, int offset) { - if (spreadMapEntryType is InterfaceType) { - if (spreadMapEntryType.classNode == inferrer.coreTypes.nullClass) { - if (isNullAware) { - if (inferrer.isNonNullableByDefault) { - output[offset] = - output[offset + 1] = const NeverType(Nullability.nonNullable); - } else { - output[offset] = output[offset + 1] = spreadMapEntryType; - } - } - } else { - List supertypeArguments = inferrer.typeSchemaEnvironment - .getTypeArgumentsAsInstanceOf( - spreadMapEntryType, inferrer.coreTypes.mapClass); - if (supertypeArguments != null) { - output[offset] = supertypeArguments[0]; - output[offset + 1] = supertypeArguments[1]; + DartType typeBound = inferrer.resolveTypeParameter(spreadMapEntryType); + if (inferrer.coreTypes.isNull(typeBound)) { + if (isNullAware) { + if (inferrer.isNonNullableByDefault) { + output[offset] = + output[offset + 1] = const NeverType(Nullability.nonNullable); + } else { + output[offset] = output[offset + 1] = inferrer.coreTypes.nullType; } } - } - if (spreadMapEntryType is DynamicType) { + } else if (typeBound is InterfaceType) { + List supertypeArguments = inferrer.typeSchemaEnvironment + .getTypeArgumentsAsInstanceOf(typeBound, inferrer.coreTypes.mapClass); + if (supertypeArguments != null) { + output[offset] = supertypeArguments[0]; + output[offset + 1] = supertypeArguments[1]; + } + } else if (spreadMapEntryType is DynamicType) { output[offset] = output[offset + 1] = const DynamicType(); + } else if (inferrer.coreTypes.isBottom(spreadMapEntryType)) { + output[offset] = + output[offset + 1] = const NeverType(Nullability.nonNullable); } } @@ -1800,12 +1807,15 @@ class InferenceVisitor MapEntry replacement = entry; if (typeChecksNeeded) { if (actualKeyType == null) { - if (spreadType is InterfaceType && - spreadType.classNode == inferrer.coreTypes.nullClass && + if (inferrer.coreTypes + .isNull(inferrer.resolveTypeParameter(spreadType)) && !entry.isNullAware) { replacement = new MapEntry( - inferrer.helper.buildProblem(messageNonNullAwareSpreadIsNull, - entry.expression.fileOffset, 1), + inferrer.helper.buildProblem( + templateNonNullAwareSpreadIsNull.withArguments( + spreadType, inferrer.isNonNullableByDefault), + entry.expression.fileOffset, + 1), new NullLiteral()) ..fileOffset = entry.fileOffset; } else if (actualElementType != null) { diff --git a/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart b/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart index d6682d401b5..e7f565a5c7f 100644 --- a/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart +++ b/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart @@ -154,9 +154,8 @@ class TypeLabeler implements DartTypeVisitor, ConstantVisitor { } void visitNeverType(NeverType node) { - // TODO(askesc): Consider throwing internal error if NeverType appears in - // diagnostics. result.add("Never"); + addNullability(node.declaredNullability); } void visitDynamicType(DynamicType node) { diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml index 3966bbe4f5f..356c1be8b9b 100644 --- a/pkg/front_end/messages.yaml +++ b/pkg/front_end/messages.yaml @@ -3914,7 +3914,7 @@ SpreadMapElement: severity: CONTEXT NonNullAwareSpreadIsNull: - template: "Can't spread a value with static type Null." + template: "Can't spread a value with static type '#type'." script: > main() { [...null]; diff --git a/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.expect b/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.expect index 48f59522a4d..ae46db2e678 100644 --- a/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.expect +++ b/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.expect @@ -76,15 +76,15 @@ library; // Map map61 = {...mapSpread}; // ^ // -// pkg/front_end/testcases/general/spread_collection_inference.dart:131:30: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general/spread_collection_inference.dart:131:30: Error: Can't spread a value with static type 'Null'. // List lhs70 = [...null]; // ^ // -// pkg/front_end/testcases/general/spread_collection_inference.dart:133:29: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general/spread_collection_inference.dart:133:29: Error: Can't spread a value with static type 'Null'. // Set set70 = {...null}; // ^ // -// pkg/front_end/testcases/general/spread_collection_inference.dart:137:8: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general/spread_collection_inference.dart:137:8: Error: Can't spread a value with static type 'Null'. // ...null, // ^ // @@ -92,7 +92,7 @@ library; // ...null, // ^ // -// pkg/front_end/testcases/general/spread_collection_inference.dart:142:45: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general/spread_collection_inference.dart:142:45: Error: Can't spread a value with static type 'Null'. // Map map70 = {...null}; // ^ // @@ -302,10 +302,10 @@ Try providing type arguments for the literal explicitly to disambiguate it. core::Map* map61 = {null: invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:129:51: Error: Can't assign spread entry values of type 'int' to map entry values of type 'String'. Map map61 = {...mapSpread}; ^"}; - core::List* lhs70 = [invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:131:30: Error: Can't spread a value with static type Null. + core::List* lhs70 = [invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:131:30: Error: Can't spread a value with static type 'Null'. List lhs70 = [...null]; ^"]; - core::Set* set70 = let final core::Set* #t66 = col::LinkedHashSet::•() in let final dynamic #t67 = #t66.{core::Set::add}(invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:133:29: Error: Can't spread a value with static type Null. + core::Set* set70 = let final core::Set* #t66 = col::LinkedHashSet::•() in let final dynamic #t67 = #t66.{core::Set::add}(invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:133:29: Error: Can't spread a value with static type 'Null'. Set set70 = {...null}; ^") in #t66; core::Set* set71ambiguous = block { @@ -318,7 +318,7 @@ Try providing type arguments for the literal explicitly to disambiguate it. #t68.{core::Set::add}(#t70); } } =>#t68; - core::Map* map70 = {invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:142:45: Error: Can't spread a value with static type Null. + core::Map* map70 = {invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:142:45: Error: Can't spread a value with static type 'Null'. Map map70 = {...null}; ^": null}; core::List* lhs80 = block { diff --git a/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.transformed.expect b/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.transformed.expect index 91386aeacca..e42c97f8535 100644 --- a/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.transformed.expect @@ -76,15 +76,15 @@ library; // Map map61 = {...mapSpread}; // ^ // -// pkg/front_end/testcases/general/spread_collection_inference.dart:131:30: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general/spread_collection_inference.dart:131:30: Error: Can't spread a value with static type 'Null'. // List lhs70 = [...null]; // ^ // -// pkg/front_end/testcases/general/spread_collection_inference.dart:133:29: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general/spread_collection_inference.dart:133:29: Error: Can't spread a value with static type 'Null'. // Set set70 = {...null}; // ^ // -// pkg/front_end/testcases/general/spread_collection_inference.dart:137:8: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general/spread_collection_inference.dart:137:8: Error: Can't spread a value with static type 'Null'. // ...null, // ^ // @@ -92,7 +92,7 @@ library; // ...null, // ^ // -// pkg/front_end/testcases/general/spread_collection_inference.dart:142:45: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general/spread_collection_inference.dart:142:45: Error: Can't spread a value with static type 'Null'. // Map map70 = {...null}; // ^ // @@ -431,10 +431,10 @@ Try providing type arguments for the literal explicitly to disambiguate it. core::Map* map61 = {null: invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:129:51: Error: Can't assign spread entry values of type 'int' to map entry values of type 'String'. Map map61 = {...mapSpread}; ^"}; - core::List* lhs70 = [invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:131:30: Error: Can't spread a value with static type Null. + core::List* lhs70 = [invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:131:30: Error: Can't spread a value with static type 'Null'. List lhs70 = [...null]; ^"]; - core::Set* set70 = let final core::Set* #t66 = col::LinkedHashSet::•() in let final core::bool #t67 = #t66.{core::Set::add}(invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:133:29: Error: Can't spread a value with static type Null. + core::Set* set70 = let final core::Set* #t66 = col::LinkedHashSet::•() in let final core::bool #t67 = #t66.{core::Set::add}(invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:133:29: Error: Can't spread a value with static type 'Null'. Set set70 = {...null}; ^") in #t66; core::Set* set71ambiguous = block { @@ -453,7 +453,7 @@ Try providing type arguments for the literal explicitly to disambiguate it. } } } =>#t68; - core::Map* map70 = {invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:142:45: Error: Can't spread a value with static type Null. + core::Map* map70 = {invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:142:45: Error: Can't spread a value with static type 'Null'. Map map70 = {...null}; ^": null}; core::List* lhs80 = block { diff --git a/pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart.weak.expect b/pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart.weak.expect index 5ff354628e7..977c606a02a 100644 --- a/pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart.weak.expect +++ b/pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart.weak.expect @@ -76,15 +76,15 @@ library; // Map map61 = {...mapSpread}; // ^ // -// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:133:30: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:133:30: Error: Can't spread a value with static type 'Null'. // List lhs70 = [...null]; // ^ // -// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:135:29: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:135:29: Error: Can't spread a value with static type 'Null'. // Set set70 = {...null}; // ^ // -// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:139:8: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:139:8: Error: Can't spread a value with static type 'Null'. // ...null, // ^ // @@ -92,7 +92,7 @@ library; // ...null, // ^ // -// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:144:45: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:144:45: Error: Can't spread a value with static type 'Null'. // Map map70 = {...null}; // ^ // @@ -302,10 +302,10 @@ Try providing type arguments for the literal explicitly to disambiguate it. core::Map* map61 = {null: invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:131:51: Error: Can't assign spread entry values of type 'int' to map entry values of type 'String'. Map map61 = {...mapSpread}; ^"}; - core::List* lhs70 = [invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:133:30: Error: Can't spread a value with static type Null. + core::List* lhs70 = [invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:133:30: Error: Can't spread a value with static type 'Null'. List lhs70 = [...null]; ^"]; - core::Set* set70 = let final core::Set* #t66 = col::LinkedHashSet::•() in let final dynamic #t67 = #t66.{core::Set::add}(invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:135:29: Error: Can't spread a value with static type Null. + core::Set* set70 = let final core::Set* #t66 = col::LinkedHashSet::•() in let final dynamic #t67 = #t66.{core::Set::add}(invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:135:29: Error: Can't spread a value with static type 'Null'. Set set70 = {...null}; ^") in #t66; core::Set* set71ambiguous = block { @@ -318,7 +318,7 @@ Try providing type arguments for the literal explicitly to disambiguate it. #t68.{core::Set::add}(#t70); } } =>#t68; - core::Map* map70 = {invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:144:45: Error: Can't spread a value with static type Null. + core::Map* map70 = {invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:144:45: Error: Can't spread a value with static type 'Null'. Map map70 = {...null}; ^": null}; core::List* lhs80 = block { diff --git a/pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart.weak.transformed.expect b/pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart.weak.transformed.expect index 69e0bad73e8..6e97878c64c 100644 --- a/pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart.weak.transformed.expect @@ -76,15 +76,15 @@ library; // Map map61 = {...mapSpread}; // ^ // -// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:133:30: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:133:30: Error: Can't spread a value with static type 'Null'. // List lhs70 = [...null]; // ^ // -// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:135:29: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:135:29: Error: Can't spread a value with static type 'Null'. // Set set70 = {...null}; // ^ // -// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:139:8: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:139:8: Error: Can't spread a value with static type 'Null'. // ...null, // ^ // @@ -92,7 +92,7 @@ library; // ...null, // ^ // -// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:144:45: Error: Can't spread a value with static type Null. +// pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:144:45: Error: Can't spread a value with static type 'Null'. // Map map70 = {...null}; // ^ // @@ -431,10 +431,10 @@ Try providing type arguments for the literal explicitly to disambiguate it. core::Map* map61 = {null: invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:131:51: Error: Can't assign spread entry values of type 'int' to map entry values of type 'String'. Map map61 = {...mapSpread}; ^"}; - core::List* lhs70 = [invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:133:30: Error: Can't spread a value with static type Null. + core::List* lhs70 = [invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:133:30: Error: Can't spread a value with static type 'Null'. List lhs70 = [...null]; ^"]; - core::Set* set70 = let final core::Set* #t66 = col::LinkedHashSet::•() in let final core::bool #t67 = #t66.{core::Set::add}(invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:135:29: Error: Can't spread a value with static type Null. + core::Set* set70 = let final core::Set* #t66 = col::LinkedHashSet::•() in let final core::bool #t67 = #t66.{core::Set::add}(invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:135:29: Error: Can't spread a value with static type 'Null'. Set set70 = {...null}; ^") in #t66; core::Set* set71ambiguous = block { @@ -453,7 +453,7 @@ Try providing type arguments for the literal explicitly to disambiguate it. } } } =>#t68; - core::Map* map70 = {invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:144:45: Error: Can't spread a value with static type Null. + core::Map* map70 = {invalid-expression "pkg/front_end/testcases/general_nnbd_opt_out/spread_collection_inference.dart:144:45: Error: Can't spread a value with static type 'Null'. Map map70 = {...null}; ^": null}; core::List* lhs80 = block { diff --git a/pkg/front_end/testcases/nnbd/issue42758.dart b/pkg/front_end/testcases/nnbd/issue42758.dart new file mode 100644 index 00000000000..38474ee5770 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/issue42758.dart @@ -0,0 +1,48 @@ +// Copyright (c) 2020, 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. + +test1(Never n1, Never? n2, Null n3) { + var l1 = [...n1]; + var l2 = [...?n1]; + var l3 = [...n2]; + var l4 = [...?n2]; + var l5 = [...n3]; + var l6 = [...?n3]; + var s1 = {...n1, n1}; + var s2 = {...?n1, n1}; + var s3 = {...n2, n1}; + var s4 = {...?n2, n1}; + var s5 = {...n3, n1}; + var s6 = {...?n3, n1}; + var m1 = {...n1, n1: n1}; + var m2 = {...?n1, n1: n1}; + var m3 = {...n2, n1: n1}; + var m4 = {...?n2, n1: n1}; + var m5 = {...n3, n1: n1}; + var m6 = {...?n3, n1: n1}; +} + +test2( + N1 n1, N2 n2, N3 n3) { + var l1 = [...n1]; + var l2 = [...?n1]; + var l3 = [...n2]; + var l4 = [...?n2]; + var l5 = [...n3]; + var l6 = [...?n3]; + var s1 = {...n1, n1}; + var s2 = {...?n1, n1}; + var s3 = {...n2, n1}; + var s4 = {...?n2, n1}; + var s5 = {...n3, n1}; + var s6 = {...?n3, n1}; + var m1 = {...n1, n1: n1}; + var m2 = {...?n1, n1: n1}; + var m3 = {...n2, n1: n1}; + var m4 = {...?n2, n1: n1}; + var m5 = {...n3, n1: n1}; + var m6 = {...?n3, n1: n1}; +} + +main() {} diff --git a/pkg/front_end/testcases/nnbd/issue42758.dart.outline.expect b/pkg/front_end/testcases/nnbd/issue42758.dart.outline.expect new file mode 100644 index 00000000000..3ada4d69631 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/issue42758.dart.outline.expect @@ -0,0 +1,10 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "dart:core" as core; + +static method test1(Never n1, Never? n2, core::Null? n3) → dynamic + ; +static method test2(self::test2::N1 n1, self::test2::N2% n2, self::test2::N3% n3) → dynamic + ; +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/nnbd/issue42758.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue42758.dart.strong.expect new file mode 100644 index 00000000000..6e4b63d00b6 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/issue42758.dart.strong.expect @@ -0,0 +1,293 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/nnbd/issue42758.dart:7:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var l2 = [...?n1]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:8:16: Error: Can't spread a value with static type 'Never?'. +// var l3 = [...n2]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:10:16: Error: Can't spread a value with static type 'Null'. +// var l5 = [...n3]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:13:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var s2 = {...?n1, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:14:16: Error: Can't spread a value with static type 'Never?'. +// var s3 = {...n2, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:16:16: Error: Can't spread a value with static type 'Null'. +// var s5 = {...n3, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:19:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var m2 = {...?n1, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:20:16: Error: Can't spread a value with static type 'Never?'. +// var m3 = {...n2, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:22:16: Error: Can't spread a value with static type 'Null'. +// var m5 = {...n3, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:29:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var l2 = [...?n1]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:30:16: Error: Can't spread a value with static type 'N2'. +// var l3 = [...n2]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:32:16: Error: Can't spread a value with static type 'N3'. +// var l5 = [...n3]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:35:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var s2 = {...?n1, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:36:16: Error: Can't spread a value with static type 'N2'. +// var s3 = {...n2, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:38:16: Error: Can't spread a value with static type 'N3'. +// var s5 = {...n3, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:41:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var m2 = {...?n1, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:42:16: Error: Can't spread a value with static type 'N2'. +// var m3 = {...n2, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:44:16: Error: Can't spread a value with static type 'N3'. +// var m5 = {...n3, n1: n1}; +// ^ +// +import self as self; +import "dart:core" as core; +import "dart:collection" as col; + +static method test1(Never n1, Never? n2, core::Null? n3) → dynamic { + core::List l1 = block { + final core::List #t1 = []; + for (final Never #t2 in n1) + #t1.{core::List::add}(#t2); + } =>#t1; + core::List l2 = block { + final core::List #t3 = []; + final core::Iterable? #t4 = n1; + if(!#t4.{core::Object::==}(null)) + for (final Never #t5 in #t4{core::Iterable}) + #t3.{core::List::add}(#t5); + } =>#t3; + core::List l3 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:8:16: Error: Can't spread a value with static type 'Never?'. + var l3 = [...n2]; + ^"]; + core::List l4 = block { + final core::List #t6 = []; + final core::Iterable? #t7 = n2; + if(!#t7.{core::Object::==}(null)) + for (final Never #t8 in #t7{core::Iterable}) + #t6.{core::List::add}(#t8); + } =>#t6; + core::List l5 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:10:16: Error: Can't spread a value with static type 'Null'. + var l5 = [...n3]; + ^"]; + core::List l6 = block { + final core::List #t9 = []; + final core::Iterable? #t10 = n3; + if(!#t10.{core::Object::==}(null)) + for (final Never #t11 in #t10{core::Iterable}) + #t9.{core::List::add}(#t11); + } =>#t9; + core::Set s1 = block { + final core::Set #t12 = col::LinkedHashSet::•(); + for (final Never #t13 in n1) + #t12.{core::Set::add}(#t13); + #t12.{core::Set::add}(n1); + } =>#t12; + core::Set s2 = block { + final core::Set #t14 = col::LinkedHashSet::•(); + final core::Iterable? #t15 = n1; + if(!#t15.{core::Object::==}(null)) + for (final Never #t16 in #t15{core::Iterable}) + #t14.{core::Set::add}(#t16); + #t14.{core::Set::add}(n1); + } =>#t14; + core::Set s3 = let final core::Set #t17 = col::LinkedHashSet::•() in let final dynamic #t18 = #t17.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:14:16: Error: Can't spread a value with static type 'Never?'. + var s3 = {...n2, n1}; + ^") in let final dynamic #t19 = #t17.{core::Set::add}(n1) in #t17; + core::Set s4 = block { + final core::Set #t20 = col::LinkedHashSet::•(); + final core::Iterable? #t21 = n2; + if(!#t21.{core::Object::==}(null)) + for (final Never #t22 in #t21{core::Iterable}) + #t20.{core::Set::add}(#t22); + #t20.{core::Set::add}(n1); + } =>#t20; + core::Set s5 = let final core::Set #t23 = col::LinkedHashSet::•() in let final dynamic #t24 = #t23.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:16:16: Error: Can't spread a value with static type 'Null'. + var s5 = {...n3, n1}; + ^") in let final dynamic #t25 = #t23.{core::Set::add}(n1) in #t23; + core::Set s6 = block { + final core::Set #t26 = col::LinkedHashSet::•(); + final core::Iterable? #t27 = n3; + if(!#t27.{core::Object::==}(null)) + for (final Never #t28 in #t27{core::Iterable}) + #t26.{core::Set::add}(#t28); + #t26.{core::Set::add}(n1); + } =>#t26; + core::Map m1 = block { + final core::Map #t29 = {}; + for (final core::MapEntry #t30 in n1.{core::Map::entries}) + #t29.{core::Map::[]=}(#t30.{core::MapEntry::key}, #t30.{core::MapEntry::value}); + #t29.{core::Map::[]=}(n1, n1); + } =>#t29; + core::Map m2 = block { + final core::Map #t31 = {}; + final core::Map? #t32 = n1; + if(!#t32.{core::Object::==}(null)) + for (final core::MapEntry #t33 in #t32{core::Map}.{core::Map::entries}) + #t31.{core::Map::[]=}(#t33.{core::MapEntry::key}, #t33.{core::MapEntry::value}); + #t31.{core::Map::[]=}(n1, n1); + } =>#t31; + core::Map m3 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:20:16: Error: Can't spread a value with static type 'Never?'. + var m3 = {...n2, n1: n1}; + ^": null, n1: n1}; + core::Map m4 = block { + final core::Map #t34 = {}; + final core::Map? #t35 = n2; + if(!#t35.{core::Object::==}(null)) + for (final core::MapEntry #t36 in #t35{core::Map}.{core::Map::entries}) + #t34.{core::Map::[]=}(#t36.{core::MapEntry::key}, #t36.{core::MapEntry::value}); + #t34.{core::Map::[]=}(n1, n1); + } =>#t34; + core::Map m5 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:22:16: Error: Can't spread a value with static type 'Null'. + var m5 = {...n3, n1: n1}; + ^": null, n1: n1}; + core::Map m6 = block { + final core::Map #t37 = {}; + final core::Map? #t38 = n3; + if(!#t38.{core::Object::==}(null)) + for (final core::MapEntry #t39 in #t38{core::Map}.{core::Map::entries}) + #t37.{core::Map::[]=}(#t39.{core::MapEntry::key}, #t39.{core::MapEntry::value}); + #t37.{core::Map::[]=}(n1, n1); + } =>#t37; +} +static method test2(self::test2::N1 n1, self::test2::N2% n2, self::test2::N3% n3) → dynamic { + core::List l1 = block { + final core::List #t40 = []; + for (final Never #t41 in n1) + #t40.{core::List::add}(#t41); + } =>#t40; + core::List l2 = block { + final core::List #t42 = []; + final core::Iterable? #t43 = n1; + if(!#t43.{core::Object::==}(null)) + for (final Never #t44 in #t43{core::Iterable}) + #t42.{core::List::add}(#t44); + } =>#t42; + core::List l3 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:30:16: Error: Can't spread a value with static type 'N2'. + var l3 = [...n2]; + ^"]; + core::List l4 = block { + final core::List #t45 = []; + final core::Iterable? #t46 = n2; + if(!#t46.{core::Object::==}(null)) + for (final Never #t47 in #t46{core::Iterable}) + #t45.{core::List::add}(#t47); + } =>#t45; + core::List l5 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:32:16: Error: Can't spread a value with static type 'N3'. + var l5 = [...n3]; + ^"]; + core::List l6 = block { + final core::List #t48 = []; + final core::Iterable? #t49 = n3; + if(!#t49.{core::Object::==}(null)) + for (final Never #t50 in #t49{core::Iterable}) + #t48.{core::List::add}(#t50); + } =>#t48; + core::Set s1 = block { + final core::Set #t51 = col::LinkedHashSet::•(); + for (final self::test2::N1 #t52 in n1) + #t51.{core::Set::add}(#t52); + #t51.{core::Set::add}(n1); + } =>#t51; + core::Set s2 = block { + final core::Set #t53 = col::LinkedHashSet::•(); + final core::Iterable? #t54 = n1; + if(!#t54.{core::Object::==}(null)) + for (final self::test2::N1 #t55 in #t54{core::Iterable}) + #t53.{core::Set::add}(#t55); + #t53.{core::Set::add}(n1); + } =>#t53; + core::Set s3 = let final core::Set #t56 = col::LinkedHashSet::•() in let final dynamic #t57 = #t56.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:36:16: Error: Can't spread a value with static type 'N2'. + var s3 = {...n2, n1}; + ^") in let final dynamic #t58 = #t56.{core::Set::add}(n1) in #t56; + core::Set s4 = block { + final core::Set #t59 = col::LinkedHashSet::•(); + final core::Iterable? #t60 = n2; + if(!#t60.{core::Object::==}(null)) + for (final self::test2::N1 #t61 in #t60{core::Iterable}) + #t59.{core::Set::add}(#t61); + #t59.{core::Set::add}(n1); + } =>#t59; + core::Set s5 = let final core::Set #t62 = col::LinkedHashSet::•() in let final dynamic #t63 = #t62.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:38:16: Error: Can't spread a value with static type 'N3'. + var s5 = {...n3, n1}; + ^") in let final dynamic #t64 = #t62.{core::Set::add}(n1) in #t62; + core::Set s6 = block { + final core::Set #t65 = col::LinkedHashSet::•(); + final core::Iterable? #t66 = n3; + if(!#t66.{core::Object::==}(null)) + for (final self::test2::N1 #t67 in #t66{core::Iterable}) + #t65.{core::Set::add}(#t67); + #t65.{core::Set::add}(n1); + } =>#t65; + core::Map m1 = block { + final core::Map #t68 = {}; + for (final core::MapEntry #t69 in n1.{core::Map::entries}) + #t68.{core::Map::[]=}(#t69.{core::MapEntry::key}, #t69.{core::MapEntry::value}); + #t68.{core::Map::[]=}(n1, n1); + } =>#t68; + core::Map m2 = block { + final core::Map #t70 = {}; + final core::Map? #t71 = n1; + if(!#t71.{core::Object::==}(null)) + for (final core::MapEntry #t72 in #t71{core::Map}.{core::Map::entries}) + #t70.{core::Map::[]=}(#t72.{core::MapEntry::key}, #t72.{core::MapEntry::value}); + #t70.{core::Map::[]=}(n1, n1); + } =>#t70; + core::Map m3 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:42:16: Error: Can't spread a value with static type 'N2'. + var m3 = {...n2, n1: n1}; + ^": null, n1: n1}; + core::Map m4 = block { + final core::Map #t73 = {}; + final core::Map? #t74 = n2; + if(!#t74.{core::Object::==}(null)) + for (final core::MapEntry #t75 in #t74{core::Map}.{core::Map::entries}) + #t73.{core::Map::[]=}(#t75.{core::MapEntry::key}, #t75.{core::MapEntry::value}); + #t73.{core::Map::[]=}(n1, n1); + } =>#t73; + core::Map m5 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:44:16: Error: Can't spread a value with static type 'N3'. + var m5 = {...n3, n1: n1}; + ^": null, n1: n1}; + core::Map m6 = block { + final core::Map #t76 = {}; + final core::Map? #t77 = n3; + if(!#t77.{core::Object::==}(null)) + for (final core::MapEntry #t78 in #t77{core::Map}.{core::Map::entries}) + #t76.{core::Map::[]=}(#t78.{core::MapEntry::key}, #t78.{core::MapEntry::value}); + #t76.{core::Map::[]=}(n1, n1); + } =>#t76; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/nnbd/issue42758.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/issue42758.dart.strong.transformed.expect new file mode 100644 index 00000000000..f24f3517fc6 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/issue42758.dart.strong.transformed.expect @@ -0,0 +1,375 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/nnbd/issue42758.dart:7:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var l2 = [...?n1]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:8:16: Error: Can't spread a value with static type 'Never?'. +// var l3 = [...n2]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:10:16: Error: Can't spread a value with static type 'Null'. +// var l5 = [...n3]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:13:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var s2 = {...?n1, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:14:16: Error: Can't spread a value with static type 'Never?'. +// var s3 = {...n2, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:16:16: Error: Can't spread a value with static type 'Null'. +// var s5 = {...n3, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:19:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var m2 = {...?n1, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:20:16: Error: Can't spread a value with static type 'Never?'. +// var m3 = {...n2, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:22:16: Error: Can't spread a value with static type 'Null'. +// var m5 = {...n3, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:29:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var l2 = [...?n1]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:30:16: Error: Can't spread a value with static type 'N2'. +// var l3 = [...n2]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:32:16: Error: Can't spread a value with static type 'N3'. +// var l5 = [...n3]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:35:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var s2 = {...?n1, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:36:16: Error: Can't spread a value with static type 'N2'. +// var s3 = {...n2, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:38:16: Error: Can't spread a value with static type 'N3'. +// var s5 = {...n3, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:41:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var m2 = {...?n1, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:42:16: Error: Can't spread a value with static type 'N2'. +// var m3 = {...n2, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:44:16: Error: Can't spread a value with static type 'N3'. +// var m5 = {...n3, n1: n1}; +// ^ +// +import self as self; +import "dart:core" as core; +import "dart:collection" as col; + +static method test1(Never n1, Never? n2, core::Null? n3) → dynamic { + core::List l1 = block { + final core::List #t1 = []; + for (final Never #t2 in n1) + #t1.{core::List::add}(#t2); + } =>#t1; + core::List l2 = block { + final core::List #t3 = []; + final core::Iterable? #t4 = n1; + if(!#t4.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t4{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t5 = :sync-for-iterator.{core::Iterator::current}; + #t3.{core::List::add}(#t5); + } + } + } =>#t3; + core::List l3 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:8:16: Error: Can't spread a value with static type 'Never?'. + var l3 = [...n2]; + ^"]; + core::List l4 = block { + final core::List #t6 = []; + final core::Iterable? #t7 = n2; + if(!#t7.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t7{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t8 = :sync-for-iterator.{core::Iterator::current}; + #t6.{core::List::add}(#t8); + } + } + } =>#t6; + core::List l5 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:10:16: Error: Can't spread a value with static type 'Null'. + var l5 = [...n3]; + ^"]; + core::List l6 = block { + final core::List #t9 = []; + final core::Iterable? #t10 = n3; + if(!#t10.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t10{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t11 = :sync-for-iterator.{core::Iterator::current}; + #t9.{core::List::add}(#t11); + } + } + } =>#t9; + core::Set s1 = block { + final core::Set #t12 = col::LinkedHashSet::•(); + for (final Never #t13 in n1) + #t12.{core::Set::add}(#t13); + #t12.{core::Set::add}(n1); + } =>#t12; + core::Set s2 = block { + final core::Set #t14 = col::LinkedHashSet::•(); + final core::Iterable? #t15 = n1; + if(!#t15.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t15{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t16 = :sync-for-iterator.{core::Iterator::current}; + #t14.{core::Set::add}(#t16); + } + } + #t14.{core::Set::add}(n1); + } =>#t14; + core::Set s3 = let final core::Set #t17 = col::LinkedHashSet::•() in let final core::bool #t18 = #t17.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:14:16: Error: Can't spread a value with static type 'Never?'. + var s3 = {...n2, n1}; + ^") in let final core::bool #t19 = #t17.{core::Set::add}(n1) in #t17; + core::Set s4 = block { + final core::Set #t20 = col::LinkedHashSet::•(); + final core::Iterable? #t21 = n2; + if(!#t21.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t21{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t22 = :sync-for-iterator.{core::Iterator::current}; + #t20.{core::Set::add}(#t22); + } + } + #t20.{core::Set::add}(n1); + } =>#t20; + core::Set s5 = let final core::Set #t23 = col::LinkedHashSet::•() in let final core::bool #t24 = #t23.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:16:16: Error: Can't spread a value with static type 'Null'. + var s5 = {...n3, n1}; + ^") in let final core::bool #t25 = #t23.{core::Set::add}(n1) in #t23; + core::Set s6 = block { + final core::Set #t26 = col::LinkedHashSet::•(); + final core::Iterable? #t27 = n3; + if(!#t27.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t27{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t28 = :sync-for-iterator.{core::Iterator::current}; + #t26.{core::Set::add}(#t28); + } + } + #t26.{core::Set::add}(n1); + } =>#t26; + core::Map m1 = block { + final core::Map #t29 = {}; + { + core::Iterator, >> :sync-for-iterator = n1.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t30 = :sync-for-iterator.{core::Iterator::current}; + #t29.{core::Map::[]=}(#t30.{core::MapEntry::key}, #t30.{core::MapEntry::value}); + } + } + #t29.{core::Map::[]=}(n1, n1); + } =>#t29; + core::Map m2 = block { + final core::Map #t31 = {}; + final core::Map? #t32 = n1; + if(!#t32.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t32{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t33 = :sync-for-iterator.{core::Iterator::current}; + #t31.{core::Map::[]=}(#t33.{core::MapEntry::key}, #t33.{core::MapEntry::value}); + } + } + #t31.{core::Map::[]=}(n1, n1); + } =>#t31; + core::Map m3 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:20:16: Error: Can't spread a value with static type 'Never?'. + var m3 = {...n2, n1: n1}; + ^": null, n1: n1}; + core::Map m4 = block { + final core::Map #t34 = {}; + final core::Map? #t35 = n2; + if(!#t35.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t35{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t36 = :sync-for-iterator.{core::Iterator::current}; + #t34.{core::Map::[]=}(#t36.{core::MapEntry::key}, #t36.{core::MapEntry::value}); + } + } + #t34.{core::Map::[]=}(n1, n1); + } =>#t34; + core::Map m5 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:22:16: Error: Can't spread a value with static type 'Null'. + var m5 = {...n3, n1: n1}; + ^": null, n1: n1}; + core::Map m6 = block { + final core::Map #t37 = {}; + final core::Map? #t38 = n3; + if(!#t38.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t38{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t39 = :sync-for-iterator.{core::Iterator::current}; + #t37.{core::Map::[]=}(#t39.{core::MapEntry::key}, #t39.{core::MapEntry::value}); + } + } + #t37.{core::Map::[]=}(n1, n1); + } =>#t37; +} +static method test2(self::test2::N1 n1, self::test2::N2% n2, self::test2::N3% n3) → dynamic { + core::List l1 = block { + final core::List #t40 = []; + for (final Never #t41 in n1) + #t40.{core::List::add}(#t41); + } =>#t40; + core::List l2 = block { + final core::List #t42 = []; + final core::Iterable? #t43 = n1; + if(!#t43.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t43{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t44 = :sync-for-iterator.{core::Iterator::current}; + #t42.{core::List::add}(#t44); + } + } + } =>#t42; + core::List l3 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:30:16: Error: Can't spread a value with static type 'N2'. + var l3 = [...n2]; + ^"]; + core::List l4 = block { + final core::List #t45 = []; + final core::Iterable? #t46 = n2; + if(!#t46.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t46{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t47 = :sync-for-iterator.{core::Iterator::current}; + #t45.{core::List::add}(#t47); + } + } + } =>#t45; + core::List l5 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:32:16: Error: Can't spread a value with static type 'N3'. + var l5 = [...n3]; + ^"]; + core::List l6 = block { + final core::List #t48 = []; + final core::Iterable? #t49 = n3; + if(!#t49.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t49{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t50 = :sync-for-iterator.{core::Iterator::current}; + #t48.{core::List::add}(#t50); + } + } + } =>#t48; + core::Set s1 = block { + final core::Set #t51 = col::LinkedHashSet::•(); + for (final self::test2::N1 #t52 in n1) + #t51.{core::Set::add}(#t52); + #t51.{core::Set::add}(n1); + } =>#t51; + core::Set s2 = block { + final core::Set #t53 = col::LinkedHashSet::•(); + final core::Iterable? #t54 = n1; + if(!#t54.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t54{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final self::test2::N1 #t55 = :sync-for-iterator.{core::Iterator::current}; + #t53.{core::Set::add}(#t55); + } + } + #t53.{core::Set::add}(n1); + } =>#t53; + core::Set s3 = let final core::Set #t56 = col::LinkedHashSet::•() in let final core::bool #t57 = #t56.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:36:16: Error: Can't spread a value with static type 'N2'. + var s3 = {...n2, n1}; + ^") in let final core::bool #t58 = #t56.{core::Set::add}(n1) in #t56; + core::Set s4 = block { + final core::Set #t59 = col::LinkedHashSet::•(); + final core::Iterable? #t60 = n2; + if(!#t60.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t60{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final self::test2::N1 #t61 = :sync-for-iterator.{core::Iterator::current}; + #t59.{core::Set::add}(#t61); + } + } + #t59.{core::Set::add}(n1); + } =>#t59; + core::Set s5 = let final core::Set #t62 = col::LinkedHashSet::•() in let final core::bool #t63 = #t62.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:38:16: Error: Can't spread a value with static type 'N3'. + var s5 = {...n3, n1}; + ^") in let final core::bool #t64 = #t62.{core::Set::add}(n1) in #t62; + core::Set s6 = block { + final core::Set #t65 = col::LinkedHashSet::•(); + final core::Iterable? #t66 = n3; + if(!#t66.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t66{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final self::test2::N1 #t67 = :sync-for-iterator.{core::Iterator::current}; + #t65.{core::Set::add}(#t67); + } + } + #t65.{core::Set::add}(n1); + } =>#t65; + core::Map m1 = block { + final core::Map #t68 = {}; + { + core::Iterator, >> :sync-for-iterator = n1.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t69 = :sync-for-iterator.{core::Iterator::current}; + #t68.{core::Map::[]=}(#t69.{core::MapEntry::key}, #t69.{core::MapEntry::value}); + } + } + #t68.{core::Map::[]=}(n1, n1); + } =>#t68; + core::Map m2 = block { + final core::Map #t70 = {}; + final core::Map? #t71 = n1; + if(!#t71.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t71{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t72 = :sync-for-iterator.{core::Iterator::current}; + #t70.{core::Map::[]=}(#t72.{core::MapEntry::key}, #t72.{core::MapEntry::value}); + } + } + #t70.{core::Map::[]=}(n1, n1); + } =>#t70; + core::Map m3 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:42:16: Error: Can't spread a value with static type 'N2'. + var m3 = {...n2, n1: n1}; + ^": null, n1: n1}; + core::Map m4 = block { + final core::Map #t73 = {}; + final core::Map? #t74 = n2; + if(!#t74.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t74{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t75 = :sync-for-iterator.{core::Iterator::current}; + #t73.{core::Map::[]=}(#t75.{core::MapEntry::key}, #t75.{core::MapEntry::value}); + } + } + #t73.{core::Map::[]=}(n1, n1); + } =>#t73; + core::Map m5 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:44:16: Error: Can't spread a value with static type 'N3'. + var m5 = {...n3, n1: n1}; + ^": null, n1: n1}; + core::Map m6 = block { + final core::Map #t76 = {}; + final core::Map? #t77 = n3; + if(!#t77.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t77{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t78 = :sync-for-iterator.{core::Iterator::current}; + #t76.{core::Map::[]=}(#t78.{core::MapEntry::key}, #t78.{core::MapEntry::value}); + } + } + #t76.{core::Map::[]=}(n1, n1); + } =>#t76; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/nnbd/issue42758.dart.textual_outline.expect b/pkg/front_end/testcases/nnbd/issue42758.dart.textual_outline.expect new file mode 100644 index 00000000000..09008cc5ff0 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/issue42758.dart.textual_outline.expect @@ -0,0 +1,4 @@ +test1(Never n1, Never? n2, Null n3) {} +test2( + N1 n1, N2 n2, N3 n3) {} +main() {} diff --git a/pkg/front_end/testcases/nnbd/issue42758.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/nnbd/issue42758.dart.textual_outline_modelled.expect new file mode 100644 index 00000000000..7dc1872078a --- /dev/null +++ b/pkg/front_end/testcases/nnbd/issue42758.dart.textual_outline_modelled.expect @@ -0,0 +1,4 @@ +main() {} +test1(Never n1, Never? n2, Null n3) {} +test2( + N1 n1, N2 n2, N3 n3) {} diff --git a/pkg/front_end/testcases/nnbd/issue42758.dart.weak.expect b/pkg/front_end/testcases/nnbd/issue42758.dart.weak.expect new file mode 100644 index 00000000000..6e4b63d00b6 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/issue42758.dart.weak.expect @@ -0,0 +1,293 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/nnbd/issue42758.dart:7:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var l2 = [...?n1]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:8:16: Error: Can't spread a value with static type 'Never?'. +// var l3 = [...n2]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:10:16: Error: Can't spread a value with static type 'Null'. +// var l5 = [...n3]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:13:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var s2 = {...?n1, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:14:16: Error: Can't spread a value with static type 'Never?'. +// var s3 = {...n2, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:16:16: Error: Can't spread a value with static type 'Null'. +// var s5 = {...n3, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:19:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var m2 = {...?n1, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:20:16: Error: Can't spread a value with static type 'Never?'. +// var m3 = {...n2, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:22:16: Error: Can't spread a value with static type 'Null'. +// var m5 = {...n3, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:29:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var l2 = [...?n1]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:30:16: Error: Can't spread a value with static type 'N2'. +// var l3 = [...n2]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:32:16: Error: Can't spread a value with static type 'N3'. +// var l5 = [...n3]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:35:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var s2 = {...?n1, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:36:16: Error: Can't spread a value with static type 'N2'. +// var s3 = {...n2, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:38:16: Error: Can't spread a value with static type 'N3'. +// var s5 = {...n3, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:41:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var m2 = {...?n1, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:42:16: Error: Can't spread a value with static type 'N2'. +// var m3 = {...n2, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:44:16: Error: Can't spread a value with static type 'N3'. +// var m5 = {...n3, n1: n1}; +// ^ +// +import self as self; +import "dart:core" as core; +import "dart:collection" as col; + +static method test1(Never n1, Never? n2, core::Null? n3) → dynamic { + core::List l1 = block { + final core::List #t1 = []; + for (final Never #t2 in n1) + #t1.{core::List::add}(#t2); + } =>#t1; + core::List l2 = block { + final core::List #t3 = []; + final core::Iterable? #t4 = n1; + if(!#t4.{core::Object::==}(null)) + for (final Never #t5 in #t4{core::Iterable}) + #t3.{core::List::add}(#t5); + } =>#t3; + core::List l3 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:8:16: Error: Can't spread a value with static type 'Never?'. + var l3 = [...n2]; + ^"]; + core::List l4 = block { + final core::List #t6 = []; + final core::Iterable? #t7 = n2; + if(!#t7.{core::Object::==}(null)) + for (final Never #t8 in #t7{core::Iterable}) + #t6.{core::List::add}(#t8); + } =>#t6; + core::List l5 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:10:16: Error: Can't spread a value with static type 'Null'. + var l5 = [...n3]; + ^"]; + core::List l6 = block { + final core::List #t9 = []; + final core::Iterable? #t10 = n3; + if(!#t10.{core::Object::==}(null)) + for (final Never #t11 in #t10{core::Iterable}) + #t9.{core::List::add}(#t11); + } =>#t9; + core::Set s1 = block { + final core::Set #t12 = col::LinkedHashSet::•(); + for (final Never #t13 in n1) + #t12.{core::Set::add}(#t13); + #t12.{core::Set::add}(n1); + } =>#t12; + core::Set s2 = block { + final core::Set #t14 = col::LinkedHashSet::•(); + final core::Iterable? #t15 = n1; + if(!#t15.{core::Object::==}(null)) + for (final Never #t16 in #t15{core::Iterable}) + #t14.{core::Set::add}(#t16); + #t14.{core::Set::add}(n1); + } =>#t14; + core::Set s3 = let final core::Set #t17 = col::LinkedHashSet::•() in let final dynamic #t18 = #t17.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:14:16: Error: Can't spread a value with static type 'Never?'. + var s3 = {...n2, n1}; + ^") in let final dynamic #t19 = #t17.{core::Set::add}(n1) in #t17; + core::Set s4 = block { + final core::Set #t20 = col::LinkedHashSet::•(); + final core::Iterable? #t21 = n2; + if(!#t21.{core::Object::==}(null)) + for (final Never #t22 in #t21{core::Iterable}) + #t20.{core::Set::add}(#t22); + #t20.{core::Set::add}(n1); + } =>#t20; + core::Set s5 = let final core::Set #t23 = col::LinkedHashSet::•() in let final dynamic #t24 = #t23.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:16:16: Error: Can't spread a value with static type 'Null'. + var s5 = {...n3, n1}; + ^") in let final dynamic #t25 = #t23.{core::Set::add}(n1) in #t23; + core::Set s6 = block { + final core::Set #t26 = col::LinkedHashSet::•(); + final core::Iterable? #t27 = n3; + if(!#t27.{core::Object::==}(null)) + for (final Never #t28 in #t27{core::Iterable}) + #t26.{core::Set::add}(#t28); + #t26.{core::Set::add}(n1); + } =>#t26; + core::Map m1 = block { + final core::Map #t29 = {}; + for (final core::MapEntry #t30 in n1.{core::Map::entries}) + #t29.{core::Map::[]=}(#t30.{core::MapEntry::key}, #t30.{core::MapEntry::value}); + #t29.{core::Map::[]=}(n1, n1); + } =>#t29; + core::Map m2 = block { + final core::Map #t31 = {}; + final core::Map? #t32 = n1; + if(!#t32.{core::Object::==}(null)) + for (final core::MapEntry #t33 in #t32{core::Map}.{core::Map::entries}) + #t31.{core::Map::[]=}(#t33.{core::MapEntry::key}, #t33.{core::MapEntry::value}); + #t31.{core::Map::[]=}(n1, n1); + } =>#t31; + core::Map m3 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:20:16: Error: Can't spread a value with static type 'Never?'. + var m3 = {...n2, n1: n1}; + ^": null, n1: n1}; + core::Map m4 = block { + final core::Map #t34 = {}; + final core::Map? #t35 = n2; + if(!#t35.{core::Object::==}(null)) + for (final core::MapEntry #t36 in #t35{core::Map}.{core::Map::entries}) + #t34.{core::Map::[]=}(#t36.{core::MapEntry::key}, #t36.{core::MapEntry::value}); + #t34.{core::Map::[]=}(n1, n1); + } =>#t34; + core::Map m5 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:22:16: Error: Can't spread a value with static type 'Null'. + var m5 = {...n3, n1: n1}; + ^": null, n1: n1}; + core::Map m6 = block { + final core::Map #t37 = {}; + final core::Map? #t38 = n3; + if(!#t38.{core::Object::==}(null)) + for (final core::MapEntry #t39 in #t38{core::Map}.{core::Map::entries}) + #t37.{core::Map::[]=}(#t39.{core::MapEntry::key}, #t39.{core::MapEntry::value}); + #t37.{core::Map::[]=}(n1, n1); + } =>#t37; +} +static method test2(self::test2::N1 n1, self::test2::N2% n2, self::test2::N3% n3) → dynamic { + core::List l1 = block { + final core::List #t40 = []; + for (final Never #t41 in n1) + #t40.{core::List::add}(#t41); + } =>#t40; + core::List l2 = block { + final core::List #t42 = []; + final core::Iterable? #t43 = n1; + if(!#t43.{core::Object::==}(null)) + for (final Never #t44 in #t43{core::Iterable}) + #t42.{core::List::add}(#t44); + } =>#t42; + core::List l3 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:30:16: Error: Can't spread a value with static type 'N2'. + var l3 = [...n2]; + ^"]; + core::List l4 = block { + final core::List #t45 = []; + final core::Iterable? #t46 = n2; + if(!#t46.{core::Object::==}(null)) + for (final Never #t47 in #t46{core::Iterable}) + #t45.{core::List::add}(#t47); + } =>#t45; + core::List l5 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:32:16: Error: Can't spread a value with static type 'N3'. + var l5 = [...n3]; + ^"]; + core::List l6 = block { + final core::List #t48 = []; + final core::Iterable? #t49 = n3; + if(!#t49.{core::Object::==}(null)) + for (final Never #t50 in #t49{core::Iterable}) + #t48.{core::List::add}(#t50); + } =>#t48; + core::Set s1 = block { + final core::Set #t51 = col::LinkedHashSet::•(); + for (final self::test2::N1 #t52 in n1) + #t51.{core::Set::add}(#t52); + #t51.{core::Set::add}(n1); + } =>#t51; + core::Set s2 = block { + final core::Set #t53 = col::LinkedHashSet::•(); + final core::Iterable? #t54 = n1; + if(!#t54.{core::Object::==}(null)) + for (final self::test2::N1 #t55 in #t54{core::Iterable}) + #t53.{core::Set::add}(#t55); + #t53.{core::Set::add}(n1); + } =>#t53; + core::Set s3 = let final core::Set #t56 = col::LinkedHashSet::•() in let final dynamic #t57 = #t56.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:36:16: Error: Can't spread a value with static type 'N2'. + var s3 = {...n2, n1}; + ^") in let final dynamic #t58 = #t56.{core::Set::add}(n1) in #t56; + core::Set s4 = block { + final core::Set #t59 = col::LinkedHashSet::•(); + final core::Iterable? #t60 = n2; + if(!#t60.{core::Object::==}(null)) + for (final self::test2::N1 #t61 in #t60{core::Iterable}) + #t59.{core::Set::add}(#t61); + #t59.{core::Set::add}(n1); + } =>#t59; + core::Set s5 = let final core::Set #t62 = col::LinkedHashSet::•() in let final dynamic #t63 = #t62.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:38:16: Error: Can't spread a value with static type 'N3'. + var s5 = {...n3, n1}; + ^") in let final dynamic #t64 = #t62.{core::Set::add}(n1) in #t62; + core::Set s6 = block { + final core::Set #t65 = col::LinkedHashSet::•(); + final core::Iterable? #t66 = n3; + if(!#t66.{core::Object::==}(null)) + for (final self::test2::N1 #t67 in #t66{core::Iterable}) + #t65.{core::Set::add}(#t67); + #t65.{core::Set::add}(n1); + } =>#t65; + core::Map m1 = block { + final core::Map #t68 = {}; + for (final core::MapEntry #t69 in n1.{core::Map::entries}) + #t68.{core::Map::[]=}(#t69.{core::MapEntry::key}, #t69.{core::MapEntry::value}); + #t68.{core::Map::[]=}(n1, n1); + } =>#t68; + core::Map m2 = block { + final core::Map #t70 = {}; + final core::Map? #t71 = n1; + if(!#t71.{core::Object::==}(null)) + for (final core::MapEntry #t72 in #t71{core::Map}.{core::Map::entries}) + #t70.{core::Map::[]=}(#t72.{core::MapEntry::key}, #t72.{core::MapEntry::value}); + #t70.{core::Map::[]=}(n1, n1); + } =>#t70; + core::Map m3 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:42:16: Error: Can't spread a value with static type 'N2'. + var m3 = {...n2, n1: n1}; + ^": null, n1: n1}; + core::Map m4 = block { + final core::Map #t73 = {}; + final core::Map? #t74 = n2; + if(!#t74.{core::Object::==}(null)) + for (final core::MapEntry #t75 in #t74{core::Map}.{core::Map::entries}) + #t73.{core::Map::[]=}(#t75.{core::MapEntry::key}, #t75.{core::MapEntry::value}); + #t73.{core::Map::[]=}(n1, n1); + } =>#t73; + core::Map m5 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:44:16: Error: Can't spread a value with static type 'N3'. + var m5 = {...n3, n1: n1}; + ^": null, n1: n1}; + core::Map m6 = block { + final core::Map #t76 = {}; + final core::Map? #t77 = n3; + if(!#t77.{core::Object::==}(null)) + for (final core::MapEntry #t78 in #t77{core::Map}.{core::Map::entries}) + #t76.{core::Map::[]=}(#t78.{core::MapEntry::key}, #t78.{core::MapEntry::value}); + #t76.{core::Map::[]=}(n1, n1); + } =>#t76; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/nnbd/issue42758.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd/issue42758.dart.weak.transformed.expect new file mode 100644 index 00000000000..f24f3517fc6 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/issue42758.dart.weak.transformed.expect @@ -0,0 +1,375 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/nnbd/issue42758.dart:7:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var l2 = [...?n1]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:8:16: Error: Can't spread a value with static type 'Never?'. +// var l3 = [...n2]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:10:16: Error: Can't spread a value with static type 'Null'. +// var l5 = [...n3]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:13:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var s2 = {...?n1, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:14:16: Error: Can't spread a value with static type 'Never?'. +// var s3 = {...n2, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:16:16: Error: Can't spread a value with static type 'Null'. +// var s5 = {...n3, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:19:17: Warning: Operand of null-aware operation '...?' has type 'Never' which excludes null. +// var m2 = {...?n1, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:20:16: Error: Can't spread a value with static type 'Never?'. +// var m3 = {...n2, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:22:16: Error: Can't spread a value with static type 'Null'. +// var m5 = {...n3, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:29:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var l2 = [...?n1]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:30:16: Error: Can't spread a value with static type 'N2'. +// var l3 = [...n2]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:32:16: Error: Can't spread a value with static type 'N3'. +// var l5 = [...n3]; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:35:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var s2 = {...?n1, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:36:16: Error: Can't spread a value with static type 'N2'. +// var s3 = {...n2, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:38:16: Error: Can't spread a value with static type 'N3'. +// var s5 = {...n3, n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:41:17: Warning: Operand of null-aware operation '...?' has type 'N1' which excludes null. +// var m2 = {...?n1, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:42:16: Error: Can't spread a value with static type 'N2'. +// var m3 = {...n2, n1: n1}; +// ^ +// +// pkg/front_end/testcases/nnbd/issue42758.dart:44:16: Error: Can't spread a value with static type 'N3'. +// var m5 = {...n3, n1: n1}; +// ^ +// +import self as self; +import "dart:core" as core; +import "dart:collection" as col; + +static method test1(Never n1, Never? n2, core::Null? n3) → dynamic { + core::List l1 = block { + final core::List #t1 = []; + for (final Never #t2 in n1) + #t1.{core::List::add}(#t2); + } =>#t1; + core::List l2 = block { + final core::List #t3 = []; + final core::Iterable? #t4 = n1; + if(!#t4.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t4{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t5 = :sync-for-iterator.{core::Iterator::current}; + #t3.{core::List::add}(#t5); + } + } + } =>#t3; + core::List l3 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:8:16: Error: Can't spread a value with static type 'Never?'. + var l3 = [...n2]; + ^"]; + core::List l4 = block { + final core::List #t6 = []; + final core::Iterable? #t7 = n2; + if(!#t7.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t7{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t8 = :sync-for-iterator.{core::Iterator::current}; + #t6.{core::List::add}(#t8); + } + } + } =>#t6; + core::List l5 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:10:16: Error: Can't spread a value with static type 'Null'. + var l5 = [...n3]; + ^"]; + core::List l6 = block { + final core::List #t9 = []; + final core::Iterable? #t10 = n3; + if(!#t10.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t10{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t11 = :sync-for-iterator.{core::Iterator::current}; + #t9.{core::List::add}(#t11); + } + } + } =>#t9; + core::Set s1 = block { + final core::Set #t12 = col::LinkedHashSet::•(); + for (final Never #t13 in n1) + #t12.{core::Set::add}(#t13); + #t12.{core::Set::add}(n1); + } =>#t12; + core::Set s2 = block { + final core::Set #t14 = col::LinkedHashSet::•(); + final core::Iterable? #t15 = n1; + if(!#t15.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t15{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t16 = :sync-for-iterator.{core::Iterator::current}; + #t14.{core::Set::add}(#t16); + } + } + #t14.{core::Set::add}(n1); + } =>#t14; + core::Set s3 = let final core::Set #t17 = col::LinkedHashSet::•() in let final core::bool #t18 = #t17.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:14:16: Error: Can't spread a value with static type 'Never?'. + var s3 = {...n2, n1}; + ^") in let final core::bool #t19 = #t17.{core::Set::add}(n1) in #t17; + core::Set s4 = block { + final core::Set #t20 = col::LinkedHashSet::•(); + final core::Iterable? #t21 = n2; + if(!#t21.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t21{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t22 = :sync-for-iterator.{core::Iterator::current}; + #t20.{core::Set::add}(#t22); + } + } + #t20.{core::Set::add}(n1); + } =>#t20; + core::Set s5 = let final core::Set #t23 = col::LinkedHashSet::•() in let final core::bool #t24 = #t23.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:16:16: Error: Can't spread a value with static type 'Null'. + var s5 = {...n3, n1}; + ^") in let final core::bool #t25 = #t23.{core::Set::add}(n1) in #t23; + core::Set s6 = block { + final core::Set #t26 = col::LinkedHashSet::•(); + final core::Iterable? #t27 = n3; + if(!#t27.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t27{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t28 = :sync-for-iterator.{core::Iterator::current}; + #t26.{core::Set::add}(#t28); + } + } + #t26.{core::Set::add}(n1); + } =>#t26; + core::Map m1 = block { + final core::Map #t29 = {}; + { + core::Iterator, >> :sync-for-iterator = n1.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t30 = :sync-for-iterator.{core::Iterator::current}; + #t29.{core::Map::[]=}(#t30.{core::MapEntry::key}, #t30.{core::MapEntry::value}); + } + } + #t29.{core::Map::[]=}(n1, n1); + } =>#t29; + core::Map m2 = block { + final core::Map #t31 = {}; + final core::Map? #t32 = n1; + if(!#t32.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t32{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t33 = :sync-for-iterator.{core::Iterator::current}; + #t31.{core::Map::[]=}(#t33.{core::MapEntry::key}, #t33.{core::MapEntry::value}); + } + } + #t31.{core::Map::[]=}(n1, n1); + } =>#t31; + core::Map m3 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:20:16: Error: Can't spread a value with static type 'Never?'. + var m3 = {...n2, n1: n1}; + ^": null, n1: n1}; + core::Map m4 = block { + final core::Map #t34 = {}; + final core::Map? #t35 = n2; + if(!#t35.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t35{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t36 = :sync-for-iterator.{core::Iterator::current}; + #t34.{core::Map::[]=}(#t36.{core::MapEntry::key}, #t36.{core::MapEntry::value}); + } + } + #t34.{core::Map::[]=}(n1, n1); + } =>#t34; + core::Map m5 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:22:16: Error: Can't spread a value with static type 'Null'. + var m5 = {...n3, n1: n1}; + ^": null, n1: n1}; + core::Map m6 = block { + final core::Map #t37 = {}; + final core::Map? #t38 = n3; + if(!#t38.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t38{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t39 = :sync-for-iterator.{core::Iterator::current}; + #t37.{core::Map::[]=}(#t39.{core::MapEntry::key}, #t39.{core::MapEntry::value}); + } + } + #t37.{core::Map::[]=}(n1, n1); + } =>#t37; +} +static method test2(self::test2::N1 n1, self::test2::N2% n2, self::test2::N3% n3) → dynamic { + core::List l1 = block { + final core::List #t40 = []; + for (final Never #t41 in n1) + #t40.{core::List::add}(#t41); + } =>#t40; + core::List l2 = block { + final core::List #t42 = []; + final core::Iterable? #t43 = n1; + if(!#t43.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t43{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t44 = :sync-for-iterator.{core::Iterator::current}; + #t42.{core::List::add}(#t44); + } + } + } =>#t42; + core::List l3 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:30:16: Error: Can't spread a value with static type 'N2'. + var l3 = [...n2]; + ^"]; + core::List l4 = block { + final core::List #t45 = []; + final core::Iterable? #t46 = n2; + if(!#t46.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t46{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t47 = :sync-for-iterator.{core::Iterator::current}; + #t45.{core::List::add}(#t47); + } + } + } =>#t45; + core::List l5 = [invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:32:16: Error: Can't spread a value with static type 'N3'. + var l5 = [...n3]; + ^"]; + core::List l6 = block { + final core::List #t48 = []; + final core::Iterable? #t49 = n3; + if(!#t49.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t49{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final Never #t50 = :sync-for-iterator.{core::Iterator::current}; + #t48.{core::List::add}(#t50); + } + } + } =>#t48; + core::Set s1 = block { + final core::Set #t51 = col::LinkedHashSet::•(); + for (final self::test2::N1 #t52 in n1) + #t51.{core::Set::add}(#t52); + #t51.{core::Set::add}(n1); + } =>#t51; + core::Set s2 = block { + final core::Set #t53 = col::LinkedHashSet::•(); + final core::Iterable? #t54 = n1; + if(!#t54.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t54{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final self::test2::N1 #t55 = :sync-for-iterator.{core::Iterator::current}; + #t53.{core::Set::add}(#t55); + } + } + #t53.{core::Set::add}(n1); + } =>#t53; + core::Set s3 = let final core::Set #t56 = col::LinkedHashSet::•() in let final core::bool #t57 = #t56.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:36:16: Error: Can't spread a value with static type 'N2'. + var s3 = {...n2, n1}; + ^") in let final core::bool #t58 = #t56.{core::Set::add}(n1) in #t56; + core::Set s4 = block { + final core::Set #t59 = col::LinkedHashSet::•(); + final core::Iterable? #t60 = n2; + if(!#t60.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t60{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final self::test2::N1 #t61 = :sync-for-iterator.{core::Iterator::current}; + #t59.{core::Set::add}(#t61); + } + } + #t59.{core::Set::add}(n1); + } =>#t59; + core::Set s5 = let final core::Set #t62 = col::LinkedHashSet::•() in let final core::bool #t63 = #t62.{core::Set::add}(invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:38:16: Error: Can't spread a value with static type 'N3'. + var s5 = {...n3, n1}; + ^") in let final core::bool #t64 = #t62.{core::Set::add}(n1) in #t62; + core::Set s6 = block { + final core::Set #t65 = col::LinkedHashSet::•(); + final core::Iterable? #t66 = n3; + if(!#t66.{core::Object::==}(null)) { + core::Iterator :sync-for-iterator = #t66{core::Iterable}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final self::test2::N1 #t67 = :sync-for-iterator.{core::Iterator::current}; + #t65.{core::Set::add}(#t67); + } + } + #t65.{core::Set::add}(n1); + } =>#t65; + core::Map m1 = block { + final core::Map #t68 = {}; + { + core::Iterator, >> :sync-for-iterator = n1.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t69 = :sync-for-iterator.{core::Iterator::current}; + #t68.{core::Map::[]=}(#t69.{core::MapEntry::key}, #t69.{core::MapEntry::value}); + } + } + #t68.{core::Map::[]=}(n1, n1); + } =>#t68; + core::Map m2 = block { + final core::Map #t70 = {}; + final core::Map? #t71 = n1; + if(!#t71.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t71{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t72 = :sync-for-iterator.{core::Iterator::current}; + #t70.{core::Map::[]=}(#t72.{core::MapEntry::key}, #t72.{core::MapEntry::value}); + } + } + #t70.{core::Map::[]=}(n1, n1); + } =>#t70; + core::Map m3 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:42:16: Error: Can't spread a value with static type 'N2'. + var m3 = {...n2, n1: n1}; + ^": null, n1: n1}; + core::Map m4 = block { + final core::Map #t73 = {}; + final core::Map? #t74 = n2; + if(!#t74.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t74{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t75 = :sync-for-iterator.{core::Iterator::current}; + #t73.{core::Map::[]=}(#t75.{core::MapEntry::key}, #t75.{core::MapEntry::value}); + } + } + #t73.{core::Map::[]=}(n1, n1); + } =>#t73; + core::Map m5 = {invalid-expression "pkg/front_end/testcases/nnbd/issue42758.dart:44:16: Error: Can't spread a value with static type 'N3'. + var m5 = {...n3, n1: n1}; + ^": null, n1: n1}; + core::Map m6 = block { + final core::Map #t76 = {}; + final core::Map? #t77 = n3; + if(!#t77.{core::Object::==}(null)) { + core::Iterator> :sync-for-iterator = #t77{core::Map}.{core::Map::entries}.{core::Iterable::iterator}; + for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) { + final core::MapEntry #t78 = :sync-for-iterator.{core::Iterator::current}; + #t76.{core::Map::[]=}(#t78.{core::MapEntry::key}, #t78.{core::MapEntry::value}); + } + } + #t76.{core::Map::[]=}(n1, n1); + } =>#t76; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/nnbd/never_receiver.dart.strong.expect b/pkg/front_end/testcases/nnbd/never_receiver.dart.strong.expect index 40260d90df1..64f137e92be 100644 --- a/pkg/front_end/testcases/nnbd/never_receiver.dart.strong.expect +++ b/pkg/front_end/testcases/nnbd/never_receiver.dart.strong.expect @@ -22,42 +22,42 @@ library /*isNonNullableByDefault*/; // x?.[42] = 42; // Warning. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing method, or defining a method named 'foo'. // y.foo(); // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'bar'. // y.bar; // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing setter, or defining a setter or field named 'baz'. // y.baz = 42; // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing method, or defining a method named 'call'. // y(); // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '+' operator. // y++; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '+' operator. // y += 1; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '[]' operator. // y[42]; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '[]=' operator. // y[42] = 42; // Error. // ^ @@ -87,35 +87,35 @@ static method foo(Never x, Never? y) → dynamic { let final Never #t9 = x in #t9.{core::Object::==}(null) ?{core::int?} null : #t9.baz = 42; let final Never #t10 = x in #t10.{core::Object::==}(null) ?{core::Null?} null : #t10.[](42); let final Never #t11 = x in #t11.{core::Object::==}(null) ?{core::int?} null : #t11.[]=(42, 42); - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing method, or defining a method named 'foo'. y.foo(); // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'bar'. y.bar; // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing setter, or defining a setter or field named 'baz'. y.baz = 42; // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing method, or defining a method named 'call'. y(); // Error. ^"; - y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never'. + y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '+' operator. y++; // Error. ^" as{TypeError,ForDynamic,ForNonNullableByDefault} Never?; - y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never'. + y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '+' operator. y += 1; // Error. ^" as{TypeError,ForDynamic,ForNonNullableByDefault} Never?; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '[]' operator. y[42]; // Error. ^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '[]=' operator. y[42] = 42; // Error. ^"; diff --git a/pkg/front_end/testcases/nnbd/never_receiver.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/never_receiver.dart.strong.transformed.expect index 1eb7ae340f6..2a5f9c51354 100644 --- a/pkg/front_end/testcases/nnbd/never_receiver.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/nnbd/never_receiver.dart.strong.transformed.expect @@ -22,42 +22,42 @@ library /*isNonNullableByDefault*/; // x?.[42] = 42; // Warning. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing method, or defining a method named 'foo'. // y.foo(); // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'bar'. // y.bar; // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing setter, or defining a setter or field named 'baz'. // y.baz = 42; // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing method, or defining a method named 'call'. // y(); // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '+' operator. // y++; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '+' operator. // y += 1; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '[]' operator. // y[42]; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '[]=' operator. // y[42] = 42; // Error. // ^ @@ -87,35 +87,35 @@ static method foo(Never x, Never? y) → dynamic { let final Never #t9 = x in #t9.{core::Object::==}(null) ?{core::int?} null : #t9.baz = 42; let final Never #t10 = x in #t10.{core::Object::==}(null) ?{core::Null?} null : #t10.[](42); let final Never #t11 = x in #t11.{core::Object::==}(null) ?{core::int?} null : #t11.[]=(42, 42); - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing method, or defining a method named 'foo'. y.foo(); // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'bar'. y.bar; // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing setter, or defining a setter or field named 'baz'. y.baz = 42; // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing method, or defining a method named 'call'. y(); // Error. ^"; - y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never'. + y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '+' operator. y++; // Error. ^"; - y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never'. + y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '+' operator. y += 1; // Error. ^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '[]' operator. y[42]; // Error. ^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '[]=' operator. y[42] = 42; // Error. ^"; diff --git a/pkg/front_end/testcases/nnbd/never_receiver.dart.weak.expect b/pkg/front_end/testcases/nnbd/never_receiver.dart.weak.expect index 40260d90df1..64f137e92be 100644 --- a/pkg/front_end/testcases/nnbd/never_receiver.dart.weak.expect +++ b/pkg/front_end/testcases/nnbd/never_receiver.dart.weak.expect @@ -22,42 +22,42 @@ library /*isNonNullableByDefault*/; // x?.[42] = 42; // Warning. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing method, or defining a method named 'foo'. // y.foo(); // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'bar'. // y.bar; // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing setter, or defining a setter or field named 'baz'. // y.baz = 42; // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing method, or defining a method named 'call'. // y(); // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '+' operator. // y++; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '+' operator. // y += 1; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '[]' operator. // y[42]; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '[]=' operator. // y[42] = 42; // Error. // ^ @@ -87,35 +87,35 @@ static method foo(Never x, Never? y) → dynamic { let final Never #t9 = x in #t9.{core::Object::==}(null) ?{core::int?} null : #t9.baz = 42; let final Never #t10 = x in #t10.{core::Object::==}(null) ?{core::Null?} null : #t10.[](42); let final Never #t11 = x in #t11.{core::Object::==}(null) ?{core::int?} null : #t11.[]=(42, 42); - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing method, or defining a method named 'foo'. y.foo(); // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'bar'. y.bar; // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing setter, or defining a setter or field named 'baz'. y.baz = 42; // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing method, or defining a method named 'call'. y(); // Error. ^"; - y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never'. + y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '+' operator. y++; // Error. ^" as{TypeError,ForDynamic,ForNonNullableByDefault} Never?; - y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never'. + y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '+' operator. y += 1; // Error. ^" as{TypeError,ForDynamic,ForNonNullableByDefault} Never?; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '[]' operator. y[42]; // Error. ^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '[]=' operator. y[42] = 42; // Error. ^"; diff --git a/pkg/front_end/testcases/nnbd/never_receiver.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd/never_receiver.dart.weak.transformed.expect index 1eb7ae340f6..2a5f9c51354 100644 --- a/pkg/front_end/testcases/nnbd/never_receiver.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/nnbd/never_receiver.dart.weak.transformed.expect @@ -22,42 +22,42 @@ library /*isNonNullableByDefault*/; // x?.[42] = 42; // Warning. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing method, or defining a method named 'foo'. // y.foo(); // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'bar'. // y.bar; // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing setter, or defining a setter or field named 'baz'. // y.baz = 42; // Error. // ^^^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never?'. // Try correcting the name to the name of an existing method, or defining a method named 'call'. // y(); // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '+' operator. // y++; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '+' operator. // y += 1; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '[]' operator. // y[42]; // Error. // ^ // -// pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never'. +// pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never?'. // Try correcting the operator to an existing operator, or defining a '[]=' operator. // y[42] = 42; // Error. // ^ @@ -87,35 +87,35 @@ static method foo(Never x, Never? y) → dynamic { let final Never #t9 = x in #t9.{core::Object::==}(null) ?{core::int?} null : #t9.baz = 42; let final Never #t10 = x in #t10.{core::Object::==}(null) ?{core::Null?} null : #t10.[](42); let final Never #t11 = x in #t11.{core::Object::==}(null) ?{core::int?} null : #t11.[]=(42, 42); - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:30:5: Error: The method 'foo' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing method, or defining a method named 'foo'. y.foo(); // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:31:5: Error: The getter 'bar' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'bar'. y.bar; // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:32:5: Error: The setter 'baz' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing setter, or defining a setter or field named 'baz'. y.baz = 42; // Error. ^^^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:33:4: Error: The method 'call' isn't defined for the class 'Never?'. Try correcting the name to the name of an existing method, or defining a method named 'call'. y(); // Error. ^"; - y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never'. + y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:34:4: Error: The operator '+' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '+' operator. y++; // Error. ^"; - y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never'. + y = invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:35:5: Error: The operator '+' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '+' operator. y += 1; // Error. ^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:36:4: Error: The operator '[]' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '[]' operator. y[42]; // Error. ^"; - invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never'. + invalid-expression "pkg/front_end/testcases/nnbd/never_receiver.dart:37:4: Error: The operator '[]=' isn't defined for the class 'Never?'. Try correcting the operator to an existing operator, or defining a '[]=' operator. y[42] = 42; // Error. ^"; diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart index 529bfb44c28..e1bf6e01954 100644 --- a/pkg/kernel/lib/ast.dart +++ b/pkg/kernel/lib/ast.dart @@ -3021,6 +3021,9 @@ abstract class Expression extends TreeNode { if (type == context.typeEnvironment.nullType) { return context.typeEnvironment.coreTypes .bottomInterfaceType(superclass, context.nullable); + } else if (type is NeverType) { + return context.typeEnvironment.coreTypes + .bottomInterfaceType(superclass, type.nullability); } if (type is InterfaceType) { List upcastTypeArguments = context.typeEnvironment diff --git a/pkg/kernel/lib/type_checker.dart b/pkg/kernel/lib/type_checker.dart index 7eeef0cc7d6..5db606b2766 100644 --- a/pkg/kernel/lib/type_checker.dart +++ b/pkg/kernel/lib/type_checker.dart @@ -249,7 +249,7 @@ class TypeCheckingVisitor while (type is TypeParameterType) { type = (type as TypeParameterType).bound; } - if (type is BottomType) { + if (type is BottomType || type is NeverType || type == coreTypes.nullType) { // The bottom type is a subtype of all types, so it should be allowed. return Substitution.bottomForClass(superclass); }