dart-sdk/tests/language/super_conditional_operator_test.dart
Paul Berry 4b83219847 Switch on null-aware operators by default in analyzer.
Patches to update analyzer_cli and analysis_server will follow once a
new version of analyzer has been published.

BUG=dartbug.com/23793
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1239513005 .
2015-07-13 15:56:21 -07:00

43 lines
1.3 KiB
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.
// Verify that the ?. operator cannot be used with "super".
class B {
B();
B.namedConstructor();
var field = 1;
method() => 1;
}
class C extends B {
C()
: super?.namedConstructor() /// 01: compile-time error
;
test() {
super?.field = 1; /// 02: compile-time error
super?.field += 1; /// 03: compile-time error
super?.field ??= 1; /// 04: compile-time error
super?.field; /// 05: compile-time error
1 * super?.field; /// 06: compile-time error
-super?.field; /// 07: compile-time error
~super?.field; /// 08: compile-time error
!super?.field; /// 09: compile-time error
--super?.field; /// 10: compile-time error
++super?.field; /// 11: compile-time error
super?.method(); /// 12: compile-time error
1 * super?.method(); /// 13: compile-time error
-super?.method(); /// 14: compile-time error
~super?.method(); /// 15: compile-time error
!super?.method(); /// 16: compile-time error
--super?.method(); /// 17: compile-time error
++super?.method(); /// 18: compile-time error
}
}
main() {
new C().test();
}