2f3b889c7b
.length on JS arrays are not introduced yet because that is not seen as field accesses by our class hierarchy. I've changed the contract on Primitives so they can have side effects, depend on state, diverge, throw, anything goes. GetField on possibly null receivers would not be allowed otherwise. AFAIK there are no optimizations that actually used the contract on primitives, it just seemed like a good idea at one point in the past, so that change only affects a single doc comment. I'll migrate some of the classes that can now be primitives in another CL. BuiltinOperators are still required to be pure, although that too may possibly change soon. BUG= R=kmillikin@google.com Review URL: https://codereview.chromium.org//1188253006.
21 lines
433 B
Dart
21 lines
433 B
Dart
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
class Foo {
|
|
var field = 10;
|
|
}
|
|
|
|
@NoInline()
|
|
getField(x) {
|
|
x.field;
|
|
return 34;
|
|
}
|
|
|
|
main() {
|
|
Expect.equals(34, getField(new Foo()));
|
|
Expect.throws(() => getField(null));
|
|
}
|