Skip to content

Commit 3d22f36

Browse files
MarkzipanCommit Queue
authored andcommitted
[ddc] Fixing cross module private name symbols redefining each other when used as function default values.
Fixes #60968 Change-Id: I0686da16b182f8a42e5fa0b55ced918671bdedca Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436001 Reviewed-by: Nicholas Shahan <[email protected]> Commit-Queue: Mark Zhou <[email protected]>
1 parent 2b1cbb0 commit 3d22f36

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8323,7 +8323,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
83238323

83248324
@override
83258325
js_ast.Expression visitSymbolConstant(SymbolConstant node) =>
8326-
_emitDartSymbol(node.name);
8326+
_emitDartSymbol(node.name, library: node.libraryReference?.asLibrary);
83278327

83288328
@override
83298329
js_ast.Expression visitMapConstant(MapConstant node) {
@@ -8767,15 +8767,17 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
87678767
/// Emits a Dart Symbol with the given member [symbolName].
87688768
///
87698769
/// If the symbol refers to a private name, its library will be set to the
8770-
/// [currentLibrary], so the Symbol is scoped properly.
8771-
js_ast.Expression _emitDartSymbol(String symbolName) {
8770+
/// [currentLibrary] by default, so the Symbol is scoped properly. Symbol
8771+
/// constants should pass the symbol's [library] if the referenced symbol was
8772+
/// declared outside the current library.
8773+
js_ast.Expression _emitDartSymbol(String symbolName, {Library? library}) {
87728774
// TODO(vsm): Handle qualified symbols correctly.
87738775
var last = symbolName.split('.').last;
87748776
var name = js.escapedString(symbolName, "'");
87758777
js_ast.Expression result;
87768778
if (last.startsWith('_')) {
87778779
var nativeSymbolAccessor = _getSymbol(
8778-
_emitPrivateNameSymbol(_currentLibrary!, last),
8780+
_emitPrivateNameSymbol(library ?? _currentLibrary!, last),
87798781
);
87808782
result = js.call('new #.new(#, #)', [
87818783
_emitConstructorAccess(_privateSymbolType),

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9066,7 +9066,7 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
90669066

90679067
@override
90689068
js_ast.Expression visitSymbolConstant(SymbolConstant node) =>
9069-
_emitDartSymbol(node.name);
9069+
_emitDartSymbol(node.name, library: node.libraryReference?.asLibrary);
90709070

90719071
@override
90729072
js_ast.Expression visitMapConstant(MapConstant node) {
@@ -9562,15 +9562,17 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
95629562
/// Emits a Dart Symbol with the given member [symbolName].
95639563
///
95649564
/// If the symbol refers to a private name, its library will be set to the
9565-
/// [currentLibrary], so the Symbol is scoped properly.
9566-
js_ast.Expression _emitDartSymbol(String symbolName) {
9565+
/// [currentLibrary] by default, so the Symbol is scoped properly. Symbol
9566+
/// constants should pass the symbol's [library] if the referenced symbol was
9567+
/// declared outside the current library.
9568+
js_ast.Expression _emitDartSymbol(String symbolName, {Library? library}) {
95679569
// TODO(vsm): Handle qualified symbols correctly.
95689570
var last = symbolName.split('.').last;
95699571
var name = js.escapedString(symbolName, "'");
95709572
js_ast.Expression result;
95719573
if (last.startsWith('_')) {
95729574
var nativeSymbolAccessor = _getSymbol(
9573-
_emitPrivateNameSymbol(_currentLibrary!, last),
9575+
_emitPrivateNameSymbol(library ?? _currentLibrary!, last),
95749576
);
95759577
result = js.call('new #.new(#, #)', [
95769578
_emitConstructorAccess(_privateSymbolType),

0 commit comments

Comments
 (0)