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

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

Issue 2365053003: fix #27421, DDC did not generate implicit super calls in some cases (Closed)
Patch Set: Created 4 years, 3 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/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 54f4b6fd5741d5b8f1aecfdb910a2a55b657e225..1b306a74106e06b1567709c1048fa146950435f5 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -1884,8 +1884,6 @@ class CodeGenerator extends GeneralizingAstVisitor
ClassDeclaration node,
List<FieldDeclaration> fields,
Map<FieldElement, JS.TemporaryId> virtualFields) {
- assert(_hasUnnamedConstructor(node.element) == fields.isNotEmpty);
-
// If we don't have a method body, skip this.
var superCall = _superConstructorCall(node.element);
if (fields.isEmpty && superCall == null) return null;
@@ -2059,7 +2057,7 @@ class CodeGenerator extends GeneralizingAstVisitor
return null;
}
- if (superCtor.name == '' && !_shouldCallUnnamedSuperCtor(element)) {
+ if (superCtor.name == '' && !_hasUnnamedSuperConstructor(element)) {
return null;
}
@@ -2068,7 +2066,7 @@ class CodeGenerator extends GeneralizingAstVisitor
return annotate(js.statement('super.#(#);', [name, args]), node);
}
- bool _shouldCallUnnamedSuperCtor(ClassElement e) {
+ bool _hasUnnamedSuperConstructor(ClassElement e) {
var supertype = e.supertype;
if (supertype == null) return false;
if (_hasUnnamedConstructor(supertype.element)) return true;
@@ -2081,7 +2079,8 @@ class CodeGenerator extends GeneralizingAstVisitor
bool _hasUnnamedConstructor(ClassElement e) {
if (e.type.isObject) return false;
if (!e.unnamedConstructor.isSynthetic) return true;
- return e.fields.any((f) => !f.isStatic && !f.isSynthetic);
+ if (e.fields.any((f) => !f.isStatic && !f.isSynthetic)) return true;
+ return _hasUnnamedSuperConstructor(e);
}
/// Initialize fields. They follow the sequence:

Powered by Google App Engine
This is Rietveld 408576698