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

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

Issue 1989943002: Fix linker's handling of malformed function references. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Revert unnecessary method rename Created 4 years, 7 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 import 'package:analyzer/dart/element/type.dart'; 5 import 'package:analyzer/dart/element/type.dart';
6 import 'package:analyzer/src/dart/element/element.dart'; 6 import 'package:analyzer/src/dart/element/element.dart';
7 import 'package:analyzer/src/summary/format.dart'; 7 import 'package:analyzer/src/summary/format.dart';
8 import 'package:analyzer/src/summary/idl.dart';
8 import 'package:analyzer/src/summary/link.dart'; 9 import 'package:analyzer/src/summary/link.dart';
9 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
10 11
11 import '../../reflective_tests.dart'; 12 import '../../reflective_tests.dart';
12 import 'summarize_ast_test.dart'; 13 import 'summarize_ast_test.dart';
13 14
14 main() { 15 main() {
15 groupSep = ' | '; 16 groupSep = ' | ';
16 runReflectiveTests(LinkerUnitTest); 17 runReflectiveTests(LinkerUnitTest);
17 } 18 }
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 addNamedSource('/b.dart', ''); 599 addNamedSource('/b.dart', '');
599 createLinker('import "a.dart"; import "b.dart";'); 600 createLinker('import "a.dart"; import "b.dart";');
600 LibraryElementForLink libA = getLibrary('file:///a.dart'); 601 LibraryElementForLink libA = getLibrary('file:///a.dart');
601 LibraryElementForLink libB = getLibrary('file:///b.dart'); 602 LibraryElementForLink libB = getLibrary('file:///b.dart');
602 LibraryCycleForLink libraryCycle = testLibrary.libraryCycleForLink; 603 LibraryCycleForLink libraryCycle = testLibrary.libraryCycleForLink;
603 expect(libraryCycle.dependencies, 604 expect(libraryCycle.dependencies,
604 unorderedEquals([libA.libraryCycleForLink, libB.libraryCycleForLink])); 605 unorderedEquals([libA.libraryCycleForLink, libB.libraryCycleForLink]));
605 expect(libraryCycle.libraries, [testLibrary]); 606 expect(libraryCycle.libraries, [testLibrary]);
606 } 607 }
607 608
609 void test_malformed_function_reference() {
610 // Create a corrupted package bundle in which the inferred type of `x`
611 // refers to a non-existent local function.
612 var bundle = createPackageBundle('var x = () {}', path: '/a.dart');
613 expect(bundle.linkedLibraries, hasLength(1));
614 expect(bundle.linkedLibraries[0].units, hasLength(1));
615 for (LinkedReferenceBuilder ref
616 in bundle.linkedLibraries[0].units[0].references) {
617 if (ref.kind == ReferenceKind.function) {
618 ref.localIndex = 1234;
619 }
620 }
621 addBundle(bundle);
622 createLinker('''
623 import 'a.dart';
624 var y = x;
625 ''');
626 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
627 expect(
628 library
629 .getContainedName('y')
630 .asTypeInferenceNode
631 .variableElement
632 .inferredType
633 .toString(),
634 'dynamic');
635 }
636
608 void test_multiplyInheritedExecutable_differentSignatures() { 637 void test_multiplyInheritedExecutable_differentSignatures() {
609 createLinker(''' 638 createLinker('''
610 class B { 639 class B {
611 void f() {} 640 void f() {}
612 } 641 }
613 abstract class I { 642 abstract class I {
614 f(); 643 f();
615 } 644 }
616 class C extends B with I {} 645 class C extends B with I {}
617 class D extends C { 646 class D extends C {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 TypeParameterElementImpl t = c.typeParameters[0]; 746 TypeParameterElementImpl t = c.typeParameters[0];
718 TypeParameterElementImpl u = c.typeParameters[1]; 747 TypeParameterElementImpl u = c.typeParameters[1];
719 TypeParameterElementImpl v = d.typeParameters[0]; 748 TypeParameterElementImpl v = d.typeParameters[0];
720 TypeParameterElementImpl w = d.typeParameters[1]; 749 TypeParameterElementImpl w = d.typeParameters[1];
721 expect(c.isTypeParameterInScope(v), false); 750 expect(c.isTypeParameterInScope(v), false);
722 expect(c.isTypeParameterInScope(w), false); 751 expect(c.isTypeParameterInScope(w), false);
723 expect(d.isTypeParameterInScope(t), false); 752 expect(d.isTypeParameterInScope(t), false);
724 expect(d.isTypeParameterInScope(u), false); 753 expect(d.isTypeParameterInScope(u), false);
725 } 754 }
726 } 755 }
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