Files
sdk/tests/language/metadata/constructor_new_error_test.dart
T
Johnni Winther dd3fbffac7 [cfe,analyzer] Support new as identifier in metadata
The parser didn't support 'new' as identifier in this context.

The CL also adds the reporting of tear-offs as metadata for the CFE.
This was already handled by the analyzer.

Change-Id: I7ab5868fa83e5f216d0e7be7ae9cec4a2c865e80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364480
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-04-26 14:00:04 +00:00

52 lines
2.4 KiB
Dart

// Copyright (c) 2024, 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 'constructor_new_error_test.dart' as self;
class Class {
const Class();
}
class GenericClass<X, Y> {
const GenericClass();
}
@Class.new
// [error column 1, length 10]
// [analyzer] COMPILE_TIME_ERROR.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS
// [error column 2]
// [cfe] This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor.
@GenericClass.new
// [error column 1, length 17]
// [analyzer] COMPILE_TIME_ERROR.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS
// [error column 2]
// [cfe] This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor.
@GenericClass<int, String>.new
// [error column 1, length 30]
// [analyzer] COMPILE_TIME_ERROR.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS
// [error column 2]
// [cfe] This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor.
// ^^^
// [analyzer] SYNTACTIC_ERROR.ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED
// [cfe] An annotation with type arguments must be followed by an argument list.
@self.Class.new
// [error column 1, length 15]
// [analyzer] COMPILE_TIME_ERROR.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS
// ^
// [cfe] This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor.
@self.GenericClass.new
// [error column 1, length 22]
// [analyzer] COMPILE_TIME_ERROR.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS
// ^
// [cfe] This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor.
@self.GenericClass<int, String>.new
// [error column 1, length 35]
// [analyzer] COMPILE_TIME_ERROR.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS
// ^
// [cfe] This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor.
// ^^^
// [analyzer] SYNTACTIC_ERROR.ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED
// [cfe] An annotation with type arguments must be followed by an argument list.
main() {}