Chromium Code Reviews| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 _isFutureOrOf = | 81 _isFutureOrOf = |
| 82 _isInstantiationOf(_hasElementOf(typeProvider.futureOrType)); | 82 _isInstantiationOf(_hasElementOf(typeProvider.futureOrType)); |
| 83 _isFutureOfDynamic = _isFutureOf([_isDynamic]); | 83 _isFutureOfDynamic = _isFutureOf([_isDynamic]); |
| 84 _isFutureOfInt = _isFutureOf([_isInt]); | 84 _isFutureOfInt = _isFutureOf([_isInt]); |
| 85 _isFutureOrOfInt = _isFutureOrOf([_isInt]); | 85 _isFutureOrOfInt = _isFutureOrOf([_isInt]); |
| 86 _isStreamOf = _isInstantiationOf(_hasElementOf(typeProvider.streamType)); | 86 _isStreamOf = _isInstantiationOf(_hasElementOf(typeProvider.streamType)); |
| 87 } | 87 } |
| 88 return result; | 88 return result; |
| 89 } | 89 } |
| 90 | 90 |
| 91 fail_constrainedByBounds3() async { | 91 fail_constrainedByBounds3() async { |
|
Leaf
2017/02/17 22:26:03
I think I added these to test ordering behavior of
Jennifer Messerly
2017/03/14 02:07:07
it's passing now!
| |
| 92 // Test that upwards inference with two type variables does | 92 // Test that upwards inference with two type variables does |
| 93 // not propogate from the constrained variable to the unconstrained | 93 // not propogate from the constrained variable to the unconstrained |
| 94 // variable if they are ordered right to left, and that if the result | 94 // variable if they are ordered right to left, and that if the result |
| 95 // is not a valid instantiation an error is issued | 95 // is not a valid instantiation an error is issued |
| 96 String code = r''' | 96 String code = r''' |
| 97 T f<T extends S, S extends int>(S x) => null; | 97 T f<T extends S, S extends int>(S x) => null; |
| 98 void test() { var x = f(3); } | 98 void test() { var x = f(3); } |
| 99 '''; | 99 '''; |
| 100 Source source = addSource(code); | 100 Source source = addSource(code); |
| 101 TestAnalysisResult analysisResult = await computeAnalysisResult(source); | 101 TestAnalysisResult analysisResult = await computeAnalysisResult(source); |
| 102 assertErrors( | 102 assertErrors( |
| 103 source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 103 source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); |
| 104 verify([source]); | 104 verify([source]); |
| 105 CompilationUnit unit = analysisResult.unit; | 105 CompilationUnit unit = analysisResult.unit; |
| 106 List<Statement> statements = | 106 List<Statement> statements = |
| 107 AstFinder.getStatementsInTopLevelFunction(unit, "test"); | 107 AstFinder.getStatementsInTopLevelFunction(unit, "test"); |
| 108 VariableDeclarationStatement stmt = statements[0]; | 108 VariableDeclarationStatement stmt = statements[0]; |
| 109 VariableDeclaration decl = stmt.variables.variables[0]; | 109 VariableDeclaration decl = stmt.variables.variables[0]; |
| 110 Expression call = decl.initializer; | 110 Expression call = decl.initializer; |
| 111 _isDynamic(call.staticType); | 111 _isDynamic(call.staticType); |
| 112 } | 112 } |
| 113 | 113 |
| 114 fail_constrainedByBounds5() async { | 114 fail_constrainedByBounds5() async { |
|
Leaf
2017/02/17 22:26:03
ditto
Jennifer Messerly
2017/03/14 02:07:07
same, this is now passing!
| |
| 115 // Test that upwards inference with two type variables does not | 115 // Test that upwards inference with two type variables does not |
| 116 // propogate from the constrained variable to the unconstrained | 116 // propogate from the constrained variable to the unconstrained |
| 117 // variable if they are ordered right to left, when the variable | 117 // variable if they are ordered right to left, when the variable |
| 118 // appears co and contra variantly, and that an error is issued | 118 // appears co and contra variantly, and that an error is issued |
| 119 // for the non-matching bound. | 119 // for the non-matching bound. |
| 120 String code = r''' | 120 String code = r''' |
| 121 typedef To Func1<From, To>(From x); | 121 typedef To Func1<From, To>(From x); |
| 122 T f<T extends Func1<S, S>, S>(S x) => null; | 122 T f<T extends Func1<S, S>, S>(S x) => null; |
| 123 void test() { var x = f(3)(4); } | 123 void test() { var x = f(3)(4); } |
| 124 '''; | 124 '''; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 135 Expression call = decl.initializer; | 135 Expression call = decl.initializer; |
| 136 _isInt(call.staticType); | 136 _isInt(call.staticType); |
| 137 } | 137 } |
| 138 | 138 |
| 139 fail_futureOr_downwards7() async { | 139 fail_futureOr_downwards7() async { |
| 140 // Test that downwards inference incorporates bounds correctly | 140 // Test that downwards inference incorporates bounds correctly |
| 141 // when instantiating type variables. | 141 // when instantiating type variables. |
| 142 // TODO(leafp): I think this should pass once the inference changes | 142 // TODO(leafp): I think this should pass once the inference changes |
| 143 // that jmesserly is adding are landed. | 143 // that jmesserly is adding are landed. |
| 144 MethodInvocation invoke = await _testFutureOr(r''' | 144 MethodInvocation invoke = await _testFutureOr(r''' |
| 145 T mk<T extends int>(T x) => null; | 145 T mk<T extends int>(T x) => null; |
|
Leaf
2017/02/17 22:26:03
This test looks bogus. I think maybe the intentio
Jennifer Messerly
2017/03/14 02:07:07
yup, I fixed it & it now passes
| |
| 146 FutureOr<int> test() => mk(new Future.value(42)); | 146 FutureOr<int> test() => mk(new Future.value(42)); |
| 147 '''); | 147 '''); |
| 148 _isFutureOfInt(invoke.staticType); | 148 _isFutureOfInt(invoke.staticType); |
| 149 _isFutureOfInt(invoke.argumentList.arguments[0].staticType); | 149 _isFutureOfInt(invoke.argumentList.arguments[0].staticType); |
| 150 } | 150 } |
| 151 | 151 |
| 152 fail_futureOr_downwards8() async { | 152 fail_futureOr_downwards8() async { |
|
Leaf
2017/02/17 22:26:03
Also looks bogus to me now - I think should be T e
Jennifer Messerly
2017/03/14 02:07:07
Hmmm, maybe you're right. I actually went ahead an
| |
| 153 // Test that downwards inference incorporates bounds correctly | 153 // Test that downwards inference incorporates bounds correctly |
| 154 // when instantiating type variables. | 154 // when instantiating type variables. |
| 155 // TODO(leafp): I think this should pass once the inference changes | 155 // TODO(leafp): I think this should pass once the inference changes |
| 156 // that jmesserly is adding are landed. | 156 // that jmesserly is adding are landed. |
| 157 MethodInvocation invoke = await _testFutureOr(r''' | 157 MethodInvocation invoke = await _testFutureOr(r''' |
| 158 T mk<T extends Future<Object>>(T x) => null; | 158 T mk<T extends Future<Object>>(T x) => null; |
| 159 FutureOr<int> test() => mk(new Future.value(42)); | 159 FutureOr<int> test() => mk(new Future.value(42)); |
| 160 '''); | 160 '''); |
| 161 _isFutureOfInt(invoke.staticType); | 161 _isFutureOfInt(invoke.staticType); |
| 162 _isFutureOfInt(invoke.argumentList.arguments[0].staticType); | 162 _isFutureOfInt(invoke.argumentList.arguments[0].staticType); |
| 163 } | 163 } |
| 164 | 164 |
| 165 fail_pinning_multipleConstraints1() async { | 165 fail_pinning_multipleConstraints1() async { |
|
Leaf
2017/02/17 22:26:03
Why is this failing? Are we inferring Null?
Jennifer Messerly
2017/03/14 02:07:07
it's passing now
| |
| 166 // Test that downwards inference with two different downwards covariant | 166 // Test that downwards inference with two different downwards covariant |
| 167 // constraints on the same parameter correctly fails to infer when | 167 // constraints on the same parameter correctly fails to infer when |
| 168 // the types do not share a common subtype | 168 // the types do not share a common subtype |
| 169 String code = r''' | 169 String code = r''' |
| 170 class A<S, T> { | 170 class A<S, T> { |
| 171 S s; | 171 S s; |
| 172 T t; | 172 T t; |
| 173 } | 173 } |
| 174 class B<S> extends A<S, S> { B(S s); } | 174 class B<S> extends A<S, S> { B(S s); } |
| 175 A<int, String> test() => new B(3); | 175 A<int, String> test() => new B(3); |
| 176 '''; | 176 '''; |
| 177 Source source = addSource(code); | 177 Source source = addSource(code); |
| 178 TestAnalysisResult analysisResult = await computeAnalysisResult(source); | 178 TestAnalysisResult analysisResult = await computeAnalysisResult(source); |
| 179 assertErrors(source, [StrongModeCode.COULD_NOT_INFER]); | 179 assertErrors(source, [StrongModeCode.COULD_NOT_INFER]); |
| 180 verify([source]); | 180 verify([source]); |
| 181 CompilationUnit unit = analysisResult.unit; | 181 CompilationUnit unit = analysisResult.unit; |
| 182 FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test"); | 182 FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test"); |
| 183 ExpressionFunctionBody body = test.functionExpression.body; | 183 ExpressionFunctionBody body = test.functionExpression.body; |
| 184 DartType type = body.expression.staticType; | 184 DartType type = body.expression.staticType; |
| 185 | 185 |
| 186 Element elementB = AstFinder.getClass(unit, "B").element; | 186 Element elementB = AstFinder.getClass(unit, "B").element; |
| 187 | 187 |
| 188 _isInstantiationOf(_hasElement(elementB))([_isDynamic])(type); | 188 _isInstantiationOf(_hasElement(elementB))([_isDynamic])(type); |
| 189 } | 189 } |
| 190 | 190 |
| 191 fail_pinning_multipleConstraints2() async { | 191 test_pinning_multipleConstraints2() async { |
| 192 // Test that downwards inference with two identical downwards covariant | 192 // Test that downwards inference with two identical downwards covariant |
| 193 // constraints on the same parameter correctly infers and pins the type | 193 // constraints on the same parameter correctly infers and pins the type |
| 194 String code = r''' | 194 String code = r''' |
| 195 class A<S, T> { | 195 class A<S, T> { |
| 196 S s; | 196 S s; |
| 197 T t; | 197 T t; |
| 198 } | 198 } |
| 199 class B<S> extends A<S, S> { B(S s); } | 199 class B<S> extends A<S, S> { B(S s); } |
| 200 A<num, num> test() => new B(3); | 200 A<num, num> test() => new B(3); |
| 201 '''; | 201 '''; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 CompilationUnit unit = analysisResult.unit; | 235 CompilationUnit unit = analysisResult.unit; |
| 236 FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test"); | 236 FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test"); |
| 237 ExpressionFunctionBody body = test.functionExpression.body; | 237 ExpressionFunctionBody body = test.functionExpression.body; |
| 238 DartType type = body.expression.staticType; | 238 DartType type = body.expression.staticType; |
| 239 | 239 |
| 240 Element elementB = AstFinder.getClass(unit, "B").element; | 240 Element elementB = AstFinder.getClass(unit, "B").element; |
| 241 | 241 |
| 242 _isInstantiationOf(_hasElement(elementB))([_isDynamic])(type); | 242 _isInstantiationOf(_hasElement(elementB))([_isDynamic])(type); |
| 243 } | 243 } |
| 244 | 244 |
| 245 fail_returnType_variance2() async { | 245 pass_returnType_variance2() async { |
|
Leaf
2017/02/17 22:26:03
Should this be test_? Or is this a valid prefix?
Jennifer Messerly
2017/03/14 02:07:07
good catch. fixed & test passes :)
| |
| 246 // Check that downwards inference correctly pins a type parameter | 246 // Check that downwards inference correctly pins a type parameter |
| 247 // when the parameter is constrained in a covariant position | 247 // when the parameter is constrained in a covariant position |
| 248 String code = r''' | 248 String code = r''' |
| 249 typedef To Func1<From, To>(From x); | 249 typedef To Func1<From, To>(From x); |
| 250 Func1<String, T> f<T>(T x) => null; | 250 Func1<String, T> f<T>(T x) => null; |
| 251 Func1<String, num> test() => f(42); | 251 Func1<String, num> test() => f(42); |
| 252 '''; | 252 '''; |
| 253 Source source = addSource(code); | 253 Source source = addSource(code); |
| 254 TestAnalysisResult analysisResult = await computeAnalysisResult(source); | 254 TestAnalysisResult analysisResult = await computeAnalysisResult(source); |
| 255 assertNoErrors(source); | 255 assertNoErrors(source); |
| 256 verify([source]); | 256 verify([source]); |
| 257 CompilationUnit unit = analysisResult.unit; | 257 CompilationUnit unit = analysisResult.unit; |
| 258 FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test"); | 258 FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test"); |
| 259 ExpressionFunctionBody body = test.functionExpression.body; | 259 ExpressionFunctionBody body = test.functionExpression.body; |
| 260 MethodInvocation invoke = body.expression; | 260 MethodInvocation invoke = body.expression; |
| 261 _isFunction2Of(_isNum, _isFunction2Of(_isString, _isNum))( | 261 _isFunction2Of(_isNum, _isFunction2Of(_isString, _isNum))( |
| 262 invoke.staticInvokeType); | 262 invoke.staticInvokeType); |
| 263 } | 263 } |
| 264 | 264 |
| 265 fail_returnType_variance6() async { | 265 pass_returnType_variance6() async { |
| 266 // Check that pinning works correctly with a partial type | 266 // Check that pinning works correctly with a partial type |
| 267 // when the return type uses the variable in a covariant position | 267 // when the return type uses the variable in a covariant position |
| 268 String code = r''' | 268 String code = r''' |
| 269 typedef To Func1<From, To>(From x); | 269 typedef To Func1<From, To>(From x); |
| 270 Func1<String, T> f<T>(T x) => null; | 270 Func1<String, T> f<T>(T x) => null; |
| 271 T g<T, S>(Func1<S, T> f) => null; | 271 T g<T, S>(Func1<S, T> f) => null; |
| 272 num test() => g(f(3)); | 272 num test() => g(f(3)); |
| 273 '''; | 273 '''; |
| 274 Source source = addSource(code); | 274 Source source = addSource(code); |
| 275 TestAnalysisResult analysisResult = await computeAnalysisResult(source); | 275 TestAnalysisResult analysisResult = await computeAnalysisResult(source); |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1008 _isFutureOf([_isNum])(invoke.argumentList.arguments[0].staticType); | 1008 _isFutureOf([_isNum])(invoke.argumentList.arguments[0].staticType); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 test_futureOr_downwards6() async { | 1011 test_futureOr_downwards6() async { |
| 1012 // Test that downwards inference doesn't decompose FutureOr | 1012 // Test that downwards inference doesn't decompose FutureOr |
| 1013 // when instantiating type variables. | 1013 // when instantiating type variables. |
| 1014 MethodInvocation invoke = await _testFutureOr(r''' | 1014 MethodInvocation invoke = await _testFutureOr(r''' |
| 1015 T mk<T>(T x) => null; | 1015 T mk<T>(T x) => null; |
| 1016 FutureOr<int> test() => mk(new Future.value(42)); | 1016 FutureOr<int> test() => mk(new Future.value(42)); |
| 1017 '''); | 1017 '''); |
| 1018 _isFutureOfInt(invoke.staticType); | 1018 _isFutureOrOfInt(invoke.staticType); |
| 1019 _isFutureOfInt(invoke.argumentList.arguments[0].staticType); | 1019 _isFutureOfInt(invoke.argumentList.arguments[0].staticType); |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 test_futureOr_downwards9() async { | 1022 test_futureOr_downwards9() async { |
| 1023 // Test that downwards inference decomposes correctly with | 1023 // Test that downwards inference decomposes correctly with |
| 1024 // other composite types | 1024 // other composite types |
| 1025 MethodInvocation invoke = await _testFutureOr(r''' | 1025 MethodInvocation invoke = await _testFutureOr(r''' |
| 1026 List<T> mk<T>(T x) => null; | 1026 List<T> mk<T>(T x) => null; |
| 1027 FutureOr<List<int>> test() => mk(3); | 1027 FutureOr<List<int>> test() => mk(3); |
| 1028 '''); | 1028 '''); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1080 | 1080 |
| 1081 test_futureOr_upwards2() async { | 1081 test_futureOr_upwards2() async { |
| 1082 // Test that upwards inference fails when the solution doesn't | 1082 // Test that upwards inference fails when the solution doesn't |
| 1083 // match the bound. | 1083 // match the bound. |
| 1084 MethodInvocation invoke = await _testFutureOr( | 1084 MethodInvocation invoke = await _testFutureOr( |
| 1085 r''' | 1085 r''' |
| 1086 Future<T> mk<T extends Future<Object>>(FutureOr<T> x) => null; | 1086 Future<T> mk<T extends Future<Object>>(FutureOr<T> x) => null; |
| 1087 dynamic test() => mk(new Future<int>.value(42)); | 1087 dynamic test() => mk(new Future<int>.value(42)); |
| 1088 ''', | 1088 ''', |
| 1089 errors: [StrongModeCode.COULD_NOT_INFER]); | 1089 errors: [StrongModeCode.COULD_NOT_INFER]); |
| 1090 _isFutureOf([_isObject])(invoke.staticType); | 1090 _isFutureOfInt(invoke.staticType); |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 test_futureOr_assignFromValue() async { | 1093 test_futureOr_assignFromValue() async { |
| 1094 // Test a T can be assigned to FutureOr<T>. | 1094 // Test a T can be assigned to FutureOr<T>. |
| 1095 MethodInvocation invoke = await _testFutureOr(r''' | 1095 MethodInvocation invoke = await _testFutureOr(r''' |
| 1096 FutureOr<T> mk<T>(T x) => x; | 1096 FutureOr<T> mk<T>(T x) => x; |
| 1097 test() => mk(42); | 1097 test() => mk(42); |
| 1098 '''); | 1098 '''); |
| 1099 _isFutureOrOfInt(invoke.staticType); | 1099 _isFutureOrOfInt(invoke.staticType); |
| 1100 } | 1100 } |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2224 Expression exp = (statements[i] as ExpressionStatement).expression; | 2224 Expression exp = (statements[i] as ExpressionStatement).expression; |
| 2225 expect(exp.staticType, typeProvider.dynamicType); | 2225 expect(exp.staticType, typeProvider.dynamicType); |
| 2226 } | 2226 } |
| 2227 } | 2227 } |
| 2228 | 2228 |
| 2229 checkBody("C"); | 2229 checkBody("C"); |
| 2230 checkBody("D"); | 2230 checkBody("D"); |
| 2231 } | 2231 } |
| 2232 | 2232 |
| 2233 test_genericFunction_upwardsAndDownwards() async { | 2233 test_genericFunction_upwardsAndDownwards() async { |
| 2234 // Regression tests for https://github.com/dart-lang/sdk/issues/27151. | 2234 // Regression tests for https://github.com/dart-lang/sdk/issues/27586. |
| 2235 await resolveTestUnit(r'List<num> x = [1, 2];'); | 2235 await resolveTestUnit(r'List<num> x = [1, 2];'); |
| 2236 expectInitializerType('x', 'List<int>'); | 2236 expectInitializerType('x', 'List<num>'); |
| 2237 } | 2237 } |
| 2238 | 2238 |
| 2239 test_genericFunction_upwardsAndDownwards_Object() async { | |
| 2240 // Regression tests for https://github.com/dart-lang/sdk/issues/27625. | |
| 2241 await resolveTestUnit(r''' | |
| 2242 List<Object> aaa = []; | |
| 2243 List<Object> bbb = [1, 2, 3]; | |
| 2244 List<Object> ccc = [null]; | |
| 2245 List<Object> ddd = [1 as dynamic]; | |
| 2246 List<Object> eee = [new Object()]; | |
| 2247 '''); | |
| 2248 expectInitializerType('aaa', 'List<Object>'); | |
| 2249 expectInitializerType('bbb', 'List<Object>'); | |
| 2250 expectInitializerType('ccc', 'List<Object>'); | |
| 2251 expectInitializerType('ddd', 'List<Object>'); | |
| 2252 expectInitializerType('eee', 'List<Object>'); | |
| 2253 } | |
| 2254 | |
| 2255 | |
| 2239 test_genericMethod() async { | 2256 test_genericMethod() async { |
| 2240 await resolveTestUnit(r''' | 2257 await resolveTestUnit(r''' |
| 2241 class C<E> { | 2258 class C<E> { |
| 2242 List/*<T>*/ f/*<T>*/(E e) => null; | 2259 List/*<T>*/ f/*<T>*/(E e) => null; |
| 2243 } | 2260 } |
| 2244 main() { | 2261 main() { |
| 2245 C<String> cOfString; | 2262 C<String> cOfString; |
| 2246 } | 2263 } |
| 2247 '''); | 2264 '''); |
| 2248 expectFunctionType('f', '<T>(E) → List<T>', | 2265 expectFunctionType('f', '<T>(E) → List<T>', |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2878 void main() { | 2895 void main() { |
| 2879 m(null, null); | 2896 m(null, null); |
| 2880 } | 2897 } |
| 2881 } | 2898 } |
| 2882 '''; | 2899 '''; |
| 2883 await resolveTestUnit(code); | 2900 await resolveTestUnit(code); |
| 2884 assertNoErrors(testSource); | 2901 assertNoErrors(testSource); |
| 2885 expectStaticInvokeType('m(null', '(T, List<T>) → void'); | 2902 expectStaticInvokeType('m(null', '(T, List<T>) → void'); |
| 2886 } | 2903 } |
| 2887 | 2904 |
| 2905 test_instantiateToBounds_method_ok_referenceOther_before2() async { | |
| 2906 String code = r''' | |
| 2907 class C<T> { | |
| 2908 Map<S0, S1> m<S0 extends T, S1 extends List<S0>>() => null; | |
| 2909 | |
| 2910 void main() { | |
| 2911 m(); | |
| 2912 } | |
| 2913 } | |
| 2914 '''; | |
| 2915 await resolveTestUnit(code); | |
| 2916 assertNoErrors(testSource); | |
| 2917 expectStaticInvokeType('m();', '() → Map<T, List<T>>'); | |
| 2918 } | |
| 2919 | |
| 2888 test_instantiateToBounds_method_ok_simpleBounds() async { | 2920 test_instantiateToBounds_method_ok_simpleBounds() async { |
| 2889 String code = r''' | 2921 String code = r''' |
| 2890 class C<T> { | 2922 class C<T> { |
| 2891 void m<S extends T>(S p0) {} | 2923 void m<S extends T>(S p0) {} |
| 2892 | 2924 |
| 2893 void main() { | 2925 void main() { |
| 2894 m(null); | 2926 m(null); |
| 2895 } | 2927 } |
| 2896 } | 2928 } |
| 2897 '''; | 2929 '''; |
| 2898 await resolveTestUnit(code); | 2930 await resolveTestUnit(code); |
| 2899 assertNoErrors(testSource); | 2931 assertNoErrors(testSource); |
| 2900 expectStaticInvokeType('m(null)', '(T) → void'); | 2932 expectStaticInvokeType('m(null)', '(T) → void'); |
| 2901 } | 2933 } |
| 2902 | 2934 |
| 2935 test_instantiateToBounds_method_ok_simpleBounds2() async { | |
| 2936 String code = r''' | |
| 2937 class C<T> { | |
| 2938 S m<S extends T>() => null; | |
| 2939 | |
| 2940 void main() { | |
| 2941 m(); | |
| 2942 } | |
| 2943 } | |
| 2944 '''; | |
| 2945 await resolveTestUnit(code); | |
| 2946 assertNoErrors(testSource); | |
| 2947 expectStaticInvokeType('m();', '() → T'); | |
| 2948 } | |
| 2949 | |
| 2903 test_notInstantiatedBound_direct_class_class() async { | 2950 test_notInstantiatedBound_direct_class_class() async { |
| 2904 String code = r''' | 2951 String code = r''' |
| 2905 class A<T extends int> {} | 2952 class A<T extends int> {} |
| 2906 class C<T extends A> {} | 2953 class C<T extends A> {} |
| 2907 '''; | 2954 '''; |
| 2908 await resolveTestUnit(code, noErrors: false); | 2955 await resolveTestUnit(code, noErrors: false); |
| 2909 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]); | 2956 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]); |
| 2910 } | 2957 } |
| 2911 | 2958 |
| 2912 test_notInstantiatedBound_direct_class_typedef() async { | 2959 test_notInstantiatedBound_direct_class_typedef() async { |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3426 var v = x; | 3473 var v = x; |
| 3427 v; // marker | 3474 v; // marker |
| 3428 } | 3475 } |
| 3429 int x = 3; | 3476 int x = 3; |
| 3430 '''; | 3477 '''; |
| 3431 CompilationUnit unit = await resolveSource(code); | 3478 CompilationUnit unit = await resolveSource(code); |
| 3432 assertPropagatedAssignedType(code, unit, typeProvider.intType, null); | 3479 assertPropagatedAssignedType(code, unit, typeProvider.intType, null); |
| 3433 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null); | 3480 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null); |
| 3434 } | 3481 } |
| 3435 } | 3482 } |
| OLD | NEW |