diff --git a/pkg/front_end/lib/src/fasta/constant_context.dart b/pkg/front_end/lib/src/fasta/constant_context.dart index a6dac5027fb..a4d646a8f0f 100644 --- a/pkg/front_end/lib/src/fasta/constant_context.dart +++ b/pkg/front_end/lib/src/fasta/constant_context.dart @@ -23,19 +23,4 @@ enum ConstantContext { /// This means that `Object()` and `[]` are equivalent to `const Object()` and /// `const []` respectively. `new Object()` is a compile-time error. inferred, - - /// In a context that allows only constant values, but requires them to be - /// defined as `const` explicitly. For example, in default values of optional - /// and named parameters. - /// - /// The following code should emit a compile-time error: - /// - /// class Bar { const Bar(); } - /// class Foo { void foo({Bar bar: Bar()}) {} } - /// - /// The following code should compile without errors: - /// - /// class Bar { const Bar(); } - /// class Foo { void foo({Bar bar: const Bar()}) {} } - needsExplicitConst, } diff --git a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart index 8ea0b701c91..f1d773d224b 100644 --- a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart +++ b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart @@ -3761,18 +3761,6 @@ const MessageCode messageNativeClauseShouldBeAnnotation = const MessageCode( tip: r"""Try removing this native clause and adding @native() or @native('native-name') before the declaration."""); -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const Code codeNeedExplicitConst = messageNeedExplicitConst; - -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const MessageCode messageNeedExplicitConst = const MessageCode( - "NeedExplicitConst", - analyzerCode: "NON_CONSTANT_DEFAULT_VALUE", - dart2jsCode: "*fatal*", - severity: Severity.error, - message: r"""An explicit 'const' keyword is expected here.""", - tip: r"""Put the 'const' keyword at this position."""); - // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const Template< Message Function(Token token)> templateNoFormals = const Template< diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart index 459327bdcfd..b3df16cb94c 100644 --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart @@ -76,8 +76,6 @@ import 'redirecting_factory_body.dart' import '../names.dart'; -import 'constness_evaluator.dart' show evaluateConstness; - import 'fasta_accessors.dart'; import 'kernel_api.dart'; @@ -185,12 +183,6 @@ class BodyBuilder extends ScopeListener /// and where that was. Map initializedFields; - /// Constructor invocations (either generative or factory) with not specified - /// `new` or `const` keywords. The constness for these should be inferred - /// based on the subexpressions. - List constructorInvocationsWithImplicitConstness = - new List(); - BodyBuilder( KernelLibraryBuilder library, this.member, @@ -497,8 +489,6 @@ class BodyBuilder extends ScopeListener } } } - - inferConstness(); } @override @@ -696,24 +686,6 @@ class BodyBuilder extends ScopeListener unhandled("${builder.runtimeType}", "finishFunction", builder.charOffset, builder.fileUri); } - - inferConstness(); - } - - // Infers constness of the constructor invocations collected so far in - // [constructorInvocationsWithImplicitConstness], then clears out the list. - void inferConstness() { - for (Expression invocation in constructorInvocationsWithImplicitConstness) { - if (invocation is ConstructorInvocation) { - invocation.isConst = evaluateConstness(invocation, coreTypes, uri); - } else if (invocation is StaticInvocation) { - invocation.isConst = evaluateConstness(invocation, coreTypes, uri); - } else { - unhandled("${invocation.runtimeType}", "inferConstness", - invocation.fileOffset, invocation.location.file); - } - } - constructorInvocationsWithImplicitConstness.clear(); } @override @@ -2170,7 +2142,7 @@ class BodyBuilder extends ScopeListener @override void beginFormalParameterDefaultValueExpression() { super.push(constantContext); - constantContext = ConstantContext.needsExplicitConst; + constantContext = ConstantContext.none; } @override @@ -2497,11 +2469,6 @@ class BodyBuilder extends ScopeListener argMessage: argMessage); } if (target is Constructor) { - if (constantContext == ConstantContext.needsExplicitConst && - constness == Constness.implicit) { - return buildCompileTimeError( - fasta.messageNeedExplicitConst, charOffset, noLength); - } isConst = isConst || constantContext != ConstantContext.none && target.isConst; if ((isConst || constantContext == ConstantContext.inferred) && @@ -2509,19 +2476,10 @@ class BodyBuilder extends ScopeListener return deprecated_buildCompileTimeError( "Not a const constructor.", charOffset); } - ShadowConstructorInvocation invocation = new ShadowConstructorInvocation( - target, - targetTypeArguments, - initialTarget, - forest.castArguments(arguments), + return new ShadowConstructorInvocation(target, targetTypeArguments, + initialTarget, forest.castArguments(arguments), isConst: isConst) ..fileOffset = charOffset; - if (constness == Constness.implicit && - target.isConst && - constantContext != ConstantContext.inferred) { - constructorInvocationsWithImplicitConstness.add(invocation); - } - return invocation; } else { Procedure procedure = target; if (procedure.isFactory) { @@ -2532,22 +2490,10 @@ class BodyBuilder extends ScopeListener return deprecated_buildCompileTimeError( "Not a const factory.", charOffset); } - if (constantContext == ConstantContext.needsExplicitConst && - constness == Constness.implicit) { - return buildCompileTimeError( - fasta.messageNeedExplicitConst, charOffset, noLength); - } - ShadowFactoryConstructorInvocation invocation = - new ShadowFactoryConstructorInvocation(target, targetTypeArguments, - initialTarget, forest.castArguments(arguments), - isConst: isConst) - ..fileOffset = charOffset; - if (constness == Constness.implicit && - procedure.isConst && - constantContext != ConstantContext.inferred) { - constructorInvocationsWithImplicitConstness.add(invocation); - } - return invocation; + return new ShadowFactoryConstructorInvocation(target, + targetTypeArguments, initialTarget, forest.castArguments(arguments), + isConst: isConst) + ..fileOffset = charOffset; } else { return new ShadowStaticInvocation( target, forest.castArguments(arguments), diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml index fcfb60a5a40..dc8a01745c1 100644 --- a/pkg/front_end/messages.yaml +++ b/pkg/front_end/messages.yaml @@ -2061,17 +2061,3 @@ ImplicitCallOfNonMethod: template: "Can't invoke the type '#type' because its declaration of `.call` is not a method." tip: "Change .call to a method or explicitly invoke .call." severity: ERROR - -NeedExplicitConst: - template: "An explicit 'const' keyword is expected here." - tip: "Put the 'const' keyword at this position." - severity: ERROR - analyzerCode: NON_CONSTANT_DEFAULT_VALUE # TODO(dmitryas): Ask the analyzer team if the code is correct. - dart2jsCode: "*fatal*" - script: > - class Foo { - const Foo(); - } - class Bar { - const Bar([Foo foo = Foo()]); - } diff --git a/pkg/front_end/testcases/implicit_const_with_static_fields.dart.direct.expect b/pkg/front_end/testcases/implicit_const_with_static_fields.dart.direct.expect index f9280297995..e086d538e6d 100644 --- a/pkg/front_end/testcases/implicit_const_with_static_fields.dart.direct.expect +++ b/pkg/front_end/testcases/implicit_const_with_static_fields.dart.direct.expect @@ -10,6 +10,6 @@ class C extends core::Object { } static const field dynamic constTopLevelField = 42; static method main() → dynamic { - const self::C::•(self::C::constField); - const self::C::•(self::constTopLevelField); + new self::C::•(self::C::constField); + new self::C::•(self::constTopLevelField); } diff --git a/pkg/front_end/testcases/implicit_const_with_static_fields.dart.direct.transformed.expect b/pkg/front_end/testcases/implicit_const_with_static_fields.dart.direct.transformed.expect index f9280297995..e086d538e6d 100644 --- a/pkg/front_end/testcases/implicit_const_with_static_fields.dart.direct.transformed.expect +++ b/pkg/front_end/testcases/implicit_const_with_static_fields.dart.direct.transformed.expect @@ -10,6 +10,6 @@ class C extends core::Object { } static const field dynamic constTopLevelField = 42; static method main() → dynamic { - const self::C::•(self::C::constField); - const self::C::•(self::constTopLevelField); + new self::C::•(self::C::constField); + new self::C::•(self::constTopLevelField); } diff --git a/pkg/front_end/testcases/implicit_const_with_static_fields.dart.strong.expect b/pkg/front_end/testcases/implicit_const_with_static_fields.dart.strong.expect index 90d9837f22e..c4b4907b1d2 100644 --- a/pkg/front_end/testcases/implicit_const_with_static_fields.dart.strong.expect +++ b/pkg/front_end/testcases/implicit_const_with_static_fields.dart.strong.expect @@ -10,6 +10,6 @@ class C extends core::Object { } static const field core::int constTopLevelField = 42; static method main() → dynamic { - const self::C::•(self::C::constField); - const self::C::•(self::constTopLevelField); + new self::C::•(self::C::constField); + new self::C::•(self::constTopLevelField); } diff --git a/pkg/front_end/testcases/implicit_const_with_static_fields.dart.strong.transformed.expect b/pkg/front_end/testcases/implicit_const_with_static_fields.dart.strong.transformed.expect index 90d9837f22e..c4b4907b1d2 100644 --- a/pkg/front_end/testcases/implicit_const_with_static_fields.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/implicit_const_with_static_fields.dart.strong.transformed.expect @@ -10,6 +10,6 @@ class C extends core::Object { } static const field core::int constTopLevelField = 42; static method main() → dynamic { - const self::C::•(self::C::constField); - const self::C::•(self::constTopLevelField); + new self::C::•(self::C::constField); + new self::C::•(self::constTopLevelField); } diff --git a/pkg/front_end/testcases/magic_const.dart.direct.expect b/pkg/front_end/testcases/magic_const.dart.direct.expect index fea9503a892..31bfe5f8e76 100644 --- a/pkg/front_end/testcases/magic_const.dart.direct.expect +++ b/pkg/front_end/testcases/magic_const.dart.direct.expect @@ -12,20 +12,14 @@ class NotConstant extends core::Object { : super core::Object::•() ; } -static method foo({dynamic a = invalid-expression "pkg/front_end/testcases/magic_const.dart:15:9: Error: An explicit 'const' keyword is expected here. -Put the 'const' keyword at this position. -foo({a: Constant(), b: Constant(), c: []}) {} - ^", dynamic b = invalid-expression "pkg/front_end/testcases/magic_const.dart:15:24: Error: An explicit 'const' keyword is expected here. -Put the 'const' keyword at this position. -foo({a: Constant(), b: Constant(), c: []}) {} - ^", dynamic c = []}) → dynamic {} +static method foo({dynamic a = new self::Constant::•(), dynamic b = new self::Constant::•(), dynamic c = []}) → dynamic {} static method test() → dynamic { invalid-expression "pkg/front_end/testcases/magic_const.dart:18:9: Error: Not a const constructor. const NotConstant(); ^"; - const self::Constant::•(); + new self::Constant::•(); const dynamic x = const self::Constant::•(); - const core::bool::fromEnvironment("fisk"); + core::bool::fromEnvironment("fisk"); const dynamic b = const core::bool::fromEnvironment("fisk"); } static method main() → dynamic {} diff --git a/pkg/front_end/testcases/magic_const.dart.direct.transformed.expect b/pkg/front_end/testcases/magic_const.dart.direct.transformed.expect index fea9503a892..31bfe5f8e76 100644 --- a/pkg/front_end/testcases/magic_const.dart.direct.transformed.expect +++ b/pkg/front_end/testcases/magic_const.dart.direct.transformed.expect @@ -12,20 +12,14 @@ class NotConstant extends core::Object { : super core::Object::•() ; } -static method foo({dynamic a = invalid-expression "pkg/front_end/testcases/magic_const.dart:15:9: Error: An explicit 'const' keyword is expected here. -Put the 'const' keyword at this position. -foo({a: Constant(), b: Constant(), c: []}) {} - ^", dynamic b = invalid-expression "pkg/front_end/testcases/magic_const.dart:15:24: Error: An explicit 'const' keyword is expected here. -Put the 'const' keyword at this position. -foo({a: Constant(), b: Constant(), c: []}) {} - ^", dynamic c = []}) → dynamic {} +static method foo({dynamic a = new self::Constant::•(), dynamic b = new self::Constant::•(), dynamic c = []}) → dynamic {} static method test() → dynamic { invalid-expression "pkg/front_end/testcases/magic_const.dart:18:9: Error: Not a const constructor. const NotConstant(); ^"; - const self::Constant::•(); + new self::Constant::•(); const dynamic x = const self::Constant::•(); - const core::bool::fromEnvironment("fisk"); + core::bool::fromEnvironment("fisk"); const dynamic b = const core::bool::fromEnvironment("fisk"); } static method main() → dynamic {} diff --git a/pkg/front_end/testcases/magic_const.dart.strong.expect b/pkg/front_end/testcases/magic_const.dart.strong.expect index 758d6793abc..d60f57ee166 100644 --- a/pkg/front_end/testcases/magic_const.dart.strong.expect +++ b/pkg/front_end/testcases/magic_const.dart.strong.expect @@ -12,20 +12,14 @@ class NotConstant extends core::Object { : super core::Object::•() ; } -static method foo({dynamic a = invalid-expression "pkg/front_end/testcases/magic_const.dart:15:9: Error: An explicit 'const' keyword is expected here. -Put the 'const' keyword at this position. -foo({a: Constant(), b: Constant(), c: []}) {} - ^", dynamic b = invalid-expression "pkg/front_end/testcases/magic_const.dart:15:24: Error: An explicit 'const' keyword is expected here. -Put the 'const' keyword at this position. -foo({a: Constant(), b: Constant(), c: []}) {} - ^", dynamic c = []}) → dynamic {} +static method foo({dynamic a = new self::Constant::•(), dynamic b = new self::Constant::•(), dynamic c = []}) → dynamic {} static method test() → dynamic { invalid-expression "pkg/front_end/testcases/magic_const.dart:18:9: Error: Not a const constructor. const NotConstant(); ^"; - const self::Constant::•(); + new self::Constant::•(); const self::Constant x = const self::Constant::•(); - const core::bool::fromEnvironment("fisk"); + core::bool::fromEnvironment("fisk"); const core::bool b = const core::bool::fromEnvironment("fisk"); } static method main() → dynamic {} diff --git a/pkg/front_end/testcases/magic_const.dart.strong.transformed.expect b/pkg/front_end/testcases/magic_const.dart.strong.transformed.expect index 758d6793abc..d60f57ee166 100644 --- a/pkg/front_end/testcases/magic_const.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/magic_const.dart.strong.transformed.expect @@ -12,20 +12,14 @@ class NotConstant extends core::Object { : super core::Object::•() ; } -static method foo({dynamic a = invalid-expression "pkg/front_end/testcases/magic_const.dart:15:9: Error: An explicit 'const' keyword is expected here. -Put the 'const' keyword at this position. -foo({a: Constant(), b: Constant(), c: []}) {} - ^", dynamic b = invalid-expression "pkg/front_end/testcases/magic_const.dart:15:24: Error: An explicit 'const' keyword is expected here. -Put the 'const' keyword at this position. -foo({a: Constant(), b: Constant(), c: []}) {} - ^", dynamic c = []}) → dynamic {} +static method foo({dynamic a = new self::Constant::•(), dynamic b = new self::Constant::•(), dynamic c = []}) → dynamic {} static method test() → dynamic { invalid-expression "pkg/front_end/testcases/magic_const.dart:18:9: Error: Not a const constructor. const NotConstant(); ^"; - const self::Constant::•(); + new self::Constant::•(); const self::Constant x = const self::Constant::•(); - const core::bool::fromEnvironment("fisk"); + core::bool::fromEnvironment("fisk"); const core::bool b = const core::bool::fromEnvironment("fisk"); } static method main() → dynamic {} diff --git a/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.direct.expect b/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.direct.expect index 2007377484d..6c290792bab 100644 --- a/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.direct.expect +++ b/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.direct.expect @@ -19,7 +19,7 @@ class C extends core::Object { : super core::Object::•() ; method fun() → dynamic { - const self::B::•(const self::A::•(self::foo)); + new self::B::•(new self::A::•(self::foo)); } } static const field core::int foo = const core::int::fromEnvironment("fisk"); diff --git a/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.direct.transformed.expect b/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.direct.transformed.expect index 2007377484d..6c290792bab 100644 --- a/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.direct.transformed.expect +++ b/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.direct.transformed.expect @@ -19,7 +19,7 @@ class C extends core::Object { : super core::Object::•() ; method fun() → dynamic { - const self::B::•(const self::A::•(self::foo)); + new self::B::•(new self::A::•(self::foo)); } } static const field core::int foo = const core::int::fromEnvironment("fisk"); diff --git a/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.strong.expect b/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.strong.expect index 2007377484d..6c290792bab 100644 --- a/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.strong.expect +++ b/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.strong.expect @@ -19,7 +19,7 @@ class C extends core::Object { : super core::Object::•() ; method fun() → dynamic { - const self::B::•(const self::A::•(self::foo)); + new self::B::•(new self::A::•(self::foo)); } } static const field core::int foo = const core::int::fromEnvironment("fisk"); diff --git a/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.strong.transformed.expect b/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.strong.transformed.expect index 2007377484d..6c290792bab 100644 --- a/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/nested_implicit_const_with_env_var.dart.strong.transformed.expect @@ -19,7 +19,7 @@ class C extends core::Object { : super core::Object::•() ; method fun() → dynamic { - const self::B::•(const self::A::•(self::foo)); + new self::B::•(new self::A::•(self::foo)); } } static const field core::int foo = const core::int::fromEnvironment("fisk"); diff --git a/pkg/front_end/testcases/new_const_insertion/simple.dart.direct.expect b/pkg/front_end/testcases/new_const_insertion/simple.dart.direct.expect index de2c44cbbca..60532926990 100644 --- a/pkg/front_end/testcases/new_const_insertion/simple.dart.direct.expect +++ b/pkg/front_end/testcases/new_const_insertion/simple.dart.direct.expect @@ -10,8 +10,8 @@ class A extends core::Object { } static method main() → dynamic { core::int foo = 42; - const self::A::•(5); - const self::A::•(5.+(5)); + new self::A::•(5); + new self::A::•(5.+(5)); new self::A::•(foo); new self::A::•(5.+(foo)); } diff --git a/pkg/front_end/testcases/new_const_insertion/simple.dart.direct.transformed.expect b/pkg/front_end/testcases/new_const_insertion/simple.dart.direct.transformed.expect index de2c44cbbca..60532926990 100644 --- a/pkg/front_end/testcases/new_const_insertion/simple.dart.direct.transformed.expect +++ b/pkg/front_end/testcases/new_const_insertion/simple.dart.direct.transformed.expect @@ -10,8 +10,8 @@ class A extends core::Object { } static method main() → dynamic { core::int foo = 42; - const self::A::•(5); - const self::A::•(5.+(5)); + new self::A::•(5); + new self::A::•(5.+(5)); new self::A::•(foo); new self::A::•(5.+(foo)); } diff --git a/pkg/front_end/testcases/new_const_insertion/simple.dart.strong.expect b/pkg/front_end/testcases/new_const_insertion/simple.dart.strong.expect index 4ee5522fc76..d7f734bfea6 100644 --- a/pkg/front_end/testcases/new_const_insertion/simple.dart.strong.expect +++ b/pkg/front_end/testcases/new_const_insertion/simple.dart.strong.expect @@ -10,8 +10,8 @@ class A extends core::Object { } static method main() → dynamic { core::int foo = 42; - const self::A::•(5); - const self::A::•(5.{core::num::+}(5)); + new self::A::•(5); + new self::A::•(5.{core::num::+}(5)); new self::A::•(foo); new self::A::•(5.{core::num::+}(foo)); } diff --git a/pkg/front_end/testcases/new_const_insertion/simple.dart.strong.transformed.expect b/pkg/front_end/testcases/new_const_insertion/simple.dart.strong.transformed.expect index 4ee5522fc76..d7f734bfea6 100644 --- a/pkg/front_end/testcases/new_const_insertion/simple.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/new_const_insertion/simple.dart.strong.transformed.expect @@ -10,8 +10,8 @@ class A extends core::Object { } static method main() → dynamic { core::int foo = 42; - const self::A::•(5); - const self::A::•(5.{core::num::+}(5)); + new self::A::•(5); + new self::A::•(5.{core::num::+}(5)); new self::A::•(foo); new self::A::•(5.{core::num::+}(foo)); } diff --git a/tests/co19/co19-dart2js.status b/tests/co19/co19-dart2js.status index 0e2386c4ad9..c9f6d572c49 100644 --- a/tests/co19/co19-dart2js.status +++ b/tests/co19/co19-dart2js.status @@ -7087,6 +7087,8 @@ Language/Expressions/Strings/multi_line_t32: Crash Language/Expressions/Strings/multi_line_t33: Crash Language/Expressions/This/placement_t04: Crash Language/Functions/External_Functions/not_connected_to_a_body_t01: RuntimeError +Language/Functions/Formal_Parameters/Optional_Formals/default_value_t01: MissingCompileTimeError +Language/Functions/Formal_Parameters/Optional_Formals/default_value_t02: MissingCompileTimeError Language/Functions/syntax_t09: Crash Language/Libraries_and_Scripts/Imports/same_name_t10: RuntimeError Language/Libraries_and_Scripts/Scripts/top_level_main_t01: CompileTimeError diff --git a/tests/co19/co19-kernel.status b/tests/co19/co19-kernel.status index 364a34fd092..997389989a6 100644 --- a/tests/co19/co19-kernel.status +++ b/tests/co19/co19-kernel.status @@ -4,6 +4,8 @@ [ $compiler == fasta ] Language/Classes/definition_t24: MissingCompileTimeError +Language/Functions/Formal_Parameters/Optional_Formals/default_value_t01: MissingCompileTimeError +Language/Functions/Formal_Parameters/Optional_Formals/default_value_t02: MissingCompileTimeError Language/Types/Type_Void/syntax_t08: MissingCompileTimeError Language/Types/Type_Void/syntax_t09: MissingCompileTimeError LayoutTests/*: Skip # TODO(ahe): Make dart:html available. diff --git a/tests/language/language.status b/tests/language/language.status index 78000d47c13..523475abcfc 100644 --- a/tests/language/language.status +++ b/tests/language/language.status @@ -314,6 +314,13 @@ vm/regress_24517_test: Pass, Fail # Issue 24517. assertion_initializer_const_error_test/01: MissingCompileTimeError assertion_initializer_const_function_error_test/01: MissingCompileTimeError +# Detection of compile-time errors that are related to constants can't be fully +# done at the front end, because constants are evaluated at back ends. So, some +# errors aren't detected by fasta, but reported by back ends as compile-time +# errors. +[ $compiler != dart2js && $runtime != vm && $fasta ] +deferred_constraints_constants_test/default_argument2: MissingCompileTimeError + [ $compiler != dartk && $compiler != dartkp && ($runtime == dart_precompiled || $runtime == flutter || $runtime == vm) ] abstract_beats_arguments2_test/01: Crash # Issue 29171 diff --git a/tests/language/language_kernel.status b/tests/language/language_kernel.status index 4eb94082c52..89fe0d9f5af 100644 --- a/tests/language/language_kernel.status +++ b/tests/language/language_kernel.status @@ -3,6 +3,8 @@ # BSD-style license that can be found in the LICENSE file. [ $compiler == fasta ] +function_type_parameter2_negative_test: Fail +function_type_parameter_negative_test: Fail prefix5_negative_test: Fail [ $fasta ] diff --git a/tests/language_2/implicit_creation/implicit_new_or_const_composite_test.dart b/tests/language_2/implicit_creation/implicit_new_or_const_composite_test.dart index 54092f7754e..1a7debe9da3 100644 --- a/tests/language_2/implicit_creation/implicit_new_or_const_composite_test.dart +++ b/tests/language_2/implicit_creation/implicit_new_or_const_composite_test.dart @@ -29,12 +29,12 @@ main() { const cd1 = const C(const D(42)); const cd2 = C(D(42)); // Const context. - var cd3 = C(D(42)); // All constant, even in non-const context. - var cd4 = C(D(x)); // x is a non-constant expression, so `new`. - var cd5 = C(d42); // d42 is a non-constant expression, so `new`. + var cd3 = C(D(42)); // Non-constant context, so `new`. + var cd4 = C(D(x)); // Non-constant context, so `new`. + var cd5 = C(d42); // Non-constant context, so `new`. Expect.identical(cd1, cd2); - Expect.identical(cd1, cd3); + Expect.allDistinct([cd1, cd3]); Expect.allDistinct([cd1, cd4, cd5]); } @@ -44,16 +44,16 @@ main() { const cl2 = C(clist); // Constant context. const cl3 = C(const [37]); // Constant context. const cl4 = C([37]); - var cl5 = C(clist); // Constant argument, so const. - var cl6 = C(const [37]); // Constant arg, so const. - var cl7 = C(list); // Non-constant arg. - var cl8 = C([37]); // Same if literal. + var cl5 = C(clist); // Non-constant context, so `new`. + var cl6 = C(const [37]); // Non-constant context, so `new`. + var cl7 = C(list); // Non-constant context, so `new`. + var cl8 = C([37]); // Non-constant context, so `new`. Expect.identical(cl1, cl2); Expect.identical(cl1, cl3); Expect.identical(cl1, cl4); - Expect.identical(cl1, cl5); - Expect.identical(cl1, cl6); + Expect.allDistinct([cl1, cl5]); + Expect.allDistinct([cl1, cl6]); Expect.allDistinct([cl1, cl7, cl8]); } @@ -62,15 +62,15 @@ main() { const cm1 = C(cmap); // Constant context. const cm2 = C(const {19: 87}); // Constant context. const cm3 = C({19: 87}); // Constant context. - var cm4 = C(cmap); // Constant argument, so const. - var cm5 = C(const {19: 87}); // Constant arg, so const. - var cm6 = C(map); // Non-constant arg, non-const context. - var cm7 = C({19: 87}); // Same if literal. + var cm4 = C(cmap); // Non-constant context, so `new`. + var cm5 = C(const {19: 87}); // Non-constant context, so `new`. + var cm6 = C(map); // Non-constant context, so `new`. + var cm7 = C({19: 87}); // Non-constant context, so `new`. Expect.identical(cm1, cm2); Expect.identical(cm1, cm3); - Expect.identical(cm1, cm4); - Expect.identical(cm1, cm5); + Expect.allDistinct([cm1, cm4]); + Expect.allDistinct([cm1, cm5]); Expect.allDistinct([cm1, cm6, cm7]); } @@ -93,8 +93,8 @@ main() { Expect.identical(n1, n2); Expect.identical(n1, n3); - Expect.identical(n1, n4); - Expect.identical(n1, n8); + Expect.allDistinct([n1, n4]); + Expect.allDistinct([n1, n8]); Expect.allDistinct([n1, n5, n6, n7, n9, n10, n11, n12, n13, n14]); Expect.identical(clist, n6.left); @@ -128,12 +128,12 @@ main() { Expect.identical(n20, n22); Expect.identical(n20, n23); Expect.identical(n20, n24); - Expect.identical(n20, n25); - Expect.identical(n20, n26); - Expect.identical(n20, n27); + Expect.allDistinct([n20, n25]); + Expect.allDistinct([n20, n26]); + Expect.allDistinct([n20, n27]); Expect.allDistinct([n28, n29, n30, n31]); - Expect.identical(cc42, n28.left); - Expect.identical(cc42, n29.left); + Expect.allDistinct([cc42, n28.left]); + Expect.allDistinct([cc42, n29.left]); Expect.identical(cc42, n30.left); Expect.identical(cc42, n31.left); Expect.identical(clist, n29.right); @@ -185,10 +185,10 @@ main() { // List literals are never const unless in const context. Expect.allDistinct([l20, l25, l26, l27, l28, l29, l30, l31]); Expect.identical(cc42, l25[0]); - Expect.identical(cc42, l26[0]); - Expect.identical(cc42, l27[0]); - Expect.identical(cc42, l28[0]); - Expect.identical(cc42, l29[0]); + Expect.allDistinct([cc42, l26[0]]); + Expect.allDistinct([cc42, l27[0]]); + Expect.allDistinct([cc42, l28[0]]); + Expect.allDistinct([cc42, l29[0]]); Expect.identical(cc42, l30[0]); Expect.identical(cc42, l31[0]); Expect.identical(clist, l25[1]); @@ -236,10 +236,10 @@ main() { // Map literals are never const unless in const context. Expect.allDistinct([m20, m25, m26, m27, m28, m29, m30, m31]); Expect.identical(cc42, m25.keys.first); - Expect.identical(cc42, m26.keys.first); - Expect.identical(cc42, m27.keys.first); - Expect.identical(cc42, m28.keys.first); - Expect.identical(cc42, m29.keys.first); + Expect.allDistinct([cc42, m26.keys.first]); + Expect.allDistinct([cc42, m27.keys.first]); + Expect.allDistinct([cc42, m28.keys.first]); + Expect.allDistinct([cc42, m29.keys.first]); Expect.identical(cc42, m30.keys.first); Expect.identical(cc42, m31.keys.first); Expect.identical(clist, m25.values.first); diff --git a/tests/language_2/implicit_creation/implicit_new_or_const_generic_test.dart b/tests/language_2/implicit_creation/implicit_new_or_const_generic_test.dart index 1f58aa5129e..ab9f1489deb 100644 --- a/tests/language_2/implicit_creation/implicit_new_or_const_generic_test.dart +++ b/tests/language_2/implicit_creation/implicit_new_or_const_generic_test.dart @@ -72,7 +72,7 @@ main() { for (var i = 0; i < instances.length; i++) { var d = instances[i]; Expect.equals(d42, d); - if (i % 5 == 2 || i % 5 == 4) { + if (i % 5 == 2) { // The cases of D(42) without "new" are all constant. Expect.identical(d42, d, "$i"); } else { diff --git a/tests/language_2/implicit_creation/implicit_new_or_const_test.dart b/tests/language_2/implicit_creation/implicit_new_or_const_test.dart index 3a0a7b0c510..00c8ae38c52 100644 --- a/tests/language_2/implicit_creation/implicit_new_or_const_test.dart +++ b/tests/language_2/implicit_creation/implicit_new_or_const_test.dart @@ -43,11 +43,9 @@ main() { for (var i = 0; i < instances.length; i++) { var c = instances[i]; Expect.equals(c42, c); - if (i % 5 == 2 || i % 5 == 4) { - // The cases of C(42) without "new" are all constant. + if (i % 5 == 2) { Expect.identical(c42, c, "$i"); } else { - // The rest are not. Expect.notIdentical(c42, c, "$i"); } } diff --git a/tests/language_2/language_2.status b/tests/language_2/language_2.status index 8cb99833c28..1fb301eaa28 100644 --- a/tests/language_2/language_2.status +++ b/tests/language_2/language_2.status @@ -47,6 +47,25 @@ initializer_super_last_test: Crash, CompileTimeError # Issue 31321 [ $compiler != dart2js && $compiler != dartdevc && !$fasta && $strong ] type_promotion_functions_test: CompileTimeError # Issue 30895: This test requires a complete rewrite for 2.0. +# Detection of compile-time errors that are related to constants can't be fully +# done at the front end, because constants are evaluated at back ends. So, some +# errors aren't detected by fasta, but reported by back ends as compile-time +# errors. +[ $compiler != dart2js && $runtime != vm && $fasta ] +deferred_constraints_constants_test/default_argument2: MissingCompileTimeError +function_type_parameter2_negative_test: Fail +function_type_parameter_negative_test: Fail +implicit_creation/implicit_const_not_default_values_test/e12: MissingCompileTimeError +implicit_creation/implicit_const_not_default_values_test/e15: MissingCompileTimeError +implicit_creation/implicit_const_not_default_values_test/e18: MissingCompileTimeError +implicit_creation/implicit_const_not_default_values_test/e21: MissingCompileTimeError +implicit_creation/implicit_const_not_default_values_test/e24: MissingCompileTimeError +implicit_creation/implicit_const_not_default_values_test/e27: MissingCompileTimeError +implicit_creation/implicit_const_not_default_values_test/e3: MissingCompileTimeError +implicit_creation/implicit_const_not_default_values_test/e30: MissingCompileTimeError +implicit_creation/implicit_const_not_default_values_test/e6: MissingCompileTimeError +implicit_creation/implicit_const_not_default_values_test/e9: MissingCompileTimeError + [ $compiler != dart2js && !$fasta && $strong ] compile_time_constant_static5_test/11: CompileTimeError # Issue 30546 compile_time_constant_static5_test/16: CompileTimeError # Issue 30546 diff --git a/tests/language_2/language_2_dartdevc.status b/tests/language_2/language_2_dartdevc.status index 8b7ff2a9762..6ae8d4d6d09 100644 --- a/tests/language_2/language_2_dartdevc.status +++ b/tests/language_2/language_2_dartdevc.status @@ -72,6 +72,7 @@ implicit_creation/implicit_const_context_prefix_constructor_generic_named_test: implicit_creation/implicit_const_context_prefix_constructor_generic_test: CompileTimeError implicit_creation/implicit_new_or_const_composite_test: RuntimeError implicit_creation/implicit_new_or_const_generic_test: RuntimeError +implicit_creation/implicit_new_or_const_test: RuntimeError implicit_downcast_during_compound_assignment_test: RuntimeError implicit_downcast_during_indexed_compound_assignment_test: RuntimeError implicit_downcast_during_indexed_if_null_assignment_test: RuntimeError @@ -404,6 +405,8 @@ field_override_test/01: MissingCompileTimeError function_call_generic_test: RuntimeError # Issue 32756. Crashes on dsend function_propagation_test: RuntimeError function_subtype_closure0_test: RuntimeError # Expect.throws(TypeError) fails: Did not throw +function_type_parameter2_negative_test: Fail +function_type_parameter_negative_test: Fail generic_function_bounds_test: RuntimeError generic_methods_generic_function_result_test/01: MissingCompileTimeError generic_methods_recursive_bound_test/02: MissingCompileTimeError