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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/linker_test.dart
diff --git a/pkg/analyzer/test/src/summary/linker_test.dart b/pkg/analyzer/test/src/summary/linker_test.dart
index 1512f75192192119688b88783adc8af6e1f93823..310039db5e99a7cbba543b93053d76f87870a980 100644
--- a/pkg/analyzer/test/src/summary/linker_test.dart
+++ b/pkg/analyzer/test/src/summary/linker_test.dart
@@ -5,6 +5,7 @@
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/summary/format.dart';
+import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/link.dart';
import 'package:unittest/unittest.dart';
@@ -605,6 +606,34 @@ var x = {
expect(libraryCycle.libraries, [testLibrary]);
}
+ void test_malformed_function_reference() {
+ // Create a corrupted package bundle in which the inferred type of `x`
+ // refers to a non-existent local function.
+ var bundle = createPackageBundle('var x = () {}', path: '/a.dart');
+ expect(bundle.linkedLibraries, hasLength(1));
+ expect(bundle.linkedLibraries[0].units, hasLength(1));
+ for (LinkedReferenceBuilder ref
+ in bundle.linkedLibraries[0].units[0].references) {
+ if (ref.kind == ReferenceKind.function) {
+ ref.localIndex = 1234;
+ }
+ }
+ addBundle(bundle);
+ createLinker('''
+import 'a.dart';
+var y = x;
+''');
+ LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
+ expect(
+ library
+ .getContainedName('y')
+ .asTypeInferenceNode
+ .variableElement
+ .inferredType
+ .toString(),
+ 'dynamic');
+ }
+
void test_multiplyInheritedExecutable_differentSignatures() {
createLinker('''
class B {
« 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