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

Unified Diff: pkg/analyzer/test/generated/static_type_warning_code_test.dart

Issue 1927103002: Add checks for type bounds on generic methods (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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/analyzer/test/generated/static_type_warning_code_test.dart
diff --git a/pkg/analyzer/test/generated/static_type_warning_code_test.dart b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
index 4568fe9a1c8bc2651e920e8cc2c8f5de1f8f40d9..9873f93a317e206704160b03bf68fe1f57332606 100644
--- a/pkg/analyzer/test/generated/static_type_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
@@ -1288,6 +1288,64 @@ var b = 1 is G<B>;
[StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
+ void test_typeArgumentNotMatchingBounds_methodInvocation_localFunction() {
+ resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
+ assertErrorsInCode(
+ r'''
+class Point<T extends num> {
+ Point(T x, T y);
+}
+
+main() {
+ Point/*<T>*/ f/*<T extends num>*/(num/*=T*/ x, num/*=T*/ y) {
scheglov 2016/04/28 17:14:52 I'm not sure why we need to use Point in these tes
Brian Wilkerson 2016/04/28 20:46:11 I just copied the test without thinking about it t
+ return new Point/*<T>*/(x, y);
+ }
+ print(f/*<String>*/('hello', 'world'));
+}
+''',
+ [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+ }
+
+ void test_typeArgumentNotMatchingBounds_methodInvocation_method() {
+ resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
+ assertErrorsInCode(
+ r'''
+class Point<T extends num> {
+ Point(T x, T y);
+}
+
+class PointFactory {
+ Point/*<T>*/ point/*<T extends num>*/(num/*=T*/ x, num/*=T*/ y) {
+ return new Point/*<T>*/(x, y);
+ }
+}
+
+f(PointFactory factory) {
+ print(factory.point/*<String>*/('hello', 'world'));
+}
+''',
+ [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+ }
+
+ void test_typeArgumentNotMatchingBounds_methodInvocation_topLevelFunction() {
+ resetWithOptions(new AnalysisOptionsImpl()..strongMode = true);
+ assertErrorsInCode(
+ r'''
+class Point<T extends num> {
+ Point(T x, T y);
+}
+
+Point/*<T>*/ f/*<T extends num>*/(num/*=T*/ x, num/*=T*/ y) {
+ return new Point/*<T>*/(x, y);
+}
+
+main() {
+ print(f/*<String>*/('hello', 'world'));
+}
+''',
+ [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+ }
+
void test_typeArgumentNotMatchingBounds_methodReturnType() {
assertErrorsInCode(
r'''

Powered by Google App Engine
This is Rietveld 408576698