Test various uses of type variables
Change-Id: I579f4ba5dce3a4e1ff8be3afb6ab8b5814108496
Reviewed-on: https://dart-review.googlesource.com/72102
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
diff --git a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
index dbaa982..1e4d3a4 100644
--- a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
+++ b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
@@ -7031,38 +7031,15 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<
- Message Function(
- String name,
- DartType
- _type)> templateTypeVariableInConstExpression = const Template<
- Message Function(String name, DartType _type)>(
- messageTemplate:
- r"""Type variable '#name' can't be used as a constant expression '#type'.""",
- withArguments: _withArgumentsTypeVariableInConstExpression);
+const Code<Null> codeTypeVariableInConstantContext =
+ messageTypeVariableInConstantContext;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(String name, DartType _type)>
- codeTypeVariableInConstExpression =
- const Code<Message Function(String name, DartType _type)>(
- "TypeVariableInConstExpression", templateTypeVariableInConstExpression,
- analyzerCode: "TYPE_PARAMETER_IN_CONST_EXPRESSION",
- severity: Severity.error);
-
-// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsTypeVariableInConstExpression(
- String name, DartType _type) {
- NameSystem nameSystem = new NameSystem();
- StringBuffer buffer;
- buffer = new StringBuffer();
- new Printer(buffer, syntheticNames: nameSystem).writeNode(_type);
- String type = '$buffer';
-
- return new Message(codeTypeVariableInConstExpression,
- message:
- """Type variable '${name}' can't be used as a constant expression '${type}'.""",
- arguments: {'name': name, 'type': _type});
-}
+const MessageCode messageTypeVariableInConstantContext = const MessageCode(
+ "TypeVariableInConstantContext",
+ analyzerCode: "TYPE_PARAMETER_IN_CONST_EXPRESSION",
+ severity: Severity.error,
+ message: r"""Type variables can't be used as constants.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeTypeVariableInStaticContext =
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 8e4ddfc..40d1b37 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -4415,12 +4415,8 @@
}
return const InvalidType();
} else if (constantContext != ConstantContext.none) {
- int length = type.parameter.name.length;
- addCompileTimeError(
- fasta.templateTypeVariableInConstExpression
- .withArguments(type.parameter.name, type),
- offset,
- length);
+ addProblem(fasta.messageTypeVariableInConstantContext, offset,
+ type.parameter.name.length);
}
return type;
}
diff --git a/pkg/front_end/messages.status b/pkg/front_end/messages.status
index 96edfeb..eaac01d 100644
--- a/pkg/front_end/messages.status
+++ b/pkg/front_end/messages.status
@@ -336,7 +336,9 @@
TypeArgumentsOnTypeVariable/script1: Fail
TypeNotFound/example: Fail
TypeVariableDuplicatedName/example: Fail
-TypeVariableInConstExpression/example: Fail
+TypeVariableInConstantContext/declaration1: Fail
+TypeVariableInConstantContext/declaration2: Fail
+TypeVariableInConstantContext/declaration3: Fail
TypeVariableInStaticContext/example: Fail
TypeVariableSameNameAsEnclosing/example: Fail
TypedefNotFunction/example: Fail
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index a11cd7f..fe4e2fb 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -2180,16 +2180,35 @@
template: "'#name' was initialized here."
severity: CONTEXT
-TypeVariableInConstExpression:
- template: "Type variable '#name' can't be used as a constant expression '#type'."
- severity: ERROR
- analyzerCode: TYPE_PARAMETER_IN_CONST_EXPRESSION
-
TypeVariableInStaticContext:
template: "Type variables can't be used in static members."
severity: ERROR_LEGACY_WARNING
analyzerCode: TYPE_PARAMETER_REFERENCED_BY_STATIC
+TypeVariableInConstantContext:
+ template: "Type variables can't be used as constants."
+ severity: ERROR
+ analyzerCode: TYPE_PARAMETER_IN_CONST_EXPRESSION
+ declaration:
+ - |
+ class C<T> {
+ instanceMethod() {
+ return const <Object>[T];
+ }
+ }
+ - |
+ class C<T> {
+ instanceMethod() {
+ return const <T>[null];
+ }
+ }
+ - |
+ class C<T> {
+ instanceMethod() {
+ return const <List<T>>[null];
+ }
+ }
+
SuperclassMethodArgumentMismatch:
template: "Superclass doesn't have a method named '#name' with matching arguments."
severity: ERROR_LEGACY_WARNING
diff --git a/pkg/front_end/testcases/type_variable_uses.dart b/pkg/front_end/testcases/type_variable_uses.dart
new file mode 100644
index 0000000..a366ce6
--- /dev/null
+++ b/pkg/front_end/testcases/type_variable_uses.dart
@@ -0,0 +1,32 @@
+// Copyright (c) 2018, 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.
+
+class C<T> {
+ const C();
+ static C<T> staticMethod() {
+ print(T);
+ T t;
+ C<T> l;
+ C<C<T>> ll;
+ const C<T>();
+ const <T>[];
+ const <C<T>>[];
+ const <Object>[T];
+ const <Object>[const C<T>()];
+ }
+
+ C<T> instanceMethod() {
+ print(T);
+ T t;
+ C<T> l;
+ C<C<T>> ll;
+ const C<T>();
+ const <T>[];
+ const <C<T>>[];
+ const <Object>[T];
+ const <Object>[const C<T>()];
+ }
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/type_variable_uses.dart.direct.expect b/pkg/front_end/testcases/type_variable_uses.dart.direct.expect
new file mode 100644
index 0000000..a22eb9c
--- /dev/null
+++ b/pkg/front_end/testcases/type_variable_uses.dart.direct.expect
@@ -0,0 +1,118 @@
+// Errors:
+//
+// pkg/front_end/testcases/type_variable_uses.dart:8:11: Error: Type variables can't be used in static members.
+// print(T);
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:12:13: Error: Not a constant expression.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:12:13: Error: Type variables can't be used in static members.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:13:12: Error: Not a constant expression.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:13:12: Error: Type variables can't be used in static members.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:14:14: Error: Not a constant expression.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:14:14: Error: Type variables can't be used in static members.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:15:20: Error: Not a constant expression.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:15:20: Error: Type variables can't be used in static members.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:16:28: Error: Not a constant expression.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:16:28: Error: Type variables can't be used in static members.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:24:13: Error: Not a constant expression.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:24:13: Error: Type variables can't be used as constants.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:25:12: Error: Not a constant expression.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:25:12: Error: Type variables can't be used as constants.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:26:14: Error: Not a constant expression.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:26:14: Error: Type variables can't be used as constants.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:27:20: Error: Not a constant expression.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:27:20: Error: Type variables can't be used as constants.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:28:28: Error: Not a constant expression.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:28:28: Error: Type variables can't be used as constants.
+// const <Object>[const C<T>()];
+// ^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class C<T extends core::Object = dynamic> extends core::Object {
+ const constructor •() → void
+ : super core::Object::•()
+ ;
+ static method staticMethod() → self::C<dynamic> {
+ core::print(invalid-type);
+ invalid-type t;
+ self::C<invalid-type> l;
+ self::C<self::C<invalid-type>> ll;
+ const self::C::•<invalid-type>();
+ const <invalid-type>[];
+ const <self::C<invalid-type>>[];
+ const <core::Object>[invalid-type];
+ const <core::Object>[const self::C::•<invalid-type>()];
+ }
+ method instanceMethod() → self::C<self::C::T> {
+ core::print(self::C::T);
+ self::C::T t;
+ self::C<self::C::T> l;
+ self::C<self::C<self::C::T>> ll;
+ const self::C::•<self::C::T>();
+ const <self::C::T>[];
+ const <self::C<self::C::T>>[];
+ const <core::Object>[self::C::T];
+ const <core::Object>[const self::C::•<self::C::T>()];
+ }
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/type_variable_uses.dart.direct.transformed.expect b/pkg/front_end/testcases/type_variable_uses.dart.direct.transformed.expect
new file mode 100644
index 0000000..a22eb9c
--- /dev/null
+++ b/pkg/front_end/testcases/type_variable_uses.dart.direct.transformed.expect
@@ -0,0 +1,118 @@
+// Errors:
+//
+// pkg/front_end/testcases/type_variable_uses.dart:8:11: Error: Type variables can't be used in static members.
+// print(T);
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:12:13: Error: Not a constant expression.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:12:13: Error: Type variables can't be used in static members.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:13:12: Error: Not a constant expression.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:13:12: Error: Type variables can't be used in static members.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:14:14: Error: Not a constant expression.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:14:14: Error: Type variables can't be used in static members.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:15:20: Error: Not a constant expression.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:15:20: Error: Type variables can't be used in static members.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:16:28: Error: Not a constant expression.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:16:28: Error: Type variables can't be used in static members.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:24:13: Error: Not a constant expression.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:24:13: Error: Type variables can't be used as constants.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:25:12: Error: Not a constant expression.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:25:12: Error: Type variables can't be used as constants.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:26:14: Error: Not a constant expression.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:26:14: Error: Type variables can't be used as constants.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:27:20: Error: Not a constant expression.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:27:20: Error: Type variables can't be used as constants.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:28:28: Error: Not a constant expression.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:28:28: Error: Type variables can't be used as constants.
+// const <Object>[const C<T>()];
+// ^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class C<T extends core::Object = dynamic> extends core::Object {
+ const constructor •() → void
+ : super core::Object::•()
+ ;
+ static method staticMethod() → self::C<dynamic> {
+ core::print(invalid-type);
+ invalid-type t;
+ self::C<invalid-type> l;
+ self::C<self::C<invalid-type>> ll;
+ const self::C::•<invalid-type>();
+ const <invalid-type>[];
+ const <self::C<invalid-type>>[];
+ const <core::Object>[invalid-type];
+ const <core::Object>[const self::C::•<invalid-type>()];
+ }
+ method instanceMethod() → self::C<self::C::T> {
+ core::print(self::C::T);
+ self::C::T t;
+ self::C<self::C::T> l;
+ self::C<self::C<self::C::T>> ll;
+ const self::C::•<self::C::T>();
+ const <self::C::T>[];
+ const <self::C<self::C::T>>[];
+ const <core::Object>[self::C::T];
+ const <core::Object>[const self::C::•<self::C::T>()];
+ }
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/type_variable_uses.dart.outline.expect b/pkg/front_end/testcases/type_variable_uses.dart.outline.expect
new file mode 100644
index 0000000..c58ea8f
--- /dev/null
+++ b/pkg/front_end/testcases/type_variable_uses.dart.outline.expect
@@ -0,0 +1,14 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class C<T extends core::Object = dynamic> extends core::Object {
+ const constructor •() → void
+ ;
+ static method staticMethod() → self::C<dynamic>
+ ;
+ method instanceMethod() → self::C<self::C::T>
+ ;
+}
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/type_variable_uses.dart.strong.expect b/pkg/front_end/testcases/type_variable_uses.dart.strong.expect
new file mode 100644
index 0000000..83deeb2
--- /dev/null
+++ b/pkg/front_end/testcases/type_variable_uses.dart.strong.expect
@@ -0,0 +1,134 @@
+// Errors:
+//
+// pkg/front_end/testcases/type_variable_uses.dart:7:15: Error: Can only use type variables in instance methods.
+// static C<T> staticMethod() {
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:8:11: Error: Type variables can't be used in static members.
+// print(T);
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:9:5: Error: Type variables can't be used in static members.
+// T t;
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:10:7: Error: Type variables can't be used in static members.
+// C<T> l;
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:11:9: Error: Type variables can't be used in static members.
+// C<C<T>> ll;
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:12:13: Error: Not a constant expression.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:12:13: Error: Type variables can't be used in static members.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:13:12: Error: Not a constant expression.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:13:12: Error: Type variables can't be used in static members.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:14:14: Error: Not a constant expression.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:14:14: Error: Type variables can't be used in static members.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:15:20: Error: Not a constant expression.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:15:20: Error: Type variables can't be used in static members.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:16:28: Error: Not a constant expression.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:16:28: Error: Type variables can't be used in static members.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:24:13: Error: Not a constant expression.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:24:13: Error: Type variables can't be used as constants.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:25:12: Error: Not a constant expression.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:25:12: Error: Type variables can't be used as constants.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:26:14: Error: Not a constant expression.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:26:14: Error: Type variables can't be used as constants.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:27:20: Error: Not a constant expression.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:27:20: Error: Type variables can't be used as constants.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:28:28: Error: Not a constant expression.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:28:28: Error: Type variables can't be used as constants.
+// const <Object>[const C<T>()];
+// ^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class C<T extends core::Object = dynamic> extends core::Object {
+ const constructor •() → void
+ : super core::Object::•()
+ ;
+ static method staticMethod() → self::C<dynamic> {
+ core::print(invalid-type);
+ invalid-type t;
+ self::C<invalid-type> l;
+ self::C<self::C<invalid-type>> ll;
+ const self::C::•<invalid-type>();
+ const <invalid-type>[];
+ const <self::C<invalid-type>>[];
+ const <core::Object>[invalid-type];
+ const <core::Object>[const self::C::•<invalid-type>()];
+ }
+ method instanceMethod() → self::C<self::C::T> {
+ core::print(self::C::T);
+ self::C::T t;
+ self::C<self::C::T> l;
+ self::C<self::C<self::C::T>> ll;
+ const self::C::•<self::C::T>();
+ const <self::C::T>[];
+ const <self::C<self::C::T>>[];
+ const <core::Object>[self::C::T];
+ const <core::Object>[const self::C::•<self::C::T>()];
+ }
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/type_variable_uses.dart.strong.transformed.expect b/pkg/front_end/testcases/type_variable_uses.dart.strong.transformed.expect
new file mode 100644
index 0000000..83deeb2
--- /dev/null
+++ b/pkg/front_end/testcases/type_variable_uses.dart.strong.transformed.expect
@@ -0,0 +1,134 @@
+// Errors:
+//
+// pkg/front_end/testcases/type_variable_uses.dart:7:15: Error: Can only use type variables in instance methods.
+// static C<T> staticMethod() {
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:8:11: Error: Type variables can't be used in static members.
+// print(T);
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:9:5: Error: Type variables can't be used in static members.
+// T t;
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:10:7: Error: Type variables can't be used in static members.
+// C<T> l;
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:11:9: Error: Type variables can't be used in static members.
+// C<C<T>> ll;
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:12:13: Error: Not a constant expression.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:12:13: Error: Type variables can't be used in static members.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:13:12: Error: Not a constant expression.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:13:12: Error: Type variables can't be used in static members.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:14:14: Error: Not a constant expression.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:14:14: Error: Type variables can't be used in static members.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:15:20: Error: Not a constant expression.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:15:20: Error: Type variables can't be used in static members.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:16:28: Error: Not a constant expression.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:16:28: Error: Type variables can't be used in static members.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:24:13: Error: Not a constant expression.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:24:13: Error: Type variables can't be used as constants.
+// const C<T>();
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:25:12: Error: Not a constant expression.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:25:12: Error: Type variables can't be used as constants.
+// const <T>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:26:14: Error: Not a constant expression.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:26:14: Error: Type variables can't be used as constants.
+// const <C<T>>[];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:27:20: Error: Not a constant expression.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:27:20: Error: Type variables can't be used as constants.
+// const <Object>[T];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:28:28: Error: Not a constant expression.
+// const <Object>[const C<T>()];
+// ^
+//
+// pkg/front_end/testcases/type_variable_uses.dart:28:28: Error: Type variables can't be used as constants.
+// const <Object>[const C<T>()];
+// ^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class C<T extends core::Object = dynamic> extends core::Object {
+ const constructor •() → void
+ : super core::Object::•()
+ ;
+ static method staticMethod() → self::C<dynamic> {
+ core::print(invalid-type);
+ invalid-type t;
+ self::C<invalid-type> l;
+ self::C<self::C<invalid-type>> ll;
+ const self::C::•<invalid-type>();
+ const <invalid-type>[];
+ const <self::C<invalid-type>>[];
+ const <core::Object>[invalid-type];
+ const <core::Object>[const self::C::•<invalid-type>()];
+ }
+ method instanceMethod() → self::C<self::C::T> {
+ core::print(self::C::T);
+ self::C::T t;
+ self::C<self::C::T> l;
+ self::C<self::C<self::C::T>> ll;
+ const self::C::•<self::C::T>();
+ const <self::C::T>[];
+ const <self::C<self::C::T>>[];
+ const <core::Object>[self::C::T];
+ const <core::Object>[const self::C::•<self::C::T>()];
+ }
+}
+static method main() → dynamic {}