mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:13:04 +00:00
Fix summarization of closures in toplevel variable declarations in part files.
We were forgetting to include the unitNum, so it was defaulting to zero, which worked for non-part files but not for part files. R=scheglov@google.com Review URL: https://codereview.chromium.org/2416863003 .
This commit is contained in:
parent
1ee954029d
commit
809c80fa49
|
@ -1216,14 +1216,19 @@ class CompilationUnitElementInBuildUnit extends CompilationUnitElementForLink {
|
||||||
// TODO(paulberry): implement other cases as necessary
|
// TODO(paulberry): implement other cases as necessary
|
||||||
throw new UnimplementedError('${element._unlinkedExecutable.kind}');
|
throw new UnimplementedError('${element._unlinkedExecutable.kind}');
|
||||||
}
|
}
|
||||||
return addRawReference(element.name,
|
if (enclosingClass == null) {
|
||||||
numTypeParameters: element.typeParameters.length,
|
return addRawReference(element.name,
|
||||||
containingReference:
|
numTypeParameters: element.typeParameters.length,
|
||||||
enclosingClass != null ? addReference(enclosingClass) : null,
|
dependency:
|
||||||
dependency: enclosingClass != null
|
library.addDependency(element.library as LibraryElementForLink),
|
||||||
? null
|
unitNum: element.compilationUnit.unitNum,
|
||||||
: library.addDependency(element.library as LibraryElementForLink),
|
kind: kind);
|
||||||
kind: kind);
|
} else {
|
||||||
|
return addRawReference(element.name,
|
||||||
|
numTypeParameters: element.typeParameters.length,
|
||||||
|
containingReference: addReference(enclosingClass),
|
||||||
|
kind: kind);
|
||||||
|
}
|
||||||
} else if (element is FunctionElementForLink_Initializer) {
|
} else if (element is FunctionElementForLink_Initializer) {
|
||||||
return addRawReference('',
|
return addRawReference('',
|
||||||
containingReference: addReference(element.enclosingElement),
|
containingReference: addReference(element.enclosingElement),
|
||||||
|
@ -1231,6 +1236,7 @@ class CompilationUnitElementInBuildUnit extends CompilationUnitElementForLink {
|
||||||
} else if (element is TopLevelVariableElementForLink) {
|
} else if (element is TopLevelVariableElementForLink) {
|
||||||
return addRawReference(element.name,
|
return addRawReference(element.name,
|
||||||
dependency: library.addDependency(element.library),
|
dependency: library.addDependency(element.library),
|
||||||
|
unitNum: element.compilationUnit.unitNum,
|
||||||
kind: ReferenceKind.topLevelPropertyAccessor);
|
kind: ReferenceKind.topLevelPropertyAccessor);
|
||||||
} else if (element is FieldElementForLink_ClassField) {
|
} else if (element is FieldElementForLink_ClassField) {
|
||||||
ClassElementForLink_Class enclosingClass = element.enclosingElement;
|
ClassElementForLink_Class enclosingClass = element.enclosingElement;
|
||||||
|
|
|
@ -1635,6 +1635,14 @@ f() {
|
||||||
''');
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_closure_in_variable_declaration_in_part() {
|
||||||
|
addSource('/a.dart', 'part of lib; final f = (int i) => i.toDouble();');
|
||||||
|
checkLibrary('''
|
||||||
|
library lib;
|
||||||
|
part "a.dart";
|
||||||
|
''');
|
||||||
|
}
|
||||||
|
|
||||||
test_const_invalid_field_const() {
|
test_const_invalid_field_const() {
|
||||||
variablesWithNotConstInitializers.add('f');
|
variablesWithNotConstInitializers.add('f');
|
||||||
checkLibrary(
|
checkLibrary(
|
||||||
|
|
Loading…
Reference in a new issue