Skip to content

Commit

Permalink
Version 3.6.0-69.0.dev
Browse files Browse the repository at this point in the history
Merge 805aa0d into dev
  • Loading branch information
Dart CI committed Jul 22, 2024
2 parents dd27fa7 + 805aa0d commit 8db708e
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 66 deletions.
10 changes: 9 additions & 1 deletion pkg/dartdev/lib/src/sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ class Sdk {
// Assume that we want to use the same Dart executable that we used to spawn
// DartDev. We should be able to run programs with out/ReleaseX64/dart even
// if the SDK isn't completely built.
String get dart => Platform.executable;
String get dart => path.absolute(
_runFromBuildRoot
? sdkPath
: path.absolute(
sdkPath,
'bin',
),
path.basename(Platform.executable),
);

String get dartAotRuntime => _runFromBuildRoot
? path.absolute(
Expand Down
43 changes: 43 additions & 0 deletions pkg/dartdev/test/sdk_from_path_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2024, 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.

import 'dart:convert';
import 'dart:io';

import 'package:path/path.dart' as path;
import 'package:test/test.dart';

// Regression test for https://github.com/dart-lang/sdk/issues/56080

void main() {
late final Process? process;

tearDown(() {
process?.kill();
});

test('sdk_test.dart passes when run with dart from PATH', () async {
final script = path.join(
path.dirname(Platform.script.toString()),
'sdk_test.dart',
);
process = await Process.start(
'dart',
[script],
environment: {'PATH': path.dirname(Platform.resolvedExecutable)},
);

// All tests in sdk_test.dart should pass when `dart` is invoked from PATH.
final exitCode = await process!.exitCode;
if (exitCode != 0) {
print('EXIT CODE: $exitCode');
print('STDOUT:');
print(await process!.stdout.transform(utf8.decoder).join());
print('');
print('STDERR:');
print(await process!.stderr.transform(utf8.decoder).join());
print('sdk_test.dart failed when run with dart from PATH!');
}
});
}
6 changes: 2 additions & 4 deletions pkg/front_end/lib/src/base/incremental_compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
for (DillLibraryBuilder builder
in experimentalInvalidation.originalNotReusedLibraries) {
if (builder.isBuilt) {
builder.exportScope
.patchUpScope(replacementMap, replacementSettersMap);
builder.patchUpExportScope(replacementMap, replacementSettersMap);

// Clear cached calculations that points (potential) to now replaced
// things.
Expand Down Expand Up @@ -950,8 +949,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
in experimentalInvalidation.originalNotReusedLibraries) {
// There's only something to patch up if it was build already.
if (builder.isBuilt) {
builder.exportScope
.patchUpScope(replacementMap, replacementSettersMap);
builder.patchUpExportScope(replacementMap, replacementSettersMap);
}
}
}
Expand Down
10 changes: 3 additions & 7 deletions pkg/front_end/lib/src/base/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -951,13 +951,9 @@ Builder computeAmbiguousDeclarationForScope(ProblemReporting problemReporting,
// Coverage-ignore-block(suite): Not run.
// Handles the case where the same prefix is used for different
// imports.
return declaration
..exportScope.merge(other.exportScope,
(String name, Builder existing, Builder member) {
return computeAmbiguousDeclarationForScope(
problemReporting, scope, name, existing, member,
uriOffset: uriOffset, isExport: isExport, isImport: isImport);
});
declaration.mergeScopes(other, problemReporting, scope,
uriOffset: uriOffset, isImport: isImport, isExport: isExport);
return declaration;
}
}
Uri firstUri = uri!;
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/lib/src/builder/library_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ abstract class LibraryBuilder implements Builder, ProblemReporting {

NameSpace get nameSpace;

Scope get exportScope;
NameSpace get exportScope;

List<Export> get exporters;

Expand Down Expand Up @@ -489,7 +489,7 @@ abstract class LibraryBuilderImpl extends ModifierBuilderImpl
null);
}
Builder? cls = (bypassLibraryPrivacy ? scope : exportScope)
.lookup(className, -1, fileUri);
.lookupLocalMember(className, setter: false);
if (cls is TypeAliasBuilder) {
// Coverage-ignore-block(suite): Not run.
TypeAliasBuilder aliasBuilder = cls;
Expand Down
31 changes: 25 additions & 6 deletions pkg/front_end/lib/src/builder/prefix_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ library fasta.prefix_builder;

import 'package:kernel/ast.dart' show LibraryDependency;

import '../base/messages.dart';
import '../base/scope.dart';
import '../base/uri_offset.dart';
import '../codes/cfe_codes.dart';
import '../kernel/load_library_builder.dart' show LoadLibraryBuilder;
import '../source/source_library_builder.dart';
import 'builder.dart';
Expand All @@ -17,7 +17,7 @@ import 'declaration_builders.dart';
class PrefixBuilder extends BuilderImpl {
final String name;

final Scope exportScope = new Scope.top(kind: ScopeKind.library);
final Scope _exportScope = new Scope.top(kind: ScopeKind.library);

@override
final SourceLibraryBuilder parent;
Expand All @@ -43,14 +43,20 @@ class PrefixBuilder extends BuilderImpl {
}
}

LookupScope get exportScope => _exportScope;

void forEachExtension(void Function(ExtensionBuilder) f) {
_exportScope.forEachExtension(f);
}

LibraryDependency? get dependency => loadLibraryBuilder?.importDependency;

@override
Uri get fileUri => parent.fileUri;

/// Lookup a member with [name] in the export scope.
Builder? lookup(String name, int charOffset, Uri fileUri) {
return exportScope.lookup(name, charOffset, fileUri);
return _exportScope.lookup(name, charOffset, fileUri);
}

void addToExportScope(String name, Builder member, int charOffset) {
Expand All @@ -60,7 +66,7 @@ class PrefixBuilder extends BuilderImpl {
}

Builder? existing =
exportScope.lookupLocalMember(name, setter: member.isSetter);
_exportScope.lookupLocalMember(name, setter: member.isSetter);
Builder result;
if (existing != null) {
// Coverage-ignore-block(suite): Not run.
Expand All @@ -70,13 +76,26 @@ class PrefixBuilder extends BuilderImpl {
} else {
result = member;
}
exportScope.addLocalMember(name, result, setter: member.isSetter);
_exportScope.addLocalMember(name, result, setter: member.isSetter);
if (result is ExtensionBuilder) {
exportScope.addExtension(result);
_exportScope.addExtension(result);
}
}

@override
// Coverage-ignore(suite): Not run.
String get fullNameForErrors => name;

void mergeScopes(
PrefixBuilder other, ProblemReporting problemReporting, Scope scope,
{required UriOffset uriOffset,
bool isImport = false,
bool isExport = false}) {
return _exportScope.merge(other._exportScope,
(String name, Builder existing, Builder member) {
return computeAmbiguousDeclarationForScope(
problemReporting, scope, name, existing, member,
uriOffset: uriOffset, isExport: isExport, isImport: isImport);
});
}
}
11 changes: 10 additions & 1 deletion pkg/front_end/lib/src/dill/dill_library_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class DillLibraryBuilder extends LibraryBuilderImpl {
Scope get nameSpace => _scope;

@override
Scope get exportScope => _exportScope;
NameSpace get exportScope => _exportScope;

@override
List<Export> get exporters => mainCompilationUnit.exporters;
Expand Down Expand Up @@ -514,4 +514,13 @@ class DillLibraryBuilder extends LibraryBuilderImpl {

@override
Version get languageVersion => library.languageVersion;

/// Patch up the export scope, using the two replacement maps to replace
/// builders in the export scope. The replacement maps from old LibraryBuilder
/// to map, mapping from name to new (replacement) builder.
void patchUpExportScope(
Map<LibraryBuilder, Map<String, Builder>> replacementMap,
Map<LibraryBuilder, Map<String, Builder>> replacementMapSetters) {
_exportScope.patchUpScope(replacementMap, replacementMapSetters);
}
}
2 changes: 1 addition & 1 deletion pkg/front_end/lib/src/kernel/kernel_target.dart
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ class KernelTarget {
if (firstRoot != null) {
// TODO(sigmund): do only for full program
Builder? declaration =
firstRoot.exportScope.lookup("main", -1, firstRoot.fileUri);
firstRoot.exportScope.lookupLocalMember("main", setter: false);
if (declaration is AmbiguousBuilder) {
// Coverage-ignore-block(suite): Not run.
AmbiguousBuilder problem = declaration;
Expand Down
10 changes: 3 additions & 7 deletions pkg/front_end/lib/src/source/source_builder_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2382,13 +2382,9 @@ class BuilderFactoryImpl implements BuilderFactory, BuilderFactoryResult {
_compilationUnit.fileUri, other!.charOffset, noLength)
]);
}
return existing
..exportScope.merge(declaration.exportScope,
(String name, Builder existing, Builder member) {
return computeAmbiguousDeclarationForScope(
_problemReporting, scope, name, existing, member,
uriOffset: new UriOffset(_compilationUnit.fileUri, charOffset));
});
existing.mergeScopes(declaration, _problemReporting, scope,
uriOffset: new UriOffset(_compilationUnit.fileUri, charOffset));
return existing;
} else if (_isDuplicatedDeclaration(existing, declaration)) {
String fullName = name;
if (isConstructor) {
Expand Down
10 changes: 3 additions & 7 deletions pkg/front_end/lib/src/source/source_compilation_unit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -809,18 +809,14 @@ class SourceCompilationUnitImpl
if (_extensionsInScope == null) {
_extensionsInScope = <ExtensionBuilder>{};
_scope.forEachExtension((e) {
if (!e.extension.isExtensionTypeDeclaration) {
_extensionsInScope!.add(e);
}
_extensionsInScope!.add(e);
});
List<PrefixBuilder>? prefixBuilders =
_builderFactoryResult.prefixBuilders;
if (prefixBuilders != null) {
for (PrefixBuilder prefix in prefixBuilders) {
prefix.exportScope.forEachExtension((e) {
if (!e.extension.isExtensionTypeDeclaration) {
_extensionsInScope!.add(e);
}
prefix.forEachExtension((e) {
_extensionsInScope!.add(e);
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/lib/src/source/source_enum_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class SourceEnumBuilder extends SourceClassBuilder {
List<NominalVariableBuilder>? typeVariables,
TypeBuilder supertypeBuilder,
List<TypeBuilder>? interfaceBuilders,
Scope typeParameterScope,
LookupScope typeParameterScope,
Scope memberScope,
ConstructorScope constructors,
Class cls,
Expand Down Expand Up @@ -138,7 +138,7 @@ class SourceEnumBuilder extends SourceClassBuilder {
int charOffset,
int charEndOffset,
IndexedClass? referencesFromIndexed,
Scope typeParameterScope,
LookupScope typeParameterScope,
Scope memberScope,
ConstructorScope constructorScope,
LibraryBuilder coreLibrary) {
Expand Down
1 change: 0 additions & 1 deletion pkg/front_end/lib/src/source/source_extension_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class SourceExtensionBuilder extends ExtensionBuilderImpl
typeParameters: NominalVariableBuilder.typeParametersFromBuilders(
typeParameters),
reference: referenceFrom?.reference)
..isExtensionTypeDeclaration = false
..isUnnamedExtension = extensionName.isUnnamedExtension
..fileOffset = nameOffset,
constructorScope = new ConstructorScope(extensionName.name, const {}),
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/lib/src/source/source_library_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {

final Scope _scope;

final Scope _exportScope;
final NameSpace _exportScope;

@override
final SourceLoader loader;
Expand Down Expand Up @@ -389,7 +389,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
Scope get nameSpace => _scope;

@override
Scope get exportScope => _exportScope;
NameSpace get exportScope => _exportScope;

Iterable<SourceCompilationUnit> get parts => _parts;

Expand Down
10 changes: 5 additions & 5 deletions pkg/front_end/test/coverage_suite_expected.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/builder/prefix_builder.dart": (
hitCount: 35,
hitCount: 46,
missCount: 0,
),
// 100.0%.
Expand Down Expand Up @@ -775,7 +775,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/source/source_builder_factory.dart": (
hitCount: 1213,
hitCount: 1209,
missCount: 0,
),
// 100.0%.
Expand All @@ -788,9 +788,9 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
hitCount: 1213,
missCount: 0,
),
// 99.4729907773386%.
// 99.46949602122017%.
"package:front_end/src/source/source_compilation_unit.dart": (
hitCount: 755,
hitCount: 750,
missCount: 4,
),
// 100.0%.
Expand All @@ -805,7 +805,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/source/source_extension_builder.dart": (
hitCount: 72,
hitCount: 71,
missCount: 0,
),
// 100.0%.
Expand Down
4 changes: 2 additions & 2 deletions pkg/kernel/binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ type CanonicalName {

type ComponentFile {
UInt32 magic = 0x90ABCDEF;
UInt32 formatVersion = 119;
UInt32 formatVersion = 120;
Byte[10] shortSdkHash;
List<String> problemsAsJson; // Described in problems.md.
Library[] libraries;
Expand Down Expand Up @@ -346,7 +346,7 @@ type Extension extends Node {
List<Expression> annotations;
UriReference fileUri;
FileOffset fileOffset;
Byte flags (isExtensionTypeDeclaration, isUnnamedExtension);
Byte flags (isUnnamedExtension);
List<TypeParameter> typeParameters;
DartType onType;
List<ExtensionMemberDescriptor> members;
Expand Down
13 changes: 1 addition & 12 deletions pkg/kernel/lib/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1603,8 +1603,7 @@ class Extension extends NamedNode
List<Expression> annotations = const <Expression>[];

// Must match serialized bit positions.
static const int FlagExtensionTypeDeclaration = 1 << 0;
static const int FlagUnnamedExtension = 1 << 1;
static const int FlagUnnamedExtension = 1 << 0;

int flags = 0;

Expand Down Expand Up @@ -1641,16 +1640,6 @@ class Extension extends NamedNode

Library get enclosingLibrary => parent as Library;

bool get isExtensionTypeDeclaration {
return flags & FlagExtensionTypeDeclaration != 0;
}

void set isExtensionTypeDeclaration(bool value) {
flags = value
? (flags | FlagExtensionTypeDeclaration)
: (flags & ~FlagExtensionTypeDeclaration);
}

bool get isUnnamedExtension {
return flags & FlagUnnamedExtension != 0;
}
Expand Down
Loading

0 comments on commit 8db708e

Please sign in to comment.