Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2288223003: Don't perform final fields and top-level variables type propagation. (Closed)
Patch Set: Rewrite 'reuse' tests using 'inferredTypeSlot'. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.src.context.context_test; 5 library analyzer.test.src.context.context_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2469 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); 2469 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED);
2470 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); 2470 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED);
2471 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); 2471 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED);
2472 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); 2472 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED);
2473 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); 2473 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED);
2474 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); 2474 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED);
2475 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); 2475 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED);
2476 entry.setState(RESOLVED_UNIT10, CacheState.FLUSHED); 2476 entry.setState(RESOLVED_UNIT10, CacheState.FLUSHED);
2477 entry.setState(RESOLVED_UNIT11, CacheState.FLUSHED); 2477 entry.setState(RESOLVED_UNIT11, CacheState.FLUSHED);
2478 entry.setState(RESOLVED_UNIT12, CacheState.FLUSHED); 2478 entry.setState(RESOLVED_UNIT12, CacheState.FLUSHED);
2479 entry.setState(RESOLVED_UNIT13, CacheState.FLUSHED);
2480 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); 2479 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED);
2481 2480
2482 context.resolveCompilationUnit2(source, source); 2481 context.resolveCompilationUnit2(source, source);
2483 LibraryElement secondElement = context.computeLibraryElement(source); 2482 LibraryElement secondElement = context.computeLibraryElement(source);
2484 _ElementComparer comparer = new _ElementComparer(gatherer.elements); 2483 _ElementComparer comparer = new _ElementComparer(gatherer.elements);
2485 secondElement.accept(comparer); 2484 secondElement.accept(comparer);
2486 comparer.expectNoDifferences(); 2485 comparer.expectNoDifferences();
2487 } 2486 }
2488 2487
2489 void test_resolveCompilationUnit_import_relative() { 2488 void test_resolveCompilationUnit_import_relative() {
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
3790 context.getResult(new LibrarySpecificUnit(a, a), RESOLVED_UNIT); 3789 context.getResult(new LibrarySpecificUnit(a, a), RESOLVED_UNIT);
3791 ExpressionStatement statement = 3790 ExpressionStatement statement =
3792 AstFinder.getStatementsInTopLevelFunction(unit, 'main').single; 3791 AstFinder.getStatementsInTopLevelFunction(unit, 'main').single;
3793 MethodInvocation invocation = statement.expression; 3792 MethodInvocation invocation = statement.expression;
3794 return invocation.argumentList.arguments[0]; 3793 return invocation.argumentList.arguments[0];
3795 } 3794 }
3796 3795
3797 { 3796 {
3798 Expression argument = find42(); 3797 Expression argument = find42();
3799 expect(argument.staticParameterElement, isNull); 3798 expect(argument.staticParameterElement, isNull);
3800 expect(argument.propagatedParameterElement, isNotNull);
3801 } 3799 }
3800
3802 // Update a.dart: add type annotation for 'a'. 3801 // Update a.dart: add type annotation for 'a'.
3803 // '42' has 'staticParameterElement', but not 'propagatedParameterElement'. 3802 // '42' has 'staticParameterElement'.
3804 context.setContents( 3803 context.setContents(
3805 a, 3804 a,
3806 r''' 3805 r'''
3807 class A { 3806 class A {
3808 foo(int p) {} 3807 foo(int p) {}
3809 } 3808 }
3810 final A a = new A(); 3809 final A a = new A();
3811 main() { 3810 main() {
3812 a.foo(42); 3811 a.foo(42);
3813 } 3812 }
3814 '''); 3813 ''');
3815 _performPendingAnalysisTasks(); 3814 _performPendingAnalysisTasks();
3816 { 3815 {
3817 Expression argument = find42(); 3816 Expression argument = find42();
3818 expect(argument.staticParameterElement, isNotNull); 3817 expect(argument.staticParameterElement, isNotNull);
3819 expect(argument.propagatedParameterElement, isNull);
3820 } 3818 }
3819
3821 // Update a.dart: remove type annotation for 'a'. 3820 // Update a.dart: remove type annotation for 'a'.
3822 // '42' has 'propagatedParameterElement', but not 'staticParameterElement'. 3821 // '42' doesn't have 'staticParameterElement'.
3823 context.setContents( 3822 context.setContents(
3824 a, 3823 a,
3825 r''' 3824 r'''
3826 class A { 3825 class A {
3827 foo(int p) {} 3826 foo(int p) {}
3828 } 3827 }
3829 final a = new A(); 3828 final a = new A();
3830 main() { 3829 main() {
3831 a.foo(42); 3830 a.foo(42);
3832 } 3831 }
3833 '''); 3832 ''');
3834 _performPendingAnalysisTasks(); 3833 _performPendingAnalysisTasks();
3835 { 3834 {
3836 Expression argument = find42(); 3835 Expression argument = find42();
3837 expect(argument.staticParameterElement, isNull); 3836 expect(argument.staticParameterElement, isNull);
3838 expect(argument.propagatedParameterElement, isNotNull);
3839 } 3837 }
3840 } 3838 }
3841 3839
3842 void test_sequence_closureParameterTypesPropagation() { 3840 void test_sequence_closureParameterTypesPropagation() {
3843 Source a = addSource( 3841 Source a = addSource(
3844 '/a.dart', 3842 '/a.dart',
3845 r''' 3843 r'''
3846 main() { 3844 main() {
3847 f((p) => 4.2); 3845 f((p) => 4.2);
3848 } 3846 }
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
5250 * Initialize the visitor. 5248 * Initialize the visitor.
5251 */ 5249 */
5252 _ElementGatherer(); 5250 _ElementGatherer();
5253 5251
5254 @override 5252 @override
5255 void visitElement(Element element) { 5253 void visitElement(Element element) {
5256 elements[element] = element; 5254 elements[element] = element;
5257 super.visitElement(element); 5255 super.visitElement(element);
5258 } 5256 }
5259 } 5257 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | pkg/analyzer/test/src/summary/summarize_ast_strong_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698