| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.generated.strong_mode_test; | 5 library analyzer.test.generated.strong_mode_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 objectMethodOnFunctions_helper(code); | 2073 objectMethodOnFunctions_helper(code); |
| 2074 } | 2074 } |
| 2075 | 2075 |
| 2076 void test_setterWithDynamicTypeIsError() { | 2076 void test_setterWithDynamicTypeIsError() { |
| 2077 Source source = addSource(r''' | 2077 Source source = addSource(r''' |
| 2078 class A { | 2078 class A { |
| 2079 dynamic set f(String s) => null; | 2079 dynamic set f(String s) => null; |
| 2080 } | 2080 } |
| 2081 dynamic set g(int x) => null; | 2081 dynamic set g(int x) => null; |
| 2082 '''); | 2082 '''); |
| 2083 computeLibrarySourceErrors(source); | |
| 2084 assertErrors(source, [ | 2083 assertErrors(source, [ |
| 2085 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER, | 2084 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER, |
| 2086 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER | 2085 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER |
| 2087 ]); | 2086 ]); |
| 2088 verify([source]); | 2087 verify([source]); |
| 2089 } | 2088 } |
| 2090 | 2089 |
| 2091 void test_setterWithExplicitVoidType_returningVoid() { | 2090 void test_setterWithExplicitVoidType_returningVoid() { |
| 2092 Source source = addSource(r''' | 2091 Source source = addSource(r''' |
| 2093 void returnsVoid() {} | 2092 void returnsVoid() {} |
| 2094 class A { | 2093 class A { |
| 2095 void set f(String s) => returnsVoid(); | 2094 void set f(String s) => returnsVoid(); |
| 2096 } | 2095 } |
| 2097 void set g(int x) => returnsVoid(); | 2096 void set g(int x) => returnsVoid(); |
| 2098 '''); | 2097 '''); |
| 2099 computeLibrarySourceErrors(source); | |
| 2100 assertNoErrors(source); | 2098 assertNoErrors(source); |
| 2101 verify([source]); | 2099 verify([source]); |
| 2102 } | 2100 } |
| 2103 | 2101 |
| 2104 void test_setterWithNoVoidType() { | 2102 void test_setterWithNoVoidType() { |
| 2105 Source source = addSource(r''' | 2103 Source source = addSource(r''' |
| 2106 class A { | 2104 class A { |
| 2107 set f(String s) { | 2105 set f(String s) { |
| 2108 return '42'; | 2106 return '42'; |
| 2109 } | 2107 } |
| 2110 } | 2108 } |
| 2111 set g(int x) => 42; | 2109 set g(int x) => 42; |
| 2112 '''); | 2110 '''); |
| 2113 computeLibrarySourceErrors(source); | |
| 2114 assertErrors(source, [ | 2111 assertErrors(source, [ |
| 2115 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, | 2112 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, |
| 2116 ]); | 2113 ]); |
| 2117 verify([source]); | 2114 verify([source]); |
| 2118 } | 2115 } |
| 2119 | 2116 |
| 2120 void test_setterWithNoVoidType_returningVoid() { | 2117 void test_setterWithNoVoidType_returningVoid() { |
| 2121 Source source = addSource(r''' | 2118 Source source = addSource(r''' |
| 2122 void returnsVoid() {} | 2119 void returnsVoid() {} |
| 2123 class A { | 2120 class A { |
| 2124 set f(String s) => returnsVoid(); | 2121 set f(String s) => returnsVoid(); |
| 2125 } | 2122 } |
| 2126 set g(int x) => returnsVoid(); | 2123 set g(int x) => returnsVoid(); |
| 2127 '''); | 2124 '''); |
| 2128 computeLibrarySourceErrors(source); | |
| 2129 assertNoErrors(source); | 2125 assertNoErrors(source); |
| 2130 verify([source]); | 2126 verify([source]); |
| 2131 } | 2127 } |
| 2132 | 2128 |
| 2133 void test_setterWithOtherTypeIsError() { | 2129 void test_setterWithOtherTypeIsError() { |
| 2134 Source source = addSource(r''' | 2130 Source source = addSource(r''' |
| 2135 class A { | 2131 class A { |
| 2136 String set f(String s) => null; | 2132 String set f(String s) => null; |
| 2137 } | 2133 } |
| 2138 Object set g(x) => null; | 2134 Object set g(x) => null; |
| 2139 '''); | 2135 '''); |
| 2140 computeLibrarySourceErrors(source); | |
| 2141 assertErrors(source, [ | 2136 assertErrors(source, [ |
| 2142 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER, | 2137 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER, |
| 2143 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER | 2138 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER |
| 2144 ]); | 2139 ]); |
| 2145 verify([source]); | 2140 verify([source]); |
| 2146 } | 2141 } |
| 2147 | 2142 |
| 2148 void test_ternaryOperator_null_left() { | 2143 void test_ternaryOperator_null_left() { |
| 2149 String code = r''' | 2144 String code = r''' |
| 2150 main() { | 2145 main() { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2406 main() { | 2401 main() { |
| 2407 var v = x; | 2402 var v = x; |
| 2408 v; // marker | 2403 v; // marker |
| 2409 } | 2404 } |
| 2410 int x = 3; | 2405 int x = 3; |
| 2411 '''; | 2406 '''; |
| 2412 assertPropagatedAssignedType(code, typeProvider.intType, null); | 2407 assertPropagatedAssignedType(code, typeProvider.intType, null); |
| 2413 assertTypeOfMarkedExpression(code, typeProvider.intType, null); | 2408 assertTypeOfMarkedExpression(code, typeProvider.intType, null); |
| 2414 } | 2409 } |
| 2415 } | 2410 } |
| OLD | NEW |