Skip to content

Commit

Permalink
Version 3.6.0-307.0.dev
Browse files Browse the repository at this point in the history
Merge 7bb6899 into dev
  • Loading branch information
Dart CI committed Oct 1, 2024
2 parents 2370172 + 7bb6899 commit 0e8b99c
Show file tree
Hide file tree
Showing 69 changed files with 1,223 additions and 233 deletions.
49 changes: 7 additions & 42 deletions pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3377,65 +3377,30 @@ Message _withArgumentsDuplicatedExport(String name, Uri uri_, Uri uri2_) {

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<Message Function(String name, Uri uri_, Uri uri2_)>
templateDuplicatedExportInType =
templateDuplicatedImport =
const Template<Message Function(String name, Uri uri_, Uri uri2_)>(
"DuplicatedExportInType",
problemMessageTemplate:
r"""'#name' is exported from both '#uri' and '#uri2'.""",
withArguments: _withArgumentsDuplicatedExportInType,
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name, Uri uri_, Uri uri2_)>
codeDuplicatedExportInType =
const Code<Message Function(String name, Uri uri_, Uri uri2_)>(
"DuplicatedExportInType",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsDuplicatedExportInType(String name, Uri uri_, Uri uri2_) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
String? uri = relativizeUri(uri_);
String? uri2 = relativizeUri(uri2_);
return new Message(
codeDuplicatedExportInType,
problemMessage:
"""'${name}' is exported from both '${uri}' and '${uri2}'.""",
arguments: {
'name': name,
'uri': uri_,
'uri2': uri2_,
},
);
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<Message Function(String name, Uri uri_, Uri uri2_)>
templateDuplicatedImportInType =
const Template<Message Function(String name, Uri uri_, Uri uri2_)>(
"DuplicatedImportInType",
"DuplicatedImport",
problemMessageTemplate:
r"""'#name' is imported from both '#uri' and '#uri2'.""",
withArguments: _withArgumentsDuplicatedImportInType,
withArguments: _withArgumentsDuplicatedImport,
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name, Uri uri_, Uri uri2_)>
codeDuplicatedImportInType =
codeDuplicatedImport =
const Code<Message Function(String name, Uri uri_, Uri uri2_)>(
"DuplicatedImportInType",
"DuplicatedImport",
analyzerCodes: <String>["AMBIGUOUS_IMPORT"],
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsDuplicatedImportInType(String name, Uri uri_, Uri uri2_) {
Message _withArgumentsDuplicatedImport(String name, Uri uri_, Uri uri2_) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
String? uri = relativizeUri(uri_);
String? uri2 = relativizeUri(uri2_);
return new Message(
codeDuplicatedImportInType,
codeDuplicatedImport,
problemMessage:
"""'${name}' is imported from both '${uri}' and '${uri2}'.""",
arguments: {
Expand Down
6 changes: 2 additions & 4 deletions pkg/front_end/lib/src/base/import.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ class Import {
}

add = (String name, Builder member) {
prefixFragment.builder.addToExportScope(name, member,
importOffset: importOffset,
prefixOffset: prefixOffset,
fromImport: true);
prefixFragment.builder.addToPrefixScope(name, member,
importOffset: importOffset, prefixOffset: prefixOffset);
};
}
NameIterator<Builder> iterator = importedLibraryBuilder!.exportNameSpace
Expand Down
22 changes: 12 additions & 10 deletions pkg/front_end/lib/src/base/incremental_compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {

// Clear cached calculations that points (potential) to now replaced
// things.
for (Builder builder in builder.nameSpace.localMembers) {
for (Builder builder in builder.libraryNameSpace.localMembers) {
if (builder is DillClassBuilder) {
builder.clearCachedValues();
}
Expand Down Expand Up @@ -1034,7 +1034,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
if (builder.isBuiltAndMarked) {
// Clear cached calculations in classes which upon calculation can
// mark things as needed.
for (Builder builder in builder.nameSpace.localMembers) {
for (Builder builder in builder.libraryNameSpace.localMembers) {
if (builder is DillClassBuilder) {
builder.clearCachedValues();
}
Expand Down Expand Up @@ -1880,7 +1880,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {

Class? cls;
if (className != null) {
Builder? scopeMember = libraryBuilder.nameSpace
Builder? scopeMember = libraryBuilder.libraryNameSpace
.lookupLocalMember(className, setter: false);
if (scopeMember is ClassBuilder) {
cls = scopeMember.cls;
Expand All @@ -1896,7 +1896,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
if (indexOfDot >= 0) {
String beforeDot = methodName.substring(0, indexOfDot);
String afterDot = methodName.substring(indexOfDot + 1);
Builder? builder = libraryBuilder.nameSpace
Builder? builder = libraryBuilder.libraryNameSpace
.lookupLocalMember(beforeDot, setter: false);
extensionName = beforeDot;
if (builder is ExtensionBuilder) {
Expand Down Expand Up @@ -1984,14 +1984,16 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
mayImplementRestrictedTypes: false);
SourceLibraryBuilder debugLibrary = debugCompilationUnit.createLibrary();
debugLibrary.buildNameSpace();
libraryBuilder.nameSpace.forEachLocalMember((name, member) {
debugLibrary.nameSpace.addLocalMember(name, member, setter: false);
libraryBuilder.libraryNameSpace.forEachLocalMember((name, member) {
debugLibrary.libraryNameSpace
.addLocalMember(name, member, setter: false);
});
libraryBuilder.nameSpace.forEachLocalSetter((name, member) {
debugLibrary.nameSpace.addLocalMember(name, member, setter: true);
libraryBuilder.libraryNameSpace.forEachLocalSetter((name, member) {
debugLibrary.libraryNameSpace
.addLocalMember(name, member, setter: true);
});
libraryBuilder.nameSpace.forEachLocalExtension((member) {
debugLibrary.nameSpace.addExtension(member);
libraryBuilder.libraryNameSpace.forEachLocalExtension((member) {
debugLibrary.libraryNameSpace.addExtension(member);
});
debugLibrary.buildScopes(lastGoodKernelTarget.loader.coreLibrary);
_ticker.logMs("Created debug library");
Expand Down
67 changes: 26 additions & 41 deletions pkg/front_end/lib/src/base/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ enum ScopeKind {

/// Scope for type parameters of declarations
typeParameters,

import,

prefix,
}

abstract class LookupScope {
Expand Down Expand Up @@ -430,7 +434,7 @@ class CompilationUnitScope extends BaseNameSpaceLookupScope {
: _parent = parent;

@override
NameSpace get _nameSpace => _compilationUnit.libraryBuilder.nameSpace;
NameSpace get _nameSpace => _compilationUnit.libraryBuilder.libraryNameSpace;
}

class SourceLibraryBuilderScope extends BaseNameSpaceLookupScope {
Expand All @@ -440,10 +444,10 @@ class SourceLibraryBuilderScope extends BaseNameSpaceLookupScope {
this._compilationUnit, super.kind, super.classNameOrDebugName);

@override
NameSpace get _nameSpace => _compilationUnit.libraryBuilder.nameSpace;
NameSpace get _nameSpace => _compilationUnit.libraryBuilder.libraryNameSpace;

@override
LookupScope? get _parent => _compilationUnit.libraryBuilder.importScope;
LookupScope? get _parent => _compilationUnit.libraryBuilder.prefixScope;
}

abstract class ConstructorScope {
Expand All @@ -470,13 +474,11 @@ class DeclarationNameSpaceConstructorScope implements ConstructorScope {
}
}

/// Computes a builder for the import/export collision between [declaration] and
/// [other] and adds it to [nameSpace].
Builder computeAmbiguousDeclarationForScope(ProblemReporting problemReporting,
NameSpace nameSpace, String name, Builder declaration, Builder other,
{required UriOffset uriOffset,
bool isExport = false,
bool isImport = false}) {
/// Computes a builder for the import collision between [declaration] and
/// [other].
Builder computeAmbiguousDeclarationForImport(ProblemReporting problemReporting,
String name, Builder declaration, Builder other,
{required UriOffset uriOffset}) {
// Prefix fragments are merged to singular prefix builders when computing the
// import scope.
assert(!(declaration is PrefixBuilder && other is PrefixBuilder),
Expand All @@ -497,45 +499,28 @@ Builder computeAmbiguousDeclarationForScope(ProblemReporting problemReporting,
other = error.builder;
}
Builder? preferred;
Uri? uri;
Uri? otherUri;
if (nameSpace.lookupLocalMember(name, setter: false) == declaration) {
Uri uri = computeLibraryUri(declaration);
Uri otherUri = computeLibraryUri(other);
if (declaration is LoadLibraryBuilder) {
preferred = declaration;
} else {
uri = computeLibraryUri(declaration);
otherUri = computeLibraryUri(other);
if (declaration is LoadLibraryBuilder) {
preferred = declaration;
} else if (other is LoadLibraryBuilder) {
preferred = other;
} else if (otherUri.isScheme("dart") && !uri.isScheme("dart")) {
preferred = declaration;
} else if (uri.isScheme("dart") && !otherUri.isScheme("dart")) {
preferred = other;
}
} else if (other is LoadLibraryBuilder) {
preferred = other;
} else if (otherUri.isScheme("dart") && !uri.isScheme("dart")) {
preferred = declaration;
} else if (uri.isScheme("dart") && !otherUri.isScheme("dart")) {
preferred = other;
}
if (preferred != null) {
return preferred;
}

Uri firstUri = uri!;
Uri secondUri = otherUri!;
Uri firstUri = uri;
Uri secondUri = otherUri;
if (firstUri.toString().compareTo(secondUri.toString()) > 0) {
firstUri = secondUri;
secondUri = uri;
}
if (isExport) {
Template<Message Function(String name, Uri uri, Uri uri2)> template =
templateDuplicatedExport;
Message message = template.withArguments(name, firstUri, secondUri);
problemReporting.addProblem(
message, uriOffset.fileOffset, noLength, uriOffset.uri);
}
Template<Message Function(String name, Uri uri, Uri uri2)> builderTemplate =
isExport
? templateDuplicatedExportInType
: templateDuplicatedImportInType;
Message message = builderTemplate.withArguments(
Message message = templateDuplicatedImport.withArguments(
name,
// TODO(ahe): We should probably use a context object here
// instead of including URIs in this message.
Expand Down Expand Up @@ -1312,13 +1297,13 @@ abstract class MergedScope<T extends Builder> {

class MergedLibraryScope extends MergedScope<SourceLibraryBuilder> {
MergedLibraryScope(SourceLibraryBuilder origin)
: super(origin, origin.nameSpace);
: super(origin, origin.libraryNameSpace);

@override
SourceLibraryBuilder get originLibrary => _origin;

void addAugmentationScope(SourceLibraryBuilder builder) {
_addAugmentationScope(builder, builder.nameSpace,
_addAugmentationScope(builder, builder.libraryNameSpace,
augmentations: builder.augmentations,
setterAugmentations: builder.setterAugmentations,
inPatchLibrary: builder.isPatchLibrary);
Expand Down
Loading

0 comments on commit 0e8b99c

Please sign in to comment.