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

Unified Diff: pkg/front_end/testcases/inference/constructors_infer_from_arguments.dart

Issue 2846103002: Generated front_end/testcases/inference test files from Analyzer tests. (Closed)
Patch Set: Created 3 years, 8 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
Index: pkg/front_end/testcases/inference/constructors_infer_from_arguments.dart
diff --git a/pkg/front_end/testcases/inference/constructors_infer_from_arguments.dart b/pkg/front_end/testcases/inference/constructors_infer_from_arguments.dart
new file mode 100644
index 0000000000000000000000000000000000000000..53a418ec090851fdcc15de25d5fab4588a8b6440
--- /dev/null
+++ b/pkg/front_end/testcases/inference/constructors_infer_from_arguments.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2017, 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+class C<T> {
+ T t;
+ C(this.t);
+}
+
+main() {
+ var /*@type=C<int>*/ x = /*@typeArgs=int*/ new C(42);
+
+ num y;
+ C<int> c_int = /*@typeArgs=int*/ new C(
+ /*info:DOWN_CAST_IMPLICIT*/ /*@promotedType=none*/ y);
+
+ // These hints are not reported because we resolve with a null error listener.
+ C<num> c_num = /*@typeArgs=num*/ new C(123);
+ C<num> c_num2 = (/*@typeArgs=num*/ new C(456))..t = 1.0;
+
+ // Down't infer from explicit dynamic.
+ var /*@type=C<dynamic>*/ c_dynamic = new C<dynamic>(42);
+ /*@promotedType=none*/ x.t = /*error:INVALID_ASSIGNMENT*/ 'hello';
+}

Powered by Google App Engine
This is Rietveld 408576698