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

Unified Diff: pkg/analyzer/test/generated/compile_time_error_code_test.dart

Issue 1620963003: final fields shouldn't be dependencies of const variables (Closed) Base URL: git@github.com:dart-lang/sdk.git@movetest
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | pkg/analyzer/test/generated/constant_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/compile_time_error_code_test.dart
diff --git a/pkg/analyzer/test/generated/compile_time_error_code_test.dart b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
index 5f2abf5255e11f92317a1ebba3917166fee88343..b12692efd096262f396e3c1be88b7d484cfef487 100644
--- a/pkg/analyzer/test/generated/compile_time_error_code_test.dart
+++ b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
@@ -897,7 +897,8 @@ int f() {
// TODO(paulberry): the error CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE is
// redundant and ought to be suppressed.
assertErrors(source, [
- CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
+ CompileTimeErrorCode
+ .CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
]);
verify([source]);
@@ -1265,6 +1266,18 @@ f(p) {
verify([source]);
}
+ void test_constInitializedWithNonConstValue_finalField() {
Brian Wilkerson 2016/01/23 17:32:26 Seems like we ought to have at least one test of t
skybrian 2016/01/26 02:07:14 This test is implicitly a regression test. It show
+ Source source = addSource(r'''
+class Foo {
+ final field = [];
+ foo([int x = field]) {}
+}
+''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
+ verify([source]);
+ }
+
void test_constInitializedWithNonConstValue_missingConstInListLiteral() {
Source source = addSource("const List L = [0];");
computeLibrarySourceErrors(source);
@@ -1291,7 +1304,8 @@ library root;
import 'lib1.dart' deferred as a;
const B = a.V;'''
], <ErrorCode>[
- CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY
+ CompileTimeErrorCode
skybrian 2016/01/23 04:07:36 I believe this is reversing a dartfmt I did with a
Brian Wilkerson 2016/01/23 17:32:26 No problem. It's unavoidable.
+ .CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY
]);
}
@@ -1305,7 +1319,8 @@ library root;
import 'lib1.dart' deferred as a;
const B = a.V + 1;'''
], <ErrorCode>[
- CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY
+ CompileTimeErrorCode
+ .CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY
]);
}
@@ -1827,7 +1842,8 @@ class B extends A {
verify([source]);
}
- void test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter() {
+ void
+ test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter() {
Source source = addSource(r'''
abstract class A {
int get x;
@@ -1855,7 +1871,8 @@ class B extends A {
verify([source]);
}
- void test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod() {
+ void
+ test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod() {
Source source = addSource(r'''
abstract class A {
x();
@@ -1883,7 +1900,8 @@ class B extends A {
verify([source]);
}
- void test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter() {
+ void
+ test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter() {
Source source = addSource(r'''
abstract class A {
set x(value);
@@ -1967,9 +1985,7 @@ class C = a.A with M;'''
void test_extendsDisallowedClass_class_double() {
Source source = addSource("class A extends double {}");
computeLibrarySourceErrors(source);
- assertErrors(source, [
- CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS
- ]);
+ assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
@@ -1996,9 +2012,7 @@ class C = a.A with M;'''
void test_extendsDisallowedClass_class_num() {
Source source = addSource("class A extends num {}");
computeLibrarySourceErrors(source);
- assertErrors(source, [
- CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS
- ]);
+ assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
@@ -2638,7 +2652,8 @@ class A {
verify([source]);
}
- void test_implicitThisReferenceInInitializer_redirectingConstructorInvocation() {
+ void
+ test_implicitThisReferenceInInitializer_redirectingConstructorInvocation() {
Source source = addSource(r'''
class A {
A(p) {}
@@ -3004,7 +3019,8 @@ main() {
verify([source]);
}
- void test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocation() {
+ void
+ test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocation() {
addNamedSource(
"/lib.dart",
r'''
@@ -4653,7 +4669,8 @@ class A {
const A() : x = a.c;
}'''
], <ErrorCode>[
- CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
+ CompileTimeErrorCode
+ .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
]);
}
@@ -4670,7 +4687,8 @@ class A {
const A() : x = a.c + 1;
}'''
], <ErrorCode>[
- CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
+ CompileTimeErrorCode
+ .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
]);
}
@@ -4687,7 +4705,8 @@ class A {
const A() : this.named(a.c);
}'''
], <ErrorCode>[
- CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
+ CompileTimeErrorCode
+ .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
]);
}
@@ -4706,7 +4725,8 @@ class B extends A {
const B() : super(a.c);
}'''
], <ErrorCode>[
- CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
+ CompileTimeErrorCode
+ .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
]);
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | pkg/analyzer/test/generated/constant_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698