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

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

Issue 1895903002: emit 'this.x' when 'super.x' accesses a field (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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 | test/codegen/expect/language-all.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/compiler/code_generator.dart
diff --git a/lib/src/compiler/code_generator.dart b/lib/src/compiler/code_generator.dart
index ca56b1f7938fadaa362d2916ea0bc13415cc0d81..199a629e74a9a4fbdc601c56b03680ae25dd8ca9 100644
--- a/lib/src/compiler/code_generator.dart
+++ b/lib/src/compiler/code_generator.dart
@@ -2963,7 +2963,7 @@ class CodeGenerator extends GeneralizingAstVisitor
if (isLibraryPrefix(node.prefix)) {
return _visit(node.identifier);
} else {
- return _emitGet(node.prefix, node.identifier);
+ return _emitAccess(node.prefix, node.identifier);
}
}
@@ -2972,7 +2972,7 @@ class CodeGenerator extends GeneralizingAstVisitor
if (node.operator.lexeme == '?.') {
return _emitNullSafe(node);
}
- return _emitGet(_getTarget(node), node.propertyName);
+ return _emitAccess(_getTarget(node), node.propertyName);
}
JS.Expression _emitNullSafe(Expression node) {
@@ -3042,7 +3042,7 @@ class CodeGenerator extends GeneralizingAstVisitor
}
/// Shared code for [PrefixedIdentifier] and [PropertyAccess].
- JS.Expression _emitGet(Expression target, SimpleIdentifier memberId) {
+ JS.Expression _emitAccess(Expression target, SimpleIdentifier memberId) {
var member = memberId.staticElement;
if (member is PropertyAccessorElement) {
member = (member as PropertyAccessorElement).variable;
@@ -3054,6 +3054,14 @@ class CodeGenerator extends GeneralizingAstVisitor
return js.call('dart.dload(#, #)', [_visit(target), name]);
}
+ if (target is SuperExpression &&
+ member is FieldElement &&
+ !member.isSynthetic) {
+ // If super.x is actually a field, then x is an instance property since
+ // subclasses cannot override x.
+ return js.call('this.#', [name]);
+ }
+
String code;
if (member != null && member is MethodElement && !isStatic) {
// Tear-off methods: explicitly bind it.
« no previous file with comments | « no previous file | test/codegen/expect/language-all.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698