| 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/context/context.dart' as newContext; | 9 import 'package:analyzer/src/context/context.dart' as newContext; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 12835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12846 import 'lib.dart'; | 12846 import 'lib.dart'; |
| 12847 f(p) { | 12847 f(p) { |
| 12848 if (p is A) { | 12848 if (p is A) { |
| 12849 return p.v; // marker | 12849 return p.v; // marker |
| 12850 } | 12850 } |
| 12851 }'''; | 12851 }'''; |
| 12852 _assertTypeOfMarkedExpression( | 12852 _assertTypeOfMarkedExpression( |
| 12853 code, typeProvider.dynamicType, typeProvider.intType); | 12853 code, typeProvider.dynamicType, typeProvider.intType); |
| 12854 } | 12854 } |
| 12855 | 12855 |
| 12856 void fail_finalPropertyInducingVariable_classMember_instance_unprefixed() { | |
| 12857 String code = r''' | |
| 12858 class A { | |
| 12859 final v = 0; | |
| 12860 m() { | |
| 12861 v; // marker | |
| 12862 } | |
| 12863 }'''; | |
| 12864 _assertTypeOfMarkedExpression( | |
| 12865 code, typeProvider.dynamicType, typeProvider.intType); | |
| 12866 } | |
| 12867 | |
| 12868 void fail_finalPropertyInducingVariable_classMember_static() { | 12856 void fail_finalPropertyInducingVariable_classMember_static() { |
| 12869 addNamedSource( | 12857 addNamedSource( |
| 12870 "/lib.dart", | 12858 "/lib.dart", |
| 12871 r''' | 12859 r''' |
| 12872 class A { | 12860 class A { |
| 12873 static final V = 0; | 12861 static final V = 0; |
| 12874 }'''); | 12862 }'''); |
| 12875 String code = r''' | 12863 String code = r''' |
| 12876 import 'lib.dart'; | 12864 import 'lib.dart'; |
| 12877 f() { | 12865 f() { |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13180 Source source = addSource(code); | 13168 Source source = addSource(code); |
| 13181 LibraryElement library = resolve2(source); | 13169 LibraryElement library = resolve2(source); |
| 13182 assertNoErrors(source); | 13170 assertNoErrors(source); |
| 13183 verify([source]); | 13171 verify([source]); |
| 13184 CompilationUnit unit = resolveCompilationUnit(source, library); | 13172 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 13185 SimpleIdentifier identifier = EngineTestCase.findNode( | 13173 SimpleIdentifier identifier = EngineTestCase.findNode( |
| 13186 unit, code, "context", (node) => node is SimpleIdentifier); | 13174 unit, code, "context", (node) => node is SimpleIdentifier); |
| 13187 expect(identifier.propagatedType.name, "CanvasRenderingContext2D"); | 13175 expect(identifier.propagatedType.name, "CanvasRenderingContext2D"); |
| 13188 } | 13176 } |
| 13189 | 13177 |
| 13178 void test_finalPropertyInducingVariable_classMember_instance_unprefixed() { |
| 13179 String code = r''' |
| 13180 class A { |
| 13181 final v = 0; |
| 13182 m() { |
| 13183 v; // marker |
| 13184 } |
| 13185 }'''; |
| 13186 _assertTypeOfMarkedExpression( |
| 13187 code, typeProvider.dynamicType, typeProvider.intType); |
| 13188 } |
| 13189 |
| 13190 void test_forEach() { | 13190 void test_forEach() { |
| 13191 String code = r''' | 13191 String code = r''' |
| 13192 main() { | 13192 main() { |
| 13193 var list = <String> []; | 13193 var list = <String> []; |
| 13194 for (var e in list) { | 13194 for (var e in list) { |
| 13195 e; | 13195 e; |
| 13196 } | 13196 } |
| 13197 }'''; | 13197 }'''; |
| 13198 Source source = addSource(code); | 13198 Source source = addSource(code); |
| 13199 LibraryElement library = resolve2(source); | 13199 LibraryElement library = resolve2(source); |
| (...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15193 | 15193 |
| 15194 void _resolveTestUnit(String code) { | 15194 void _resolveTestUnit(String code) { |
| 15195 testCode = code; | 15195 testCode = code; |
| 15196 testSource = addSource(testCode); | 15196 testSource = addSource(testCode); |
| 15197 LibraryElement library = resolve2(testSource); | 15197 LibraryElement library = resolve2(testSource); |
| 15198 assertNoErrors(testSource); | 15198 assertNoErrors(testSource); |
| 15199 verify([testSource]); | 15199 verify([testSource]); |
| 15200 testUnit = resolveCompilationUnit(testSource, library); | 15200 testUnit = resolveCompilationUnit(testSource, library); |
| 15201 } | 15201 } |
| 15202 } | 15202 } |
| OLD | NEW |