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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_common.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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/summary/resynthesize_common.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index f895e76462b96442cfa23981370d770e4d0b23db..5d353bb705ba278b8413c69ed735f38a7066787a 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -682,6 +682,28 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest {
compareConstAsts(resynthesized.annotationAst, original.annotationAst, desc);
}
+ void compareElementLocations(
+ Element resynthesized, Element original, String desc) {
+ bool hasFunctionElementByValue(Element e) {
+ if (e == null) {
+ return false;
+ }
+ if (e is FunctionElementImpl_forLUB) {
+ return true;
+ }
+ return hasFunctionElementByValue(e.enclosingElement);
+ }
+
+ if (hasFunctionElementByValue(resynthesized)) {
+ // We resynthesize elements representing types of local functions
+ // without corresponding name offsets, so their locations don't have
+ // corresponding valid @offset components. Also, we don't put
+ // resynthesized local functions into initializers of variables.
+ return;
+ }
+ expect(resynthesized.location, original.location, reason: desc);
+ }
+
void compareElements(Element resynthesized, Element original, String desc) {
ElementImpl rImpl = getActualElement(resynthesized, desc);
ElementImpl oImpl = getActualElement(original, desc);
@@ -710,7 +732,7 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest {
expect(rRuntimeType, oImpl.runtimeType);
}
expect(resynthesized.kind, original.kind);
- expect(resynthesized.location, original.location, reason: desc);
+ compareElementLocations(resynthesized, original, desc);
expect(resynthesized.name, original.name);
expect(resynthesized.nameOffset, original.nameOffset,
reason: '$desc.nameOffset');
@@ -1030,8 +1052,8 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest {
void compareTypeImpls(
TypeImpl resynthesized, TypeImpl original, String desc) {
- expect(resynthesized.element.location, original.element.location,
- reason: '$desc.element.location');
+ compareElementLocations(
+ resynthesized.element, original.element, '$desc.element.location');
expect(resynthesized.name, original.name, reason: '$desc.name');
}
@@ -3162,12 +3184,12 @@ dynamic f() {}
}
test_closure_generic() {
- var library = checkLibrary('final f = <U, V>(U x, V y) => y;');
+ var library = checkLibrary('final f = <U, V extends int>(U x, V y) => y;');
if (isStrongMode) {
checkElementText(
library,
r'''
-final <U,V>(U, V) → V f;
+final <U,V extends int>(U, V) → V f;
''');
} else {
checkElementText(

Powered by Google App Engine
This is Rietveld 408576698