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

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

Issue 1746963002: Follow ClassTypeAlias constructor redirections. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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) 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 import 'dart:convert'; 5 import 'dart:convert';
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/summary/format.dart'; 9 import 'package:analyzer/src/summary/format.dart';
10 import 'package:analyzer/src/summary/idl.dart'; 10 import 'package:analyzer/src/summary/idl.dart';
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 426 }
427 427
428 void test_isReferencedBy_ConstructorElement_classTypeAlias() { 428 void test_isReferencedBy_ConstructorElement_classTypeAlias() {
429 _indexTestUnit(''' 429 _indexTestUnit('''
430 class M {} 430 class M {}
431 class A implements B { 431 class A implements B {
432 A() {} 432 A() {}
433 A.named() {} 433 A.named() {}
434 } 434 }
435 class B = A with M; 435 class B = A with M;
436 class C = B with M;
436 main() { 437 main() {
437 new B(); // 1 438 new B(); // B1
438 new B.named(); // 2 439 new B.named(); // B2
440 new C(); // C1
441 new C.named(); // C2
439 } 442 }
440 '''); 443 ''');
441 ClassElement classA = findElement('A'); 444 ClassElement classA = findElement('A');
442 ConstructorElement constA = classA.constructors[0]; 445 ConstructorElement constA = classA.constructors[0];
443 ConstructorElement constA_named = classA.constructors[1]; 446 ConstructorElement constA_named = classA.constructors[1];
444 assertThat(constA).isReferencedAt('(); // 1', length: 0); 447 assertThat(constA)
445 assertThat(constA_named).isReferencedAt('.named(); // 2', length: 6); 448 ..isReferencedAt('(); // B1', length: 0)
449 ..isReferencedAt('(); // C1', length: 0);
450 assertThat(constA_named)
451 ..isReferencedAt('.named(); // B2', length: 6)
452 ..isReferencedAt('.named(); // C2', length: 6);
453 }
454
455 void test_isReferencedBy_ConstructorElement_classTypeAlias_cycle() {
456 _indexTestUnit('''
457 class M {}
458 class A = B with M;
459 class B = A with M;
460 main() {
461 new A();
462 new B();
463 }
464 ''');
465 // No additional validation, but it should not fail with stack overflow.
446 } 466 }
447 467
448 void test_isReferencedBy_ConstructorElement_redirection() { 468 void test_isReferencedBy_ConstructorElement_redirection() {
449 _indexTestUnit(''' 469 _indexTestUnit('''
450 class A { 470 class A {
451 A() : this.bar(); // 1 471 A() : this.bar(); // 1
452 A.foo() : this(); // 2 472 A.foo() : this(); // 2
453 A.bar(); 473 A.bar();
454 } 474 }
455 '''); 475 ''');
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 test._expectedLocation(search, length: length)); 784 test._expectedLocation(search, length: length));
765 } 785 }
766 786
767 void isReferencedQualifiedAt(String search, {int length}) { 787 void isReferencedQualifiedAt(String search, {int length}) {
768 test._assertHasRelation( 788 test._assertHasRelation(
769 element, 789 element,
770 IndexRelationKind.IS_REFERENCED_QUALIFIED_BY, 790 IndexRelationKind.IS_REFERENCED_QUALIFIED_BY,
771 test._expectedLocation(search, length: length)); 791 test._expectedLocation(search, length: length));
772 } 792 }
773 } 793 }
OLDNEW
« pkg/analyzer/lib/src/summary/index_unit.dart ('K') | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698