[fasta] Disable upwards new/const completion
Change-Id: If2c14bf402bbcbacbf4cf2da351eb7234e1e0944 Reviewed-on: https://dart-review.googlesource.com/49900 Commit-Queue: Dmitry Stefantsov <dmitryas@google.com> Reviewed-by: Kevin Millikin <kmillikin@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
3d8524be3f
commit
0fedb9b9d8
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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<Null> 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<
|
||||
|
||||
@@ -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<Arguments> extends ScopeListener<JumpTarget>
|
||||
/// and where that was.
|
||||
Map<String, int> 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<Expression> constructorInvocationsWithImplicitConstness =
|
||||
new List<Expression>();
|
||||
|
||||
BodyBuilder(
|
||||
KernelLibraryBuilder library,
|
||||
this.member,
|
||||
@@ -497,8 +489,6 @@ class BodyBuilder<Arguments> extends ScopeListener<JumpTarget>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inferConstness();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -696,24 +686,6 @@ class BodyBuilder<Arguments> extends ScopeListener<JumpTarget>
|
||||
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<Arguments> extends ScopeListener<JumpTarget>
|
||||
@override
|
||||
void beginFormalParameterDefaultValueExpression() {
|
||||
super.push(constantContext);
|
||||
constantContext = ConstantContext.needsExplicitConst;
|
||||
constantContext = ConstantContext.none;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -2497,11 +2469,6 @@ class BodyBuilder<Arguments> extends ScopeListener<JumpTarget>
|
||||
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<Arguments> extends ScopeListener<JumpTarget>
|
||||
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<Arguments> extends ScopeListener<JumpTarget>
|
||||
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),
|
||||
|
||||
@@ -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()]);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>[]}) → dynamic {}
|
||||
static method foo({dynamic a = new self::Constant::•(), dynamic b = new self::Constant::•(), dynamic c = <dynamic>[]}) → 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 {}
|
||||
|
||||
@@ -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>[]}) → dynamic {}
|
||||
static method foo({dynamic a = new self::Constant::•(), dynamic b = new self::Constant::•(), dynamic c = <dynamic>[]}) → 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 {}
|
||||
|
||||
@@ -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>[]}) → dynamic {}
|
||||
static method foo({dynamic a = new self::Constant::•(), dynamic b = new self::Constant::•(), dynamic c = <dynamic>[]}) → 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 {}
|
||||
|
||||
@@ -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>[]}) → dynamic {}
|
||||
static method foo({dynamic a = new self::Constant::•(), dynamic b = new self::Constant::•(), dynamic c = <dynamic>[]}) → 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 {}
|
||||
|
||||
@@ -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");
|
||||
|
||||
+1
-1
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
+1
-1
@@ -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");
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 ]
|
||||
|
||||
@@ -29,12 +29,12 @@ main() {
|
||||
|
||||
const cd1 = const C(const D<int>(42));
|
||||
const cd2 = C(D<int>(42)); // Const context.
|
||||
var cd3 = C(D<int>(42)); // All constant, even in non-const context.
|
||||
var cd4 = C(D<int>(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<int>(42)); // Non-constant context, so `new`.
|
||||
var cd4 = C(D<int>(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 <int>[37]); // Constant context.
|
||||
const cl4 = C(<int>[37]);
|
||||
var cl5 = C(clist); // Constant argument, so const.
|
||||
var cl6 = C(const <int>[37]); // Constant arg, so const.
|
||||
var cl7 = C(list); // Non-constant arg.
|
||||
var cl8 = C(<int>[37]); // Same if literal.
|
||||
var cl5 = C(clist); // Non-constant context, so `new`.
|
||||
var cl6 = C(const <int>[37]); // Non-constant context, so `new`.
|
||||
var cl7 = C(list); // Non-constant context, so `new`.
|
||||
var cl8 = C(<int>[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 <int, int>{19: 87}); // Constant context.
|
||||
const cm3 = C(<int, int>{19: 87}); // Constant context.
|
||||
var cm4 = C(cmap); // Constant argument, so const.
|
||||
var cm5 = C(const <int, int>{19: 87}); // Constant arg, so const.
|
||||
var cm6 = C(map); // Non-constant arg, non-const context.
|
||||
var cm7 = C(<int, int>{19: 87}); // Same if literal.
|
||||
var cm4 = C(cmap); // Non-constant context, so `new`.
|
||||
var cm5 = C(const <int, int>{19: 87}); // Non-constant context, so `new`.
|
||||
var cm6 = C(map); // Non-constant context, so `new`.
|
||||
var cm7 = C(<int, int>{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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user