@@ -546,12 +546,6 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
546546 /// The list of output module items, in the order they need to be emitted in.
547547 final _moduleItems = < js_ast.ModuleItem > [];
548548
549- /// Like [_moduleItems] but for items that should be emitted after classes.
550- ///
551- /// This is used for deferred supertypes of mutually recursive non-generic
552- /// classes.
553- final _afterClassDefItems = < js_ast.ModuleItem > [];
554-
555549 /// The entrypoint method of a dynamic module, if any.
556550 Procedure ? _dynamicEntrypoint;
557551
@@ -782,8 +776,6 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
782776 _constLazyAccessors.clear ();
783777 }
784778
785- _moduleItems.addAll (_afterClassDefItems);
786- _afterClassDefItems.clear ();
787779 // Register the local const cache for this module so it can be cleared on a
788780 // hot restart.
789781 if (_constTableCache.isNotEmpty) {
@@ -1194,13 +1186,9 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
11941186 var jsProperties = _emitClassProperties (c);
11951187
11961188 _emitSuperHelperSymbols (body);
1197- // Deferred supertypes must be evaluated lazily while emitting classes to
1198- // prevent evaluating a JS expression for a deferred type from influencing
1199- // class declaration order (such as when calling 'emitDeferredType').
1200- var deferredSupertypes = < js_ast.Statement Function ()> [];
12011189
12021190 // Emit the class, e.g. `core.Object = class Object { ... }`
1203- _defineClass (c, className, jsProperties, body, deferredSupertypes );
1191+ _defineClass (c, className, jsProperties, body);
12041192 body.addAll (jsCtors);
12051193
12061194 // Emit things that come after the ES6 `class ... { ... }`.
@@ -1249,14 +1237,10 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
12491237 }
12501238
12511239 var typeFormals = c.typeParameters;
1252- var evaluatedDeferredSupertypes =
1253- deferredSupertypes.map< js_ast.Statement > ((f) => f ()).toList ();
12541240 if (typeFormals.isNotEmpty) {
1255- var genericClassStmts = _defineGenericClass (typeFormals,
1256- js_ast.Statement .from (body), evaluatedDeferredSupertypes );
1241+ var genericClassStmts =
1242+ _defineGenericClass (typeFormals, js_ast.Statement .from (body));
12571243 body = [...genericClassStmts];
1258- } else {
1259- _afterClassDefItems.addAll (evaluatedDeferredSupertypes);
12601244 }
12611245
12621246 if (c == _coreTypes.objectClass) {
@@ -1324,7 +1308,7 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
13241308 var typeFormals = c.typeParameters;
13251309 if (typeFormals.isNotEmpty) {
13261310 var genericClassStmts =
1327- _defineGenericClass (typeFormals, js_ast.Statement .from (body), [] );
1311+ _defineGenericClass (typeFormals, js_ast.Statement .from (body));
13281312 body = genericClassStmts;
13291313 }
13301314 return js_ast.Statement .from (body);
@@ -1333,13 +1317,12 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
13331317 }
13341318
13351319 /// Emits a generic class with additional initialization logic.
1336- List <js_ast.Statement > _defineGenericClass (List < TypeParameter > formals,
1337- js_ast. Statement body, List < js_ast.Statement > deferredBaseClass ) {
1320+ List <js_ast.Statement > _defineGenericClass (
1321+ List < TypeParameter > formals, js_ast.Statement body ) {
13381322 assert (formals.isNotEmpty);
13391323 return [
13401324 ..._typeTable.dischargeFreeTypes (formals),
13411325 body,
1342- ...deferredBaseClass,
13431326 ];
13441327 }
13451328
@@ -1423,12 +1406,11 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
14231406 ]));
14241407 }
14251408
1426- void _defineClass (
1427- Class c,
1428- js_ast.Expression className,
1429- List <js_ast.Property > properties,
1430- List <js_ast.Statement > body,
1431- List <js_ast.Statement Function ()> deferredSupertypes) {
1409+ /// Emits code required to represent [c] as a series of statements in [body] .
1410+ ///
1411+ /// [properties] holds methods, fields, or properties in [c] .
1412+ void _defineClass (Class c, js_ast.Expression className,
1413+ List <js_ast.Property > properties, List <js_ast.Statement > body) {
14321414 if (c == _coreTypes.objectClass) {
14331415 body.add (_emitClassStatement (c, className, null , properties));
14341416 return ;
@@ -3328,12 +3310,6 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
33283310 init is BasicLiteral ||
33293311 init is ConstructorInvocation && isInternalConstructor (init) ||
33303312 init is StaticInvocation && isInlineJS (init.target)) {
3331- if (init is ConstructorInvocation ) {
3332- // This is an eagerly executed constructor invocation. We need to
3333- // ensure the class is emitted before this statement.
3334- var type = init.getStaticType (_staticTypeContext) as InterfaceType ;
3335- _emitClass (type.classNode);
3336- }
33373313 _currentUri = field.fileUri;
33383314 _moduleItems.add (js.statement ('# = #;' , [
33393315 _emitTopLevelName (field),
0 commit comments