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

Side by Side Diff: pkg/dev_compiler/test/codegen/lib/mirrors/private_field_test.dart

Issue 2535273002: Better mirrors support for mixins and private fields (Closed)
Patch Set: Address comments Created 4 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.mixin;
6
7 import 'dart:mirrors';
8
9 import 'package:expect/expect.dart';
10
11 import 'private_field_helper.dart';
12
13 class Foo extends Bar {
14 int _field = 42;
15
16 static int _staticField = 99;
17 }
18
19 var privateSymbol = #_field;
20 var publicSymbol = #field;
21
22 main() {
23 Expect.equals(publicSymbol, publicSymbol2);
24 Expect.notEquals(privateSymbol, privateSymbol2);
25
26 var foo = new Foo();
27 var m = reflect(foo);
28 m.setField(privateSymbol, 38);
29 Expect.equals(38, foo._field);
30 m.setField(privateSymbol2, "world");
31 Expect.equals("world", foo.field);
32 Expect.equals("world", m.getField(publicSymbol).reflectee);
33
34 var type = reflectClass(Foo);
35 Expect.equals(99, type.getField(#_staticField).reflectee);
36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698