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

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

Issue 2974803002: Store FunctionType(s) of local functions by value. (Closed)
Patch Set: Created 3 years, 5 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 '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/idl.dart';
9 import 'package:analyzer/src/summary/link.dart'; 9 import 'package:analyzer/src/summary/link.dart';
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 addNamedSource('/b.dart', ''); 811 addNamedSource('/b.dart', '');
812 createLinker('import "a.dart"; import "b.dart";'); 812 createLinker('import "a.dart"; import "b.dart";');
813 LibraryElementForLink libA = getLibrary('file:///a.dart'); 813 LibraryElementForLink libA = getLibrary('file:///a.dart');
814 LibraryElementForLink libB = getLibrary('file:///b.dart'); 814 LibraryElementForLink libB = getLibrary('file:///b.dart');
815 LibraryCycleForLink libraryCycle = testLibrary.libraryCycleForLink; 815 LibraryCycleForLink libraryCycle = testLibrary.libraryCycleForLink;
816 expect(libraryCycle.dependencies, 816 expect(libraryCycle.dependencies,
817 unorderedEquals([libA.libraryCycleForLink, libB.libraryCycleForLink])); 817 unorderedEquals([libA.libraryCycleForLink, libB.libraryCycleForLink]));
818 expect(libraryCycle.libraries, [testLibrary]); 818 expect(libraryCycle.libraries, [testLibrary]);
819 } 819 }
820 820
821 void test_malformed_function_reference() {
822 // Create a corrupted package bundle in which the inferred type of `x`
823 // refers to a non-existent local function.
824 var bundle = createPackageBundle('var x = () {}', path: '/a.dart');
825 expect(bundle.linkedLibraries, hasLength(1));
826 expect(bundle.linkedLibraries[0].units, hasLength(1));
827 for (LinkedReferenceBuilder ref
828 in bundle.linkedLibraries[0].units[0].references) {
829 if (ref.kind == ReferenceKind.function) {
830 ref.localIndex = 1234;
831 }
832 }
833 addBundle('/a.ds', bundle);
834 createLinker('''
835 import 'a.dart';
836 var y = x;
837 ''');
838 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
839 expect(_getVariable(library.getContainedName('y')).inferredType.toString(),
840 'dynamic');
841 }
842
843 void test_multiplyInheritedExecutable_differentSignatures() { 821 void test_multiplyInheritedExecutable_differentSignatures() {
844 createLinker(''' 822 createLinker('''
845 class B { 823 class B {
846 void f() {} 824 void f() {}
847 } 825 }
848 abstract class I { 826 abstract class I {
849 f(); 827 f();
850 } 828 }
851 class C extends B with I {} 829 class C extends B with I {}
852 class D extends C { 830 class D extends C {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 */ 967 */
990 EntityRef _lookupInferredType(LinkedUnit unit, int slot) { 968 EntityRef _lookupInferredType(LinkedUnit unit, int slot) {
991 for (EntityRef ref in unit.types) { 969 for (EntityRef ref in unit.types) {
992 if (ref.slot == slot) { 970 if (ref.slot == slot) {
993 return ref; 971 return ref;
994 } 972 }
995 } 973 }
996 return null; 974 return null;
997 } 975 }
998 } 976 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698