Skip to content

Commit

Permalink
Version 3.4.0-269.0.dev
Browse files Browse the repository at this point in the history
Merge 5b0bf46 into dev
  • Loading branch information
Dart CI committed Mar 25, 2024
2 parents a783a4a + 5b0bf46 commit b81bb92
Show file tree
Hide file tree
Showing 8 changed files with 419 additions and 44 deletions.
85 changes: 51 additions & 34 deletions pkg/front_end/lib/src/macros/macro_target_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,58 @@ MacroConfiguration computeMacroConfiguration({Uri? targetSdkSummary}) {
// Force the SDK summary to "vm_platform_strong.dill".
// TODO(54404): make this sufficiently correct for all use cases.

Uri? sdkSummary;

if ((targetSdkSummary == null ||
targetSdkSummary.path == 'virtual_platform_kernel.dill' ||
targetSdkSummary.path.contains('vm_platform_strong.dill'))) {
sdkSummary = targetSdkSummary;
} else if (targetSdkSummary.path.contains('/flutter_patched_sdk/') ||
targetSdkSummary.path.contains('/flutter_web_sdk/')) {
// Flutter. Expecting the Flutter dill to be one of
//
// flutter_patched_sdk/platform_strong.dill
// flutter_web_sdk/kernel/ddc_outline_sound.dill
//
// and the Dart SDK to be in a subdirectory `dart-sdk` above that.
//
// If not found leave `sdkSummary` as `null`.
Directory directory = new Directory.fromUri(targetSdkSummary.resolve('.'));
while (directory.parent != directory) {
final Directory sdkDirectory =
new Directory.fromUri(directory.uri.resolve('./dart-sdk'));
if (sdkDirectory.existsSync()) {
sdkSummary =
sdkDirectory.uri.resolve('./lib/_internal/vm_platform_strong.dill');
break;
}
directory = directory.parent;
}
} else {
// Non-VM target platform, not Flutter. Find the platform dill next to the
// non-VM platform dill.
sdkSummary = targetSdkSummary.resolve('./vm_platform_strong.dill');
}

return new MacroConfiguration(
target: new VmTarget(
new TargetFlags(soundNullSafety: true, supportMirrors: false)),
sdkSummary: sdkSummary);
sdkSummary: _findSdkSummary(targetSdkSummary: targetSdkSummary));
}

Uri _findSdkSummary({Uri? targetSdkSummary}) {
if (targetSdkSummary?.path == 'virtual_platform_kernel.dill') {
return targetSdkSummary!;
}

// If the currently-running tool is in a Dart SDK folder, use the platform
// dill from there. Failing that, try searching from the target dill.
List<Directory> searchDirectories = [
new File(Platform.resolvedExecutable).parent,
if (targetSdkSummary != null) new File.fromUri(targetSdkSummary).parent,
];

for (Directory searchDirectory in searchDirectories) {
Directory? sdkDirectory = _findSdkDirectoryAbove(searchDirectory);
if (sdkDirectory != null) {
File? maybeResult = _findPlatformDillUnder(sdkDirectory);
if (maybeResult != null) return maybeResult.uri;
}
}

// Maybe there's no Dart SDK folder at all, but some build system has put the
// dill we need next to the target dill.
if (targetSdkSummary != null) {
File maybeResult =
new File.fromUri(targetSdkSummary.resolve('./vm_platform_strong.dill'));
if (maybeResult.existsSync()) return maybeResult.uri;
}

throw new StateError('Unable to find platform dill to build macros.');
}

// Looks for a directory `dart-sdk` in or above [directory].
Directory? _findSdkDirectoryAbove(Directory directory) {
while (directory.parent.path != directory.path) {
final Directory sdkDirectory =
new Directory.fromUri(directory.uri.resolve('./dart-sdk'));
if (sdkDirectory.existsSync()) return sdkDirectory;
directory = directory.parent;
}
return null;
}

