Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Unified Diff: tests/compiler/dart2js/type_variable_bound_test.dart

Issue 1182663008: Typecheck const classes in the context of the constructor call. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/compiler_helper.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/type_variable_bound_test.dart
diff --git a/tests/compiler/dart2js/type_variable_bound_test.dart b/tests/compiler/dart2js/type_variable_bound_test.dart
index 6844abba0fdbc4bbf24f606147b36d5347863b97..b93c42dfc0463a6ee3ff7e621702222f4e9fdcd2 100644
--- a/tests/compiler/dart2js/type_variable_bound_test.dart
+++ b/tests/compiler/dart2js/type_variable_bound_test.dart
@@ -9,7 +9,8 @@ import "package:expect/expect.dart";
Future compile(String source) {
Uri uri = Uri.parse('test:code');
- var compiler = compilerFor(source, uri, analyzeOnly: true);
+ var compiler =
+ compilerFor(source, uri, analyzeOnly: true, enableTypeAssertions: true);
compiler.diagnosticHandler = createHandler(compiler, source);
return compiler.runCompiler(uri).then((_) {
return compiler;
@@ -71,7 +72,7 @@ void main() {
print(compiler.errors);
Expect.isTrue(compiler.errors.isEmpty, 'unexpected errors');
Expect.equals(2, compiler.warnings.length,
- 'expected exactly one error, but got ${compiler.warnings}');
+ 'expected exactly two errors, but got ${compiler.warnings}');
Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
compiler.warnings[0].message.kind);
@@ -214,6 +215,41 @@ void main() {
MessageKind.INVALID_TYPE_VARIABLE_BOUND]);
}
+test10() {
+ test(r"""
+class A {
+ const A();
+}
+class Test<T extends A> {
+ final T x = const A();
+ const Test();
+}
+main() {
+ print(const Test<A>());
+}
+""");
+}
+
+// TODO(het): The error is reported twice because both the Dart and JS constant
+// compilers are run on the const constructor, investigate why.
+test11() {
+ test(r"""
+class A {
+ const A();
+}
+class B extends A {
+ const B();
+}
+class Test<T extends A> {
+ final T x = const A();
+ const Test();
+}
+main() {
+ print(const Test<B>());
+}
+""", errors: [MessageKind.NOT_ASSIGNABLE, MessageKind.NOT_ASSIGNABLE]);
+}
+
main() {
test1();
test2();
@@ -224,4 +260,6 @@ main() {
test7();
test8();
test9();
+ test10();
+ test11();
}
« no previous file with comments | « tests/compiler/dart2js/compiler_helper.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698