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

Unified Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 3011763002: fix #30591, ensure all extension methods are generated (Closed)
Patch Set: Created 3 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index 8c56a4bef6397a14ac745f0478274c472cc5d504..e2552798ef4753d54ddc48977344feef0937fdb1 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -963,6 +963,7 @@ class CodeGenerator extends Object
_emitVirtualFieldSymbols(classElem, body);
_emitClassSignature(methods, allFields, classElem, ctors, className, body);
+ _initExtensionSymbols(classElem, methods, fields);
_defineExtensionMembers(className, body);
_emitClassMetadata(node.metadata, className, body);
@@ -1982,6 +1983,30 @@ class CodeGenerator extends Object
}
}
+ /// Ensure `dartx.` symbols we will use are present.
+ void _initExtensionSymbols(ClassElement classElem,
+ List<MethodDeclaration> methods, List<FieldDeclaration> fields) {
+ if (_extensionTypes.hasNativeSubtype(classElem.type)) {
+ for (var m in methods) {
+ if (!m.isAbstract &&
+ !m.isStatic &&
+ resolutionMap.elementDeclaredByMethodDeclaration(m).isPublic) {
+ _declareMemberName(m.element, useExtension: true);
Jennifer Messerly 2017/08/31 21:00:48 FYI, this is mostly the original code, restored fr
+ }
+ }
+ for (var fieldDecl in fields) {
+ if (!fieldDecl.isStatic) {
+ for (var field in fieldDecl.fields.variables) {
+ var e = field.element as FieldElement;
+ if (e.isPublic) {
+ _declareMemberName(e.getter, useExtension: true);
+ }
+ }
+ }
+ }
+ }
+ }
+
/// If a concrete class implements one of our extensions, we might need to
/// add forwarders.
void _defineExtensionMembers(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698