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

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

Issue 2187863003: Always set correspondingStaticParameters and correspondingPropagatedParameters, to clear when we don (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/element_resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3475 matching lines...) Expand 10 before | Expand all | Expand 10 after
3486 _assertValidForChangedLibrary(a); 3486 _assertValidForChangedLibrary(a);
3487 _assertInvalid(a, LIBRARY_ERRORS_READY); 3487 _assertInvalid(a, LIBRARY_ERRORS_READY);
3488 _assertValidForDependentLibrary(b); 3488 _assertValidForDependentLibrary(b);
3489 _assertValidAllResolution(b); 3489 _assertValidAllResolution(b);
3490 _assertInvalidHintsVerifyErrors(b); 3490 _assertInvalidHintsVerifyErrors(b);
3491 3491
3492 _performPendingAnalysisTasks(); 3492 _performPendingAnalysisTasks();
3493 expect(context.getErrors(b).errors, hasLength(1)); 3493 expect(context.getErrors(b).errors, hasLength(1));
3494 } 3494 }
3495 3495
3496 void test_sequence_clearParameterElements() {
3497 Source a = addSource(
3498 '/a.dart',
3499 r'''
3500 class A {
3501 foo(int p) {}
3502 }
3503 final a = new A();
3504 main() {
3505 a.foo(42);
3506 }
3507 ''');
3508 _performPendingAnalysisTasks();
3509 Expression find42() {
3510 CompilationUnit unit =
3511 context.getResult(new LibrarySpecificUnit(a, a), RESOLVED_UNIT);
3512 ExpressionStatement statement =
3513 AstFinder.getStatementsInTopLevelFunction(unit, 'main').single;
3514 MethodInvocation invocation = statement.expression;
3515 return invocation.argumentList.arguments[0];
3516 }
3517 {
3518 Expression argument = find42();
3519 expect(argument.staticParameterElement, isNull);
3520 expect(argument.propagatedParameterElement, isNotNull);
3521 }
3522 // Update a.dart: add type annotation for 'a'.
3523 // '42' has 'staticParameterElement', but not 'propagatedParameterElement'.
3524 context.setContents(
3525 a,
3526 r'''
3527 class A {
3528 foo(int p) {}
3529 }
3530 final A a = new A();
3531 main() {
3532 a.foo(42);
3533 }
3534 ''');
3535 _performPendingAnalysisTasks();
3536 {
3537 Expression argument = find42();
3538 expect(argument.staticParameterElement, isNotNull);
3539 expect(argument.propagatedParameterElement, isNull);
3540 }
3541 // Update a.dart: remove type annotation for 'a'.
3542 // '42' has 'propagatedParameterElement', but not 'staticParameterElement'.
3543 context.setContents(
3544 a,
3545 r'''
3546 class A {
3547 foo(int p) {}
3548 }
3549 final a = new A();
3550 main() {
3551 a.foo(42);
3552 }
3553 ''');
3554 _performPendingAnalysisTasks();
3555 {
3556 Expression argument = find42();
3557 expect(argument.staticParameterElement, isNull);
3558 expect(argument.propagatedParameterElement, isNotNull);
3559 }
3560 }
3561
3496 void test_sequence_closureParameterTypesPropagation() { 3562 void test_sequence_closureParameterTypesPropagation() {
3497 Source a = addSource( 3563 Source a = addSource(
3498 '/a.dart', 3564 '/a.dart',
3499 r''' 3565 r'''
3500 main() { 3566 main() {
3501 f((p) => 4.2); 3567 f((p) => 4.2);
3502 } 3568 }
3503 f(c(int p)) {} 3569 f(c(int p)) {}
3504 '''); 3570 ''');
3505 _performPendingAnalysisTasks(); 3571 _performPendingAnalysisTasks();
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
4715 * Initialize the visitor. 4781 * Initialize the visitor.
4716 */ 4782 */
4717 _ElementGatherer(); 4783 _ElementGatherer();
4718 4784
4719 @override 4785 @override
4720 void visitElement(Element element) { 4786 void visitElement(Element element) {
4721 elements[element] = element; 4787 elements[element] = element;
4722 super.visitElement(element); 4788 super.visitElement(element);
4723 } 4789 }
4724 } 4790 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/element_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698