Skip to content

Commit

Permalink
[dart2js] Remove remaining language version overrides
Browse files Browse the repository at this point in the history
Now that dart2js only takes migrated files as input, all tests should
use the current language version.

Change-Id: I6c84850f5786aeac04154b67bd7a3c19083c8bba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345344
Reviewed-by: Nate Biggs <[email protected]>
Commit-Queue: Mayank Patke <[email protected]>
  • Loading branch information
fishythefish authored and Commit Queue committed Jan 23, 2024
1 parent 307c6d1 commit f79ed93
Show file tree
Hide file tree
Showing 655 changed files with 1,960 additions and 4,266 deletions.
5 changes: 3 additions & 2 deletions pkg/compiler/lib/src/ir/visitors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DartTypeConverter extends ir.DartTypeVisitor<DartType> {

DartType _convertNullability(
DartType baseType, ir.DartType nullabilitySource) {
final nullability = nullabilitySource.nullability;
final nullability = nullabilitySource.declaredNullability;
switch (nullability) {
case ir.Nullability.nonNullable:
return baseType;
Expand All @@ -68,7 +68,8 @@ class DartTypeConverter extends ir.DartTypeVisitor<DartType> {
// nullability of the bound. We don't need a nullability wrapper in this
// case.
if (nullabilitySource is ir.TypeParameterType ||
nullabilitySource is ir.StructuralParameterType) {
nullabilitySource is ir.StructuralParameterType ||
nullabilitySource is ir.ExtensionType) {
return baseType;
}

Expand Down
53 changes: 5 additions & 48 deletions pkg/compiler/lib/src/util/memory_compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ Future<api.CompilationResult> runCompiler(
bool showDiagnostics = true,
Uri? librariesSpecificationUri,
Uri? packageConfig,
void beforeRun(Compiler compiler)?,
bool unsafeToTouchSourceFiles = false}) async {
void beforeRun(Compiler compiler)?}) async {
if (entryPoint == null) {
entryPoint = Uri.parse('memory:main.dart');
}
Expand All @@ -109,8 +108,7 @@ Future<api.CompilationResult> runCompiler(
environment: environment,
showDiagnostics: showDiagnostics,
librariesSpecificationUri: librariesSpecificationUri,
packageConfig: packageConfig,
unsafeToTouchSourceFiles: unsafeToTouchSourceFiles);
packageConfig: packageConfig);
if (beforeRun != null) {
beforeRun(compiler);
}
Expand All @@ -130,8 +128,7 @@ Compiler compilerFor(
Map<String, String>? environment,
bool showDiagnostics = true,
Uri? librariesSpecificationUri,
Uri? packageConfig,
bool unsafeToTouchSourceFiles = false}) {
Uri? packageConfig}) {
retainDataForTesting = true;
librariesSpecificationUri ??= sdkLibrariesSpecificationUri;

Expand All @@ -148,41 +145,6 @@ Compiler compilerFor(
// Create a local in case we end up cloning memorySourceFiles.
Map<String, dynamic> sources = memorySourceFiles;

// If soundNullSafety is not requested, then we prepend the opt out string to
// the memory files.
// TODO(48820): After migrating all tests we should no longer have to infer
// a mode in the memory compiler. The logic to update options and to update
// sources to opt-out should be removed.
if (!options.contains(Flags.soundNullSafety)) {
bool addUnsoundFlag = false;
if (!unsafeToTouchSourceFiles) {
// Map may be immutable so copy.
sources = {};
memorySourceFiles.forEach((k, v) => sources[k] = v);
addUnsoundFlag = true;
}

for (var key in sources.keys) {
if (sources[key] is String && key.endsWith('.dart')) {
RegExp optOutStr = RegExp(r"\/\/\s*@dart\s*=\s*2\.(\d+)");
final match = optOutStr.firstMatch(sources[key]);
if (match == null) {
if (!unsafeToTouchSourceFiles) {
sources[key] = '// @dart=2.7\n' + sources[key];
}
} else {
// If the file version is prior to 2.12, we treat it as unsound
if (int.parse(match.group(1)!) < 12) {
addUnsoundFlag = true;
}
}
}
}
if (addUnsoundFlag && !options.contains(Flags.noSoundNullSafety)) {
options = [Flags.noSoundNullSafety, ...options];
}
}

MemorySourceFileProvider provider;
provider = MemorySourceFileProvider(sources);
diagnosticHandler = createCompilerDiagnostics(diagnosticHandler, provider,
Expand All @@ -193,15 +155,10 @@ Compiler compilerFor(
outputProvider = const NullCompilerOutput();
}

options.add('${Flags.entryUri}=$entryPoint');
options = [...options, '${Flags.entryUri}=$entryPoint'];

CompilerOptions compilerOptions = CompilerOptions.parse(options,
librariesSpecificationUri: librariesSpecificationUri,
// Unsound platform dill files are no longer packaged in the SDK and must
// be read from the build directory during tests.
platformBinaries: options.contains(Flags.noSoundNullSafety)
? buildPlatformBinariesUri
: null)
librariesSpecificationUri: librariesSpecificationUri)
..environment = environment ?? {}
..packageConfig = packageConfig;

Expand Down
1 change: 0 additions & 1 deletion pkg/compiler/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ dev_dependencies:
modular_test: any
sourcemap_testing: any
testing: any
vm: any
4 changes: 2 additions & 2 deletions pkg/compiler/test/codegen/builtin_equals_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import '../helpers/compiler_helper.dart';

const String TEST = r"""
foo() {
String s = Object().toString();
Object o = Object().toString();
String? s = Object()?.toString();
Object? o = Object()?.toString();
return s == 'foo'
&& s == null
&& null == s
Expand Down
9 changes: 0 additions & 9 deletions pkg/compiler/test/codegen/codegen_2_shard0_test.dart

This file was deleted.

9 changes: 0 additions & 9 deletions pkg/compiler/test/codegen/codegen_2_shard1_test.dart

This file was deleted.

14 changes: 1 addition & 13 deletions pkg/compiler/test/codegen/codegen_test_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'dart:io';
import 'package:async_helper/async_helper.dart';
import 'package:compiler/src/closure.dart';
import 'package:compiler/src/common.dart';
import 'package:compiler/src/commandline_options.dart';
import 'package:compiler/src/compiler.dart';
import 'package:compiler/src/elements/entities.dart';
import 'package:compiler/src/js_model/element_map.dart';
Expand All @@ -17,11 +16,9 @@ import '../equivalence/id_equivalence.dart';
import '../equivalence/id_equivalence_helper.dart';

const List<String> skip = [];
const List<String> skip2 = [];

main(List<String> args) {
runTests(args);
runTests2(args);
}

runTests(List<String> args, [int? shardIndex]) {
Expand All @@ -30,16 +27,7 @@ runTests(List<String> args, [int? shardIndex]) {
shards: 2,
directory: 'data',
skip: skip,
options: [Flags.soundNullSafety]);
}

runTests2(List<String> args, [int? shardIndex]) {
runTestsCommon(args,
shardIndex: shardIndex,
shards: 2,
directory: 'data_2',
skip: skip2,
options: []);
options: const []);
}

runTestsCommon(List<String> args,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

// @dart = 2.17

/*member: main:ignore*/
void main() {
final x1 = XX();
Expand Down
2 changes: 0 additions & 2 deletions pkg/compiler/test/codegen/data/shift_right_unsigned.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

// @dart = 2.14

/*member: main:ignore*/
void main() {
for (var a in [false, true]) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/compiler/test/codegen/data/tdiv1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

// @dart = 2.12

/*member: main:ignore*/
void main() {
for (var a in [false, true]) {
Expand Down
3 changes: 0 additions & 3 deletions pkg/compiler/test/codegen/data_2/marker.options

This file was deleted.

118 changes: 0 additions & 118 deletions pkg/compiler/test/codegen/data_2/tdiv1.dart

This file was deleted.

62 changes: 0 additions & 62 deletions pkg/compiler/test/codegen/data_2/unused_empty_map.dart

This file was deleted.

Loading

0 comments on commit f79ed93

Please sign in to comment.