[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>
This commit is contained in:
committed by
Commit Queue
parent
9b07891e4f
commit
dd3fbffac7
@@ -972,6 +972,9 @@ class MetadataReferenceIdentifierContext extends IdentifierContext {
|
||||
}
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get allowsNewAsIdentifier => isContinuation;
|
||||
}
|
||||
|
||||
/// See [IdentifierContext.methodDeclaration],
|
||||
|
||||
@@ -927,7 +927,8 @@ class BodyBuilder extends StackListenerImpl
|
||||
}
|
||||
|
||||
ConstantContext savedConstantContext = pop() as ConstantContext;
|
||||
if (expression is! StaticAccessGenerator &&
|
||||
if (!(expression is StaticAccessGenerator &&
|
||||
expression.readTarget is Field) &&
|
||||
expression is! VariableUseGenerator &&
|
||||
// TODO(johnniwinther): Stop using the type of the generator here.
|
||||
// Ask a property instead.
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// 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 'annotation_new.dart' as self;
|
||||
|
||||
const field = 1;
|
||||
|
||||
void method() {}
|
||||
|
||||
class Class {
|
||||
const Class();
|
||||
|
||||
static const field = 1;
|
||||
|
||||
static void method() {}
|
||||
}
|
||||
|
||||
class GenericClass<X, Y> {
|
||||
const GenericClass();
|
||||
}
|
||||
|
||||
@Class.new() // OK
|
||||
@GenericClass.new() // OK
|
||||
@GenericClass<int, String>.new() // OK
|
||||
@self.Class.new() // OK
|
||||
@self.GenericClass.new() // OK
|
||||
@self.GenericClass<int, String>.new() // OK
|
||||
@field // OK
|
||||
@self.field // OK
|
||||
@method // Error
|
||||
@self.method // Error
|
||||
@Class.field // OK
|
||||
@Class.method // Error
|
||||
@Class.new // Error
|
||||
@self.Class.field // OK
|
||||
@self.Class.method // Error
|
||||
@self.Class.new // Error
|
||||
main() {}
|
||||
@@ -0,0 +1,90 @@
|
||||
library;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
// @method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
// @Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
// @Class.new // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
import "org-dartlang-testcase:///annotation_new.dart" as self;
|
||||
|
||||
class Class extends core::Object /*hasConstConstructor*/ {
|
||||
static const field core::int field = #C1;
|
||||
const constructor •() → self::Class
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method method() → void {}
|
||||
}
|
||||
class GenericClass<X extends core::Object? = dynamic, Y extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
|
||||
const constructor •() → self::GenericClass<self::GenericClass::X%, self::GenericClass::Y%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
}
|
||||
static const field core::int field = #C1;
|
||||
static method method() → void {}
|
||||
@#C2
|
||||
@#C3
|
||||
@#C4
|
||||
@#C2
|
||||
@#C3
|
||||
@#C4
|
||||
@#C1
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
@method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
^"
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
@Class.method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
@Class.new // Error
|
||||
^"
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
^"
|
||||
static method main() → dynamic {}
|
||||
|
||||
constants {
|
||||
#C1 = 1
|
||||
#C2 = self::Class {}
|
||||
#C3 = self::GenericClass<dynamic, dynamic> {}
|
||||
#C4 = self::GenericClass<core::int, core::String> {}
|
||||
}
|
||||
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///annotation_new.dart:
|
||||
- Class. (from org-dartlang-testcase:///annotation_new.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
|
||||
- GenericClass. (from org-dartlang-testcase:///annotation_new.dart:20:9)
|
||||
@@ -0,0 +1,90 @@
|
||||
library;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
// @method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
// @Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
// @Class.new // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
import "org-dartlang-testcase:///annotation_new.dart" as self;
|
||||
|
||||
class Class extends core::Object /*hasConstConstructor*/ {
|
||||
static const field core::int field = #C1;
|
||||
const constructor •() → self::Class
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method method() → void {}
|
||||
}
|
||||
class GenericClass<X extends core::Object? = dynamic, Y extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
|
||||
const constructor •() → self::GenericClass<self::GenericClass::X%, self::GenericClass::Y%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
}
|
||||
static const field core::int field = #C1;
|
||||
static method method() → void {}
|
||||
@#C2
|
||||
@#C3
|
||||
@#C4
|
||||
@#C2
|
||||
@#C3
|
||||
@#C4
|
||||
@#C1
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
@method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
^"
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
@Class.method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
@Class.new // Error
|
||||
^"
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
^"
|
||||
static method main() → dynamic {}
|
||||
|
||||
constants {
|
||||
#C1 = 1
|
||||
#C2 = self::Class {}
|
||||
#C3 = self::GenericClass<dynamic, dynamic> {}
|
||||
#C4 = self::GenericClass<core::int, core::String> {}
|
||||
}
|
||||
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///annotation_new.dart:
|
||||
- Class. (from org-dartlang-testcase:///annotation_new.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
|
||||
- GenericClass. (from org-dartlang-testcase:///annotation_new.dart:20:9)
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'annotation_new.dart' as self;
|
||||
|
||||
const field = 1;
|
||||
|
||||
void method() {}
|
||||
|
||||
class Class {
|
||||
const Class();
|
||||
static const field = 1;
|
||||
static void method() {}
|
||||
}
|
||||
|
||||
class GenericClass<X, Y> {
|
||||
const GenericClass();
|
||||
}
|
||||
|
||||
@Class.new()
|
||||
@GenericClass.new()
|
||||
@GenericClass<int, String>.new()
|
||||
@self.Class.new()
|
||||
@self.GenericClass.new()
|
||||
@self.GenericClass<int, String>.new()
|
||||
@field
|
||||
@self.field
|
||||
@method
|
||||
@self.method
|
||||
@Class.field
|
||||
@Class.method
|
||||
@Class.new
|
||||
@self.Class.field
|
||||
@self.Class.method
|
||||
@self.Class.new
|
||||
main() {}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'annotation_new.dart' as self;
|
||||
|
||||
class Class {
|
||||
const Class();
|
||||
static const field = 1;
|
||||
static void method() {}
|
||||
}
|
||||
|
||||
class GenericClass<X, Y> {
|
||||
const GenericClass();
|
||||
}
|
||||
|
||||
const field = 1;
|
||||
|
||||
@Class.new()
|
||||
@GenericClass.new()
|
||||
@GenericClass<int, String>.new()
|
||||
@self.Class.new()
|
||||
@self.GenericClass.new()
|
||||
@self.GenericClass<int, String>.new()
|
||||
@field
|
||||
@self.field
|
||||
@method
|
||||
@self.method
|
||||
@Class.field
|
||||
@Class.method
|
||||
@Class.new
|
||||
@self.Class.field
|
||||
@self.Class.method
|
||||
@self.Class.new
|
||||
main() {}
|
||||
|
||||
void method() {}
|
||||
@@ -0,0 +1,90 @@
|
||||
library;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
// @method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
// @Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
// @Class.new // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
import "org-dartlang-testcase:///annotation_new.dart" as self;
|
||||
|
||||
class Class extends core::Object /*hasConstConstructor*/ {
|
||||
static const field core::int field = #C1;
|
||||
const constructor •() → self::Class
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method method() → void {}
|
||||
}
|
||||
class GenericClass<X extends core::Object? = dynamic, Y extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
|
||||
const constructor •() → self::GenericClass<self::GenericClass::X%, self::GenericClass::Y%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
}
|
||||
static const field core::int field = #C1;
|
||||
static method method() → void {}
|
||||
@#C2
|
||||
@#C3
|
||||
@#C4
|
||||
@#C2
|
||||
@#C3
|
||||
@#C4
|
||||
@#C1
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
@method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
^"
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
@Class.method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
@Class.new // Error
|
||||
^"
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
^"
|
||||
static method main() → dynamic {}
|
||||
|
||||
constants {
|
||||
#C1 = 1
|
||||
#C2 = self::Class {}
|
||||
#C3 = self::GenericClass<dynamic, dynamic> {}
|
||||
#C4 = self::GenericClass<core::int*, core::String*> {}
|
||||
}
|
||||
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///annotation_new.dart:
|
||||
- Class. (from org-dartlang-testcase:///annotation_new.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
|
||||
- GenericClass. (from org-dartlang-testcase:///annotation_new.dart:20:9)
|
||||
@@ -0,0 +1,90 @@
|
||||
library;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
// @method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
// @Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
// @Class.new // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
import "org-dartlang-testcase:///annotation_new.dart" as self;
|
||||
|
||||
class Class extends core::Object /*hasConstConstructor*/ {
|
||||
static const field core::int field = #C1;
|
||||
const constructor •() → self::Class
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method method() → void {}
|
||||
}
|
||||
class GenericClass<X extends core::Object? = dynamic, Y extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
|
||||
const constructor •() → self::GenericClass<self::GenericClass::X%, self::GenericClass::Y%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
}
|
||||
static const field core::int field = #C1;
|
||||
static method method() → void {}
|
||||
@#C2
|
||||
@#C3
|
||||
@#C4
|
||||
@#C2
|
||||
@#C3
|
||||
@#C4
|
||||
@#C1
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
@method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
^"
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
@Class.method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
@Class.new // Error
|
||||
^"
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
^"
|
||||
static method main() → dynamic {}
|
||||
|
||||
constants {
|
||||
#C1 = 1
|
||||
#C2 = self::Class {}
|
||||
#C3 = self::GenericClass<dynamic, dynamic> {}
|
||||
#C4 = self::GenericClass<core::int*, core::String*> {}
|
||||
}
|
||||
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///annotation_new.dart:
|
||||
- Class. (from org-dartlang-testcase:///annotation_new.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
|
||||
- GenericClass. (from org-dartlang-testcase:///annotation_new.dart:20:9)
|
||||
@@ -0,0 +1,93 @@
|
||||
library;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
// @method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
// @Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
// @Class.new // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
import "org-dartlang-testcase:///annotation_new.dart" as self;
|
||||
|
||||
class Class extends core::Object /*hasConstConstructor*/ {
|
||||
static const field core::int field = 1;
|
||||
const constructor •() → self::Class
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method method() → void
|
||||
;
|
||||
}
|
||||
class GenericClass<X extends core::Object? = dynamic, Y extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
|
||||
const constructor •() → self::GenericClass<self::GenericClass::X%, self::GenericClass::Y%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
}
|
||||
static const field core::int field = 1;
|
||||
static method method() → void
|
||||
;
|
||||
@self::Class::•()
|
||||
@self::GenericClass::•<dynamic, dynamic>()
|
||||
@self::GenericClass::•<core::int, core::String>()
|
||||
@self::Class::•()
|
||||
@self::GenericClass::•<dynamic, dynamic>()
|
||||
@self::GenericClass::•<core::int, core::String>()
|
||||
@self::field
|
||||
@self::field
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
@method // Error
|
||||
^" in self::method
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
^" in self::method
|
||||
@self::Class::field
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
@Class.method // Error
|
||||
^" in self::Class::method
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
@Class.new // Error
|
||||
^" in self::Class::•
|
||||
@self::Class::field
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
^" in self::Class::method
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
^" in self::Class::•
|
||||
static method main() → dynamic
|
||||
;
|
||||
|
||||
|
||||
Extra constant evaluation status:
|
||||
Evaluated: ConstructorInvocation @ org-dartlang-testcase:///annotation_new.dart:23:2 -> InstanceConstant(const Class{})
|
||||
Evaluated: ConstructorInvocation @ org-dartlang-testcase:///annotation_new.dart:24:2 -> InstanceConstant(const GenericClass<dynamic, dynamic>{})
|
||||
Evaluated: ConstructorInvocation @ org-dartlang-testcase:///annotation_new.dart:25:2 -> InstanceConstant(const GenericClass<int*, String*>{})
|
||||
Evaluated: ConstructorInvocation @ org-dartlang-testcase:///annotation_new.dart:26:2 -> InstanceConstant(const Class{})
|
||||
Evaluated: ConstructorInvocation @ org-dartlang-testcase:///annotation_new.dart:27:2 -> InstanceConstant(const GenericClass<dynamic, dynamic>{})
|
||||
Evaluated: ConstructorInvocation @ org-dartlang-testcase:///annotation_new.dart:28:2 -> InstanceConstant(const GenericClass<int*, String*>{})
|
||||
Evaluated: StaticGet @ org-dartlang-testcase:///annotation_new.dart:29:2 -> IntConstant(1)
|
||||
Evaluated: StaticGet @ org-dartlang-testcase:///annotation_new.dart:30:7 -> IntConstant(1)
|
||||
Evaluated: StaticGet @ org-dartlang-testcase:///annotation_new.dart:33:8 -> IntConstant(1)
|
||||
Evaluated: StaticGet @ org-dartlang-testcase:///annotation_new.dart:36:13 -> IntConstant(1)
|
||||
Extra constant evaluation: evaluated: 10, effectively constant: 10
|
||||
@@ -0,0 +1,90 @@
|
||||
library;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
// @method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
// @Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
// @Class.new // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
import "org-dartlang-testcase:///annotation_new.dart" as self;
|
||||
|
||||
class Class extends core::Object /*hasConstConstructor*/ {
|
||||
static const field core::int field = #C1;
|
||||
const constructor •() → self::Class
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method method() → void {}
|
||||
}
|
||||
class GenericClass<X extends core::Object? = dynamic, Y extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
|
||||
const constructor •() → self::GenericClass<self::GenericClass::X%, self::GenericClass::Y%>
|
||||
: super core::Object::•()
|
||||
;
|
||||
}
|
||||
static const field core::int field = #C1;
|
||||
static method method() → void {}
|
||||
@#C2
|
||||
@#C3
|
||||
@#C4
|
||||
@#C2
|
||||
@#C3
|
||||
@#C4
|
||||
@#C1
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:31:2: Error: 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.
|
||||
@method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:32:7: Error: 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.method // Error
|
||||
^"
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:34:8: Error: 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.
|
||||
@Class.method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:35:2: Error: 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.
|
||||
@Class.new // Error
|
||||
^"
|
||||
@#C1
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:37:13: Error: 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.Class.method // Error
|
||||
^"
|
||||
@invalid-expression "pkg/front_end/testcases/general/annotation_new.dart:38:7: Error: 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.Class.new // Error
|
||||
^"
|
||||
static method main() → dynamic {}
|
||||
|
||||
constants {
|
||||
#C1 = 1
|
||||
#C2 = self::Class {}
|
||||
#C3 = self::GenericClass<dynamic, dynamic> {}
|
||||
#C4 = self::GenericClass<core::int*, core::String*> {}
|
||||
}
|
||||
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///annotation_new.dart:
|
||||
- Class. (from org-dartlang-testcase:///annotation_new.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
|
||||
- GenericClass. (from org-dartlang-testcase:///annotation_new.dart:20:9)
|
||||
@@ -0,0 +1,51 @@
|
||||
// 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() {}
|
||||
@@ -0,0 +1,21 @@
|
||||
// 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_test.dart' as self;
|
||||
|
||||
class Class {
|
||||
const Class();
|
||||
}
|
||||
|
||||
class GenericClass<X, Y> {
|
||||
const GenericClass();
|
||||
}
|
||||
|
||||
@Class.new()
|
||||
@GenericClass.new()
|
||||
@GenericClass<int, String>.new()
|
||||
@self.Class.new()
|
||||
@self.GenericClass.new()
|
||||
@self.GenericClass<int, String>.new()
|
||||
main() {}
|
||||
@@ -117,6 +117,8 @@ class Q {}
|
||||
@V.tearOff
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_ANNOTATION
|
||||
// ^
|
||||
// [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.
|
||||
class V {
|
||||
static tearOff() {}
|
||||
}
|
||||
@@ -126,6 +128,8 @@ topLevelTearOff() => 4;
|
||||
@topLevelTearOff
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_ANNOTATION
|
||||
// ^
|
||||
// [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.
|
||||
class W {}
|
||||
|
||||
@TypeParameter
|
||||
@@ -254,7 +258,7 @@ class JJ {}
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_ANNOTATION
|
||||
// ^
|
||||
// [cfe] Constant evaluation error:
|
||||
// [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.
|
||||
class KK {
|
||||
const KK();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user