| 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 engine.resolver_test; | 5 library engine.resolver_test; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 7023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7034 E e; | 7034 E e; |
| 7035 m() { | 7035 m() { |
| 7036 (e as A).a(); | 7036 (e as A).a(); |
| 7037 } | 7037 } |
| 7038 }'''); | 7038 }'''); |
| 7039 resolve(source); | 7039 resolve(source); |
| 7040 assertNoErrors(source); | 7040 assertNoErrors(source); |
| 7041 verify([source]); | 7041 verify([source]); |
| 7042 } | 7042 } |
| 7043 | 7043 |
| 7044 void test_unnecessaryCast_conditionalExpression() { |
| 7045 Source source = addSource(r''' |
| 7046 abstract class I {} |
| 7047 class A implements I {} |
| 7048 class B implements I {} |
| 7049 I m(A a, B b) { |
| 7050 return a == null ? b as I : a as I; |
| 7051 }'''); |
| 7052 resolve(source); |
| 7053 assertNoErrors(source); |
| 7054 verify([source]); |
| 7055 } |
| 7056 |
| 7044 void test_unnecessaryCast_dynamic_type() { | 7057 void test_unnecessaryCast_dynamic_type() { |
| 7045 Source source = addSource(r''' | 7058 Source source = addSource(r''' |
| 7046 m(v) { | 7059 m(v) { |
| 7047 var b = v as Object; | 7060 var b = v as Object; |
| 7048 }'''); | 7061 }'''); |
| 7049 resolve(source); | 7062 resolve(source); |
| 7050 assertNoErrors(source); | 7063 assertNoErrors(source); |
| 7051 verify([source]); | 7064 verify([source]); |
| 7052 } | 7065 } |
| 7053 | 7066 |
| (...skipping 6747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13801 // check propagated type | 13814 // check propagated type |
| 13802 FunctionType propagatedType = node.propagatedType as FunctionType; | 13815 FunctionType propagatedType = node.propagatedType as FunctionType; |
| 13803 expect(propagatedType.returnType, test.typeProvider.stringType); | 13816 expect(propagatedType.returnType, test.typeProvider.stringType); |
| 13804 } on AnalysisException catch (e, stackTrace) { | 13817 } on AnalysisException catch (e, stackTrace) { |
| 13805 thrownException[0] = new CaughtException(e, stackTrace); | 13818 thrownException[0] = new CaughtException(e, stackTrace); |
| 13806 } | 13819 } |
| 13807 } | 13820 } |
| 13808 return null; | 13821 return null; |
| 13809 } | 13822 } |
| 13810 } | 13823 } |
| OLD | NEW |