8de8a1c226
They are all errors now. Change-Id: If48d38e38e845fd5b5a950dd5514bf1cbbce03d8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155880 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
111 lines
4.5 KiB
Dart
111 lines
4.5 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()
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] Cannot use '?.' here.
|
|
// ^
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
;
|
|
|
|
test() {
|
|
super?.field = 1;
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
super?.field += 1;
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
super?.field ??= 1;
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
super?.field;
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
1 * super?.field;
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
-super?.field;
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
~super?.field;
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
!super?.field;
|
|
// ^^^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.NON_BOOL_NEGATION_EXPRESSION
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
// ^
|
|
// [cfe] A value of type 'int' can't be assigned to a variable of type 'bool'.
|
|
--super?.field;
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
++super?.field;
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
super?.method();
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
1 * super?.method();
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
-super?.method();
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
~super?.method();
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
!super?.method();
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
--super?.method();
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
// ^
|
|
// [cfe] Can't assign to this.
|
|
// ^
|
|
// [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
|
|
++super?.method();
|
|
// ^^
|
|
// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
|
|
// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
|
|
// ^
|
|
// [cfe] Can't assign to this.
|
|
// ^
|
|
// [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
|
|
}
|
|
}
|
|
|
|
main() {
|
|
new C().test();
|
|
}
|