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

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_ast_test.dart

Issue 1902103002: Clean up handling of declared/inferred types in ExecutableElementForLink (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/summary/link.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.summary.resynthesize_ast_test; 5 library analyzer.test.src.summary.resynthesize_ast_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/src/dart/element/element.dart'; 9 import 'package:analyzer/src/dart/element/element.dart';
10 import 'package:analyzer/src/generated/engine.dart' 10 import 'package:analyzer/src/generated/engine.dart'
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 var a = new A(); 503 var a = new A();
504 ''', 504 ''',
505 name: '/a.dart'); 505 name: '/a.dart');
506 var unit = checkFile(r''' 506 var unit = checkFile(r'''
507 import 'a.dart' as p; 507 import 'a.dart' as p;
508 var b = p.a.b.m(); 508 var b = p.a.b.m();
509 '''); 509 ''');
510 expect(unit.topLevelVariables[0].type.toString(), 'int'); 510 expect(unit.topLevelVariables[0].type.toString(), 'int');
511 } 511 }
512 512
513 void test_infer_invokeMethodRef_method_withInferredTypeInLibraryCycle() {
514 var unit = checkFile('''
515 class Base {
516 int m() => 0;
517 }
518 class A extends Base {
519 m() => 0; // Inferred return type: int
520 }
521 var a = new A();
522 var b = a.m();
523 ''');
524 // Type inference operates on static and top level variables prior to
525 // instance members. So at the time `b` is inferred, `A.m` still has return
526 // type `dynamic`.
527 expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
528 }
529
530 void test_infer_invokeMethodRef_method_withInferredTypeOutsideLibraryCycle() {
531 addFile(
532 '''
533 class Base {
534 int m() => 0;
535 }
536 class A extends Base {
537 m() => 0; // Inferred return type: int
538 }
539 ''',
540 name: '/a.dart');
541 var unit = checkFile('''
542 import 'a.dart';
543 var a = new A();
544 var b = a.m();
545 ''');
546 // Since a.dart is in a separate library file from the compilation unit
547 // containing `a` and `b`, its types are inferred first; then `a` and `b`'s
548 // types are inferred. So the inferred return type of `int` should be
549 // propagated to `b`.
550 expect(unit.topLevelVariables[1].type.toString(), 'int');
551 }
552
513 @override 553 @override
514 @failingTest 554 @failingTest
515 void test_inferCorrectlyOnMultipleVariablesDeclaredTogether() { 555 void test_inferCorrectlyOnMultipleVariablesDeclaredTogether() {
516 super.test_inferCorrectlyOnMultipleVariablesDeclaredTogether(); 556 super.test_inferCorrectlyOnMultipleVariablesDeclaredTogether();
517 } 557 }
518 558
519 @override 559 @override
520 @failingTest 560 @failingTest
521 void test_inferenceInCyclesIsDeterministic() { 561 void test_inferenceInCyclesIsDeterministic() {
522 super.test_inferenceInCyclesIsDeterministic(); 562 super.test_inferenceInCyclesIsDeterministic();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 } 801 }
762 802
763 UnlinkedUnit definingUnit = _getUnlinkedUnit(librarySource); 803 UnlinkedUnit definingUnit = _getUnlinkedUnit(librarySource);
764 LinkedLibraryBuilder linkedLibrary = 804 LinkedLibraryBuilder linkedLibrary =
765 prelink(definingUnit, getPart, getImport); 805 prelink(definingUnit, getPart, getImport);
766 linkedLibrary.dependencies.skip(1).forEach((LinkedDependency d) { 806 linkedLibrary.dependencies.skip(1).forEach((LinkedDependency d) {
767 _serializeLibrary(resolveRelativeUri(d.uri)); 807 _serializeLibrary(resolveRelativeUri(d.uri));
768 }); 808 });
769 } 809 }
770 } 810 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698