[cfe] fix the export of inline class
Bug: #51516
Change-Id: I56d61125b4a9cba55f94e15dbd82289c4fd42214
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285262
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index aea7a6cc..4c9f741 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -1461,6 +1461,8 @@
}
if (memberLast is ClassBuilder) {
library.additionalExports.add(memberLast.cls.reference);
+ } else if (memberLast is InlineClassBuilder) {
+ library.additionalExports.add(memberLast.inlineClass.reference);
} else if (memberLast is TypeAliasBuilder) {
library.additionalExports.add(memberLast.typedef.reference);
} else if (memberLast is ExtensionBuilder) {
diff --git a/pkg/front_end/testcases/inline_class/has_export.dart b/pkg/front_end/testcases/inline_class/has_export.dart
new file mode 100644
index 0000000..78ef8f4
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_export.dart
@@ -0,0 +1,7 @@
+// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+export 'has_part_lib.dart';
+
+void main() {}
diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.strong.expect b/pkg/front_end/testcases/inline_class/has_export.dart.strong.expect
new file mode 100644
index 0000000..3482bb2
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_export.dart.strong.expect
@@ -0,0 +1,24 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "has_part_lib.dart" as has;
+additionalExports = (has::C)
+
+export "org-dartlang-testcase:///has_part_lib.dart";
+
+static method main() → void {}
+
+library /*isNonNullableByDefault*/;
+import self as has;
+import "dart:core" as core;
+
+part has_part_of_lib.dart;
+inline class C /* declaredRepresentationType = core::int */ { // from org-dartlang-testcase:///has_part_of_lib.dart
+ constructor • = has::C|;
+ tearoff • = has::_#new#tearOff;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C {
+ final has::C #this = i;
+ return #this;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C
+ return has::C|(i);
diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.strong.transformed.expect b/pkg/front_end/testcases/inline_class/has_export.dart.strong.transformed.expect
new file mode 100644
index 0000000..3482bb2
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_export.dart.strong.transformed.expect
@@ -0,0 +1,24 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "has_part_lib.dart" as has;
+additionalExports = (has::C)
+
+export "org-dartlang-testcase:///has_part_lib.dart";
+
+static method main() → void {}
+
+library /*isNonNullableByDefault*/;
+import self as has;
+import "dart:core" as core;
+
+part has_part_of_lib.dart;
+inline class C /* declaredRepresentationType = core::int */ { // from org-dartlang-testcase:///has_part_of_lib.dart
+ constructor • = has::C|;
+ tearoff • = has::_#new#tearOff;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C {
+ final has::C #this = i;
+ return #this;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C
+ return has::C|(i);
diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.textual_outline.expect b/pkg/front_end/testcases/inline_class/has_export.dart.textual_outline.expect
new file mode 100644
index 0000000..2a7131b
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_export.dart.textual_outline.expect
@@ -0,0 +1,3 @@
+export 'has_part_lib.dart';
+
+void main() {}
diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/inline_class/has_export.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..2a7131b
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_export.dart.textual_outline_modelled.expect
@@ -0,0 +1,3 @@
+export 'has_part_lib.dart';
+
+void main() {}
diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.weak.expect b/pkg/front_end/testcases/inline_class/has_export.dart.weak.expect
new file mode 100644
index 0000000..3482bb2
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_export.dart.weak.expect
@@ -0,0 +1,24 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "has_part_lib.dart" as has;
+additionalExports = (has::C)
+
+export "org-dartlang-testcase:///has_part_lib.dart";
+
+static method main() → void {}
+
+library /*isNonNullableByDefault*/;
+import self as has;
+import "dart:core" as core;
+
+part has_part_of_lib.dart;
+inline class C /* declaredRepresentationType = core::int */ { // from org-dartlang-testcase:///has_part_of_lib.dart
+ constructor • = has::C|;
+ tearoff • = has::_#new#tearOff;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C {
+ final has::C #this = i;
+ return #this;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C
+ return has::C|(i);
diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.weak.modular.expect b/pkg/front_end/testcases/inline_class/has_export.dart.weak.modular.expect
new file mode 100644
index 0000000..3482bb2
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_export.dart.weak.modular.expect
@@ -0,0 +1,24 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "has_part_lib.dart" as has;
+additionalExports = (has::C)
+
+export "org-dartlang-testcase:///has_part_lib.dart";
+
+static method main() → void {}
+
+library /*isNonNullableByDefault*/;
+import self as has;
+import "dart:core" as core;
+
+part has_part_of_lib.dart;
+inline class C /* declaredRepresentationType = core::int */ { // from org-dartlang-testcase:///has_part_of_lib.dart
+ constructor • = has::C|;
+ tearoff • = has::_#new#tearOff;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C {
+ final has::C #this = i;
+ return #this;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C
+ return has::C|(i);
diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.weak.outline.expect b/pkg/front_end/testcases/inline_class/has_export.dart.weak.outline.expect
new file mode 100644
index 0000000..560a6de
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_export.dart.weak.outline.expect
@@ -0,0 +1,23 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "has_part_lib.dart" as has;
+additionalExports = (has::C)
+
+export "org-dartlang-testcase:///has_part_lib.dart";
+
+static method main() → void
+ ;
+
+library /*isNonNullableByDefault*/;
+import self as has;
+import "dart:core" as core;
+
+part has_part_of_lib.dart;
+inline class C /* declaredRepresentationType = core::int */ { // from org-dartlang-testcase:///has_part_of_lib.dart
+ constructor • = has::C|;
+ tearoff • = has::_#new#tearOff;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C
+ ;
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C
+ return has::C|(i);
diff --git a/pkg/front_end/testcases/inline_class/has_export.dart.weak.transformed.expect b/pkg/front_end/testcases/inline_class/has_export.dart.weak.transformed.expect
new file mode 100644
index 0000000..3482bb2
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_export.dart.weak.transformed.expect
@@ -0,0 +1,24 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "has_part_lib.dart" as has;
+additionalExports = (has::C)
+
+export "org-dartlang-testcase:///has_part_lib.dart";
+
+static method main() → void {}
+
+library /*isNonNullableByDefault*/;
+import self as has;
+import "dart:core" as core;
+
+part has_part_of_lib.dart;
+inline class C /* declaredRepresentationType = core::int */ { // from org-dartlang-testcase:///has_part_of_lib.dart
+ constructor • = has::C|;
+ tearoff • = has::_#new#tearOff;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ C|(core::int i) → has::C {
+ final has::C #this = i;
+ return #this;
+}
+static method /* from org-dartlang-testcase:///has_part_of_lib.dart */ _#new#tearOff(core::int i) → has::C
+ return has::C|(i);
diff --git a/pkg/front_end/testcases/inline_class/has_part_lib.dart b/pkg/front_end/testcases/inline_class/has_part_lib.dart
new file mode 100644
index 0000000..4daef7c
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_part_lib.dart
@@ -0,0 +1,5 @@
+// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part 'has_part_of_lib.dart';
diff --git a/pkg/front_end/testcases/inline_class/has_part_of_lib.dart b/pkg/front_end/testcases/inline_class/has_part_of_lib.dart
new file mode 100644
index 0000000..438607d
--- /dev/null
+++ b/pkg/front_end/testcases/inline_class/has_part_of_lib.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of 'has_part_lib.dart';
+
+inline class C {
+
+ final int i;
+
+ C(this.i);
+}
diff --git a/pkg/kernel/lib/text/ast_to_text.dart b/pkg/kernel/lib/text/ast_to_text.dart
index d4ee710..8e13bbc 100644
--- a/pkg/kernel/lib/text/ast_to_text.dart
+++ b/pkg/kernel/lib/text/ast_to_text.dart
@@ -539,6 +539,10 @@
Library nodeLibrary = node.enclosingLibrary;
String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary);
write(prefix + '::' + node.name.text);
+ } else if (node is InlineClass) {
+ Library nodeLibrary = node.enclosingLibrary;
+ String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary);
+ write(prefix + '::' + node.name);
} else if (node is Procedure) {
Library nodeLibrary = node.enclosingLibrary;
String prefix = syntheticNames.nameLibraryPrefix(nodeLibrary);