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

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

Issue 1897843003: Support for extract property for methods. (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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 class B { 287 class B {
288 int c; 288 int c;
289 } 289 }
290 var a = new A(); 290 var a = new A();
291 var v = a.b.foo.c; 291 var v = a.b.foo.c;
292 '''); 292 ''');
293 expect(unit.topLevelVariables[1].type.toString(), 'dynamic'); 293 expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
294 } 294 }
295 295
296 void test_infer_extractProperty_method() { 296 void test_infer_extractProperty_method() {
297 checkFile(r''' 297 var unit = checkFile(r'''
298 class A {
299 int m(double p1, String p2) => 42;
300 }
301 var a = new A();
302 var v = a.m;
303 ''');
304 expect(unit.topLevelVariables[1].type.toString(), '(double, String) → int');
305 }
306
307 void test_infer_extractProperty_method2() {
308 var unit = checkFile(r'''
298 var a = 1.round; 309 var a = 1.round;
299 '''); 310 ''');
311 expect(unit.topLevelVariables[0].type.toString(), '() → int');
312 }
313
314 void test_infer_extractProperty_method_sequence() {
315 var unit = checkFile(r'''
316 class A {
317 B b = new B();
318 }
319 class B {
320 C c = new C();
321 }
322 class C {
323 int m(double p1, String p2) => 42;
324 }
325 var a = new A();
326 var v = a.b.c.m;
327 ''');
328 expect(unit.topLevelVariables[1].type.toString(), '(double, String) → int');
300 } 329 }
301 330
302 void test_infer_invokeConstructor_factoryRedirected() { 331 void test_infer_invokeConstructor_factoryRedirected() {
303 checkFile(r''' 332 checkFile(r'''
304 class A { 333 class A {
305 factory A() = B; 334 factory A() = B;
306 } 335 }
307 class B implements A {} 336 class B implements A {}
308 var a = new A(); 337 var a = new A();
309 '''); 338 ''');
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 647 }
619 648
620 UnlinkedUnit definingUnit = _getUnlinkedUnit(librarySource); 649 UnlinkedUnit definingUnit = _getUnlinkedUnit(librarySource);
621 LinkedLibraryBuilder linkedLibrary = 650 LinkedLibraryBuilder linkedLibrary =
622 prelink(definingUnit, getPart, getImport); 651 prelink(definingUnit, getPart, getImport);
623 linkedLibrary.dependencies.skip(1).forEach((LinkedDependency d) { 652 linkedLibrary.dependencies.skip(1).forEach((LinkedDependency d) {
624 _serializeLibrary(resolveRelativeUri(d.uri)); 653 _serializeLibrary(resolveRelativeUri(d.uri));
625 }); 654 });
626 } 655 }
627 } 656 }
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