mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 14:32:49 +00:00
cf33b82c6c
This is a follow-up to https://code.google.com/p/dart/source/detail?r=26519, as there where more tests checking assignments to final variables. Changed the negative tests to multi-tests for running with the analyzer(s). The latest spec (0.51) says: Attempting to assign to a final variable anywhere except in its declaration or in a constructor header will cause a runtime error to be thrown as discussed below. The assignment will also give rise to a static warning. R=ricow@google.com BUG=7062, 11591, 12184 Review URL: https://codereview.chromium.org//23112017 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26583 260f80e4-7a28-3924-810f-c04153c831b5
15 lines
397 B
Dart
15 lines
397 B
Dart
// Copyright (c) 2011, 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.
|
|
// Disallow assignment of parameters marked as final.
|
|
|
|
class A {
|
|
static void test(final x) {
|
|
x = 2; /// 01: static type warning, runtime error
|
|
}
|
|
}
|
|
|
|
main() {
|
|
A.test(1);
|
|
}
|