Skip to content

Commit 53895b2

Browse files
Markzipancommit-bot@chromium.org
authored andcommitted
[dartdevc] Fixing issue related to dual exports of multiple entrypoints in a cyclic import loop.
See: flutter/flutter#64011 Change-Id: I8a11e9d3f19428a516cf7a60ee45c3bacf26545d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162383 Commit-Queue: Mark Zhou <[email protected]> Reviewed-by: Nicholas Shahan <[email protected]>
1 parent a080545 commit 53895b2

File tree

6 files changed

+44
-2
lines changed

6 files changed

+44
-2
lines changed

pkg/dev_compiler/lib/src/kernel/compiler.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,16 +867,21 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
867867
var savedTopLevelClass = _classEmittingExtends;
868868
_classEmittingExtends = c;
869869

870-
// Unroll mixins.
870+
// Refers to 'S' in `class C extends S`. Set this to null to avoid
871+
// referencing deferred supertypes in _emitClassConstructor's JS output.
872+
js_ast.Expression baseClass;
873+
871874
if (shouldDefer(supertype)) {
872875
deferredSupertypes.add(runtimeStatement('setBaseClass(#, #)', [
873876
getBaseClass(isMixinAliasClass(c) ? 0 : mixins.length),
874877
emitDeferredType(supertype),
875878
]));
879+
// Refers to 'supertype' without any type arguments.
876880
supertype =
877881
_coreTypes.rawType(supertype.classNode, _currentLibrary.nonNullable);
882+
} else {
883+
baseClass = emitClassRef(supertype);
878884
}
879-
var baseClass = emitClassRef(supertype);
880885

881886
if (isMixinAliasClass(c)) {
882887
// Given `class C = Object with M [implements I1, I2 ...];`
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import 'dual_export_triangle_b.dart';
2+
3+
class A extends B {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import 'dual_export_triangle_c.dart';
2+
3+
class B extends C {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'dual_export_triangle_a.dart';
2+
3+
class C0<T> {}
4+
5+
class C extends C0<A> {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import 'dual_export_triangle_a.dart';
2+
3+
class Entrypoint {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Test for cyclic export regression seen in: https://github.com/flutter/flutter/issues/64011
6+
7+
// dual_export_triangle_entrypoint imports dual_export_triangle_a.
8+
// dual_export_triangle_a defines A (extends B).
9+
// dual_export_triangle_b defines B (extends C).
10+
// dual_export_triangle_c defines C (with type parameter A).
11+
// dual_export_triangle_test exports both dual_export_triangle_entrypoint and
12+
// either dual_export_triangle_b or dual_export_triangle_c.
13+
14+
library dual_export_triangle_test;
15+
16+
import 'dual_export_triangle_entrypoint.dart';
17+
18+
export 'dual_export_triangle_entrypoint.dart';
19+
export 'dual_export_triangle_b.dart';
20+
21+
main() {
22+
print(Entrypoint());
23+
}

0 commit comments

Comments
 (0)