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

Unified Diff: pkg/analyzer/test/src/task/strong/checker_test.dart

Issue 2352433002: support `@virtual` fields, fix #27384 (Closed)
Patch Set: Created 4 years, 3 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/task/strong_mode.dart ('k') | pkg/meta/CHANGELOG.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/strong/checker_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/checker_test.dart b/pkg/analyzer/test/src/task/strong/checker_test.dart
index e647d641107432af6d547cd42d5b40d9a65e1f3d..ae8ba3a29286512e5e7081e6664cb95531cfdfd0 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -540,8 +540,18 @@ class A {
get foo => '';
set foo(_) {}
}
+
class B extends A {
- @checked int foo;
+ @checked num foo;
+}
+class C extends A {
+ @checked @virtual num foo;
+}
+class D extends C {
+ @virtual int foo;
+}
+class E extends D {
+ @virtual /*error:INVALID_METHOD_OVERRIDE*/num foo;
}
''');
}
@@ -752,6 +762,36 @@ class H implements F {
''');
}
+ void test_fieldOverride_virtual() {
+ _addMetaLibrary();
+ checkFile(r'''
+import 'meta.dart';
+class C {
+ @virtual int x;
+}
+class OverrideGetter extends C {
+ int get x => 42;
+}
+class OverrideSetter extends C {
+ set x(int v) {}
+}
+class OverrideBoth extends C {
+ int get x => 42;
+ set x(int v) {}
+}
+class OverrideWithField extends C {
+ int x;
+
+ // expose the hidden storage slot
+ int get superX => super.x;
+ set superX(int v) { super.x = v; }
+}
+class VirtualNotInherited extends OverrideWithField {
+ /*error:INVALID_FIELD_OVERRIDE*/int x;
+}
+ ''');
+ }
+
void test_fieldSetterOverride() {
checkFile('''
class A {}
@@ -3876,5 +3916,8 @@ void _addMetaLibrary() {
library meta;
class _Checked { const _Checked(); }
const Object checked = const _Checked();
+
+class _Virtual { const _Virtual(); }
+const Object virtual = const _Virtual();
''', name: '/meta.dart');
}
« no previous file with comments | « pkg/analyzer/lib/src/task/strong_mode.dart ('k') | pkg/meta/CHANGELOG.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698