Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.resolver_test; | 5 library analyzer.test.generated.resolver_test; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 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 13202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13213 _resolveTestUnit(code); | 13213 _resolveTestUnit(code); |
| 13214 | 13214 |
| 13215 SimpleIdentifier identifier = _findIdentifier('foo'); | 13215 SimpleIdentifier identifier = _findIdentifier('foo'); |
| 13216 VariableDeclaration declaration = | 13216 VariableDeclaration declaration = |
| 13217 identifier.getAncestor((node) => node is VariableDeclaration); | 13217 identifier.getAncestor((node) => node is VariableDeclaration); |
| 13218 | 13218 |
| 13219 expect(declaration.initializer.staticType.toString(), "Future<String>"); | 13219 expect(declaration.initializer.staticType.toString(), "Future<String>"); |
| 13220 expect(declaration.initializer.propagatedType, isNull); | 13220 expect(declaration.initializer.propagatedType, isNull); |
| 13221 } | 13221 } |
| 13222 | 13222 |
| 13223 void test_setterWithNoVoidType() { | |
|
Brian Wilkerson
2015/12/17 17:58:00
In addition to the explicit 'dynamic' case, we sho
Jennifer Messerly
2016/01/05 00:42:44
Good catch. Done & done.
| |
| 13224 Source source = addSource(r''' | |
| 13225 class A { | |
| 13226 set f(String s) { | |
| 13227 return '42'; | |
| 13228 } | |
| 13229 } | |
| 13230 set g(int x) => 42; | |
| 13231 '''); | |
| 13232 computeLibrarySourceErrors(source); | |
| 13233 assertErrors(source, [ | |
| 13234 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, | |
| 13235 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE | |
| 13236 ]); | |
| 13237 verify([source]); | |
| 13238 } | |
| 13239 | |
| 13240 void test_setterWithNoVoidType_returningVoid() { | |
| 13241 Source source = addSource(r''' | |
| 13242 void returnsVoid() {} | |
| 13243 class A { | |
| 13244 set f(String s) => returnsVoid(); | |
| 13245 } | |
| 13246 set g(int x) => returnsVoid(); | |
| 13247 '''); | |
| 13248 computeLibrarySourceErrors(source); | |
| 13249 assertNoErrors(source); | |
| 13250 verify([source]); | |
| 13251 } | |
| 13252 | |
| 13223 void test_ternaryOperator_null_left() { | 13253 void test_ternaryOperator_null_left() { |
| 13224 String code = r''' | 13254 String code = r''' |
| 13225 main() { | 13255 main() { |
| 13226 var foo = (true) ? null : 3; | 13256 var foo = (true) ? null : 3; |
| 13227 } | 13257 } |
| 13228 '''; | 13258 '''; |
| 13229 _resolveTestUnit(code); | 13259 _resolveTestUnit(code); |
| 13230 | 13260 |
| 13231 SimpleIdentifier identifier = _findIdentifier('foo'); | 13261 SimpleIdentifier identifier = _findIdentifier('foo'); |
| 13232 VariableDeclaration declaration = | 13262 VariableDeclaration declaration = |
| (...skipping 2856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16089 | 16119 |
| 16090 void _resolveTestUnit(String code) { | 16120 void _resolveTestUnit(String code) { |
| 16091 testCode = code; | 16121 testCode = code; |
| 16092 testSource = addSource(testCode); | 16122 testSource = addSource(testCode); |
| 16093 LibraryElement library = resolve2(testSource); | 16123 LibraryElement library = resolve2(testSource); |
| 16094 assertNoErrors(testSource); | 16124 assertNoErrors(testSource); |
| 16095 verify([testSource]); | 16125 verify([testSource]); |
| 16096 testUnit = resolveCompilationUnit(testSource, library); | 16126 testUnit = resolveCompilationUnit(testSource, library); |
| 16097 } | 16127 } |
| 16098 } | 16128 } |
| OLD | NEW |