// Returns the `vm_platform_strong.dill` file under [sdkDirectory] if it
// exists, or `null` if not.
File? _findPlatformDillUnder(Directory sdkDirectory) {
File maybeResult = new File.fromUri(
sdkDirectory.uri.resolve('./lib/_internal/vm_platform_strong.dill'));
return maybeResult.existsSync() ? maybeResult : null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,275 @@ class TypeSchemaEnvironmentTest extends TypeSchemaEnvironmentTestBase {
checkTargetType: "G<num, Object?>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.interfaceShape);

checkTypeShapeCheckSufficiency(
expressionStaticType: "(int,)",
checkTargetType: "(dynamic,)",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.recordShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(int,)",
checkTargetType: "(num,)",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.recordShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(int,)",
checkTargetType: "(String,)",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(int, {String foo})",
checkTargetType: "(dynamic, {dynamic foo})",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.recordShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(int, {String foo})",
checkTargetType: "(dynamic, {String foo})",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.recordShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(int, {String foo})",
checkTargetType: "(dynamic, {bool foo})",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(int, {String foo})",
checkTargetType: "(dynamic, {String bar})",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);

checkTypeShapeCheckSufficiency(
expressionStaticType: "(int) -> void",
checkTargetType: "(Never) -> void",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.functionShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(num) -> String",
checkTargetType: "(int) -> Object",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.functionShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(int) -> bool",
checkTargetType: "(String) -> dynamic",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(dynamic, {dynamic foo}) -> void",
checkTargetType: "(int, {String foo}) -> void",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.functionShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(dynamic, {String foo}) -> Object?",
checkTargetType: "(bool, {String foo}) -> dynamic",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.functionShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(dynamic, {bool foo}) -> Never?",
checkTargetType: "(int, {String foo}) -> Null",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(dynamic, {String foo}) -> Null",
checkTargetType: "(int, {String bar}) -> Null",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);

checkTypeShapeCheckSufficiency(
expressionStaticType: "FutureOr<String>",
checkTargetType: "FutureOr<Object?>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.futureOrShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "FutureOr<String>",
checkTargetType: "FutureOr<Object>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.futureOrShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "FutureOr<int>",
checkTargetType: "FutureOr<num>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.futureOrShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "FutureOr<bool>",
checkTargetType: "FutureOr<String>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);

checkTypeShapeCheckSufficiency(
expressionStaticType: "int",
checkTargetType: "(String,)",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "int",
checkTargetType: "(num) -> void",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "bool",
checkTargetType: "FutureOr<void>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);

checkTypeShapeCheckSufficiency(
expressionStaticType: "(int,)",
checkTargetType: "String",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(int,)",
checkTargetType: "(num) -> void",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(bool,)",
checkTargetType: "FutureOr<void>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);

checkTypeShapeCheckSufficiency(
expressionStaticType: "(int) -> void",
checkTargetType: "String",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(int) -> void",
checkTargetType: "(num,)",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "(bool) -> FutureOr<Object?>",
checkTargetType: "FutureOr<void>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);

checkTypeShapeCheckSufficiency(
expressionStaticType: "A<int>",
checkTargetType: "C<int>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "A<int>",
checkTargetType: "C<String>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "A<int>",
checkTargetType: "C<dynamic>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.interfaceShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "A<int>?",
checkTargetType: "C<dynamic>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "B",
checkTargetType: "C<int>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "B?",
checkTargetType: "C<Object?>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "B",
checkTargetType: "C<Object?>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.interfaceShape);

checkTypeShapeCheckSufficiency(
expressionStaticType: "D<int>",
checkTargetType: "E<int>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.interfaceShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "D<int>?",
checkTargetType: "E<int>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "D<int>",
checkTargetType: "E<num>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.interfaceShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "D<int>?",
checkTargetType: "E<num>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "D<int>",
checkTargetType: "E<dynamic>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.interfaceShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "D<int>?",
checkTargetType: "E<dynamic>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "D<num>",
checkTargetType: "E<int>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "D<num>?",
checkTargetType: "E<int>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);

checkTypeShapeCheckSufficiency(
expressionStaticType: "F<int>",
checkTargetType: "G<int, String>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "F<int>?",
checkTargetType: "G<int, String>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "F<int>",
checkTargetType: "G<num, String>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "F<int>?",
checkTargetType: "G<num, String>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "F<int>",
checkTargetType: "G<dynamic, Object?>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.interfaceShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "F<int>?",
checkTargetType: "G<dynamic, Object?>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "F<int>",
checkTargetType: "G<int, Object?>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.interfaceShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "F<int>?",
checkTargetType: "G<int, Object?>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
checkTypeShapeCheckSufficiency(
expressionStaticType: "F<int>",
checkTargetType: "G<num, Object?>?",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.interfaceShape);
checkTypeShapeCheckSufficiency(
expressionStaticType: "F<int>?",
checkTargetType: "G<num, Object?>",
typeParameters: "",
sufficiency: TypeShapeCheckSufficiency.insufficient);
}

void checkUpperBound(
Expand Down
Loading

0 comments on commit b81bb92

Please sign in to comment.