Version 2.14.0-46.0.dev
Merge commit '931f7dc2e6d27b728038b74371922f6aa2f51c74' into 'dev'
diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes.dart
index ddb14d5..7299a94 100644
--- a/pkg/_fe_analyzer_shared/lib/src/messages/codes.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes.dart
@@ -132,7 +132,7 @@
}
FormattedMessage withFormatting(PlainAndColorizedString formatted, int line,
- int column, Severity severity, List<FormattedMessage> relatedInformation,
+ int column, Severity severity, List<FormattedMessage>? relatedInformation,
{List<Uri>? involvedFiles}) {
return new FormattedMessage(this, formatted.plain, formatted.colorized,
line, column, severity, relatedInformation,
diff --git a/pkg/front_end/lib/src/api_prototype/compiler_options.dart b/pkg/front_end/lib/src/api_prototype/compiler_options.dart
index 23ba26d..69ba280 100644
--- a/pkg/front_end/lib/src/api_prototype/compiler_options.dart
+++ b/pkg/front_end/lib/src/api_prototype/compiler_options.dart
@@ -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.9
-
library front_end.compiler_options;
import 'package:_fe_analyzer_shared/src/messages/diagnostic_message.dart'
@@ -51,7 +49,7 @@
///
/// If `null`, the SDK will be searched for using
/// [Platform.resolvedExecutable] as a starting point.
- Uri sdkRoot;
+ Uri? sdkRoot;
/// Uri to a platform libraries specification file.
///
@@ -63,9 +61,9 @@
/// If a value is not specified and `compileSdk = true`, the compiler will
/// infer at a default location under [sdkRoot], typically under
/// `lib/libraries.json`.
- Uri librariesSpecificationUri;
+ Uri? librariesSpecificationUri;
- DiagnosticMessageHandler onDiagnostic;
+ DiagnosticMessageHandler? onDiagnostic;
/// URI of the ".dart_tool/package_config.json" or ".packages" file
/// (typically a "file:" URI).
@@ -79,7 +77,7 @@
///
/// If the URI's path component is empty (e.g. `new Uri()`), no packages file
/// will be used.
- Uri packagesFileUri;
+ Uri? packagesFileUri;
/// URIs of additional dill files.
///
@@ -97,11 +95,11 @@
///
/// If `null` and [compileSdk] is false, the SDK summary will be searched for
/// at a default location within [sdkRoot].
- Uri sdkSummary;
+ Uri? sdkSummary;
/// The declared variables for use by configurable imports and constant
/// evaluation.
- Map<String, String> declaredVariables;
+ Map<String, String>? declaredVariables;
/// The [FileSystem] which should be used by the front end to access files.
///
@@ -117,42 +115,22 @@
/// When this option is `true`, [sdkSummary] must be null.
bool compileSdk = false;
- @Deprecated("Unused internally.")
- bool chaseDependencies;
-
- /// Patch files to apply on the core libraries for a specific target platform.
- ///
- /// Keys in the map are the name of the library with no `dart:` prefix, for
- /// example:
- ///
- /// {'core': [
- /// 'file:///location/of/core/patch_file1.dart',
- /// 'file:///location/of/core/patch_file2.dart',
- /// ]}
- ///
- /// The values can be either absolute or relative URIs. Absolute URIs are read
- /// directly, while relative URIs are resolved from the [sdkRoot].
- // TODO(sigmund): provide also a flag to load this data from a file (like
- // libraries.json)
- @Deprecated("Unused internally.")
- Map<String, List<Uri>> targetPatches = <String, List<Uri>>{};
-
/// Enable or disable experimental features. Features mapping to `true` are
/// explicitly enabled. Features mapping to `false` are explicitly disabled.
/// Features not mentioned in the map will have their default value.
Map<ExperimentalFlag, bool> explicitExperimentalFlags =
<ExperimentalFlag, bool>{};
- Map<ExperimentalFlag, bool> defaultExperimentFlagsForTesting;
- AllowedExperimentalFlags allowedExperimentalFlagsForTesting;
- Map<ExperimentalFlag, Version> experimentEnabledVersionForTesting;
- Map<ExperimentalFlag, Version> experimentReleasedVersionForTesting;
+ Map<ExperimentalFlag, bool>? defaultExperimentFlagsForTesting;
+ AllowedExperimentalFlags? allowedExperimentalFlagsForTesting;
+ Map<ExperimentalFlag, Version>? experimentEnabledVersionForTesting;
+ Map<ExperimentalFlag, Version>? experimentReleasedVersionForTesting;
/// Environment map used when evaluating `bool.fromEnvironment`,
/// `int.fromEnvironment` and `String.fromEnvironment` during constant
/// evaluation. If the map is `null`, all environment constants will be left
/// unevaluated and can be evaluated by a constant evaluator later.
- Map<String, String> environmentDefines = null;
+ Map<String, String>? environmentDefines = null;
/// Report an error if a constant could not be evaluated (either because it
/// is an environment constant and no environment was specified, or because
@@ -171,12 +149,7 @@
/// * how to deal with non-standard features like `native` extensions.
///
/// If not specified, the default target is the VM.
- Target target;
-
- /// Deprecated. Has no affect on front-end.
- // TODO(dartbug.com/37514) Remove this field once DDK removes its uses of it.
- @Deprecated("Unused internally.")
- bool enableAsserts = false;
+ Target? target;
/// Whether to show verbose messages (mainly for debugging and performance
/// tracking).
@@ -353,8 +326,8 @@
}
if (target != other.target) {
if (target.runtimeType != other.target.runtimeType) return false;
- if (target.name != other.target.name) return false;
- if (target.flags != other.target.flags) return false;
+ if (target?.name != other.target?.name) return false;
+ if (target?.flags != other.target?.flags) return false;
}
// enableAsserts is not used anywhere, so ignored here.
if (!ignoreVerbose) {
@@ -391,7 +364,7 @@
/// Parse experimental flag arguments of the form 'flag' or 'no-flag' into a map
/// from 'flag' to `true` or `false`, respectively.
-Map<String, bool> parseExperimentalArguments(List<String> arguments) {
+Map<String, bool> parseExperimentalArguments(List<String>? arguments) {
Map<String, bool> result = {};
if (arguments != null) {
for (String argument in arguments) {
@@ -419,14 +392,14 @@
/// If an expired flag is set to its default value the supplied warning
/// handler is called with a warning message.
Map<ExperimentalFlag, bool> parseExperimentalFlags(
- Map<String, bool> experiments,
- {void onError(String message),
- void onWarning(String message)}) {
+ Map<String, bool>? experiments,
+ {required void Function(String message) onError,
+ void Function(String message)? onWarning}) {
Map<ExperimentalFlag, bool> flags = <ExperimentalFlag, bool>{};
if (experiments != null) {
for (String experiment in experiments.keys) {
- bool value = experiments[experiment];
- ExperimentalFlag flag = parseExperimentalFlag(experiment);
+ bool value = experiments[experiment]!;
+ ExperimentalFlag? flag = parseExperimentalFlag(experiment);
if (flag == null) {
onError("Unknown experiment: " + experiment);
} else if (flags.containsKey(flag)) {
@@ -435,7 +408,7 @@
"Experiment specified with conflicting values: " + experiment);
}
} else {
- if (expiredExperimentalFlags[flag]) {
+ if (expiredExperimentalFlags[flag]!) {
if (value != defaultExperimentalFlags[flag]) {
/// Produce an error when the value is not the default value.
if (value) {
@@ -447,7 +420,7 @@
experiment +
" is no longer supported.");
}
- value = defaultExperimentalFlags[flag];
+ value = defaultExperimentalFlags[flag]!;
} else if (onWarning != null) {
/// Produce a warning when the value is the default value.
if (value) {
@@ -492,11 +465,11 @@
/// If a name isn't recognized and [onError] isn't provided, an error is
/// thrown.
static Set<InvocationMode> parseArguments(String arg,
- {void Function(String) onError}) {
+ {void Function(String)? onError}) {
Set<InvocationMode> result = {};
for (String name in arg.split(',')) {
if (name.isNotEmpty) {
- InvocationMode mode = fromName(name);
+ InvocationMode? mode = fromName(name);
if (mode == null) {
String message = "Unknown invocation mode '$name'.";
if (onError != null) {
@@ -513,7 +486,7 @@
}
/// Returns the [InvocationMode] with the given [name].
- static InvocationMode fromName(String name) {
+ static InvocationMode? fromName(String name) {
for (InvocationMode invocationMode in values) {
if (name == invocationMode.name) {
return invocationMode;
@@ -560,7 +533,7 @@
/// If [name] isn't recognized and [onError] isn't provided, an error is
/// thrown.
static Verbosity parseArgument(String name,
- {void Function(String) onError, Verbosity defaultValue: Verbosity.all}) {
+ {void Function(String)? onError, Verbosity defaultValue: Verbosity.all}) {
for (Verbosity verbosity in values) {
if (name == verbosity.name) {
return verbosity;
@@ -588,7 +561,6 @@
case Severity.ignored:
return false;
}
- break;
case Verbosity.warning:
switch (severity) {
case Severity.internalProblem:
@@ -600,7 +572,6 @@
case Severity.ignored:
return false;
}
- break;
case Verbosity.info:
switch (severity) {
case Severity.internalProblem:
@@ -612,7 +583,6 @@
case Severity.ignored:
return false;
}
- break;
case Verbosity.all:
return true;
}
diff --git a/pkg/front_end/lib/src/api_prototype/standard_file_system.dart b/pkg/front_end/lib/src/api_prototype/standard_file_system.dart
index 35d34d5..ead93b4 100644
--- a/pkg/front_end/lib/src/api_prototype/standard_file_system.dart
+++ b/pkg/front_end/lib/src/api_prototype/standard_file_system.dart
@@ -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.9
-
library front_end.standard_file_system;
import 'dart:io' as io;
@@ -112,7 +110,7 @@
*/
FileSystemException _toFileSystemException(io.FileSystemException exception) {
String message = exception.message;
- String osMessage = exception.osError?.message;
+ String? osMessage = exception.osError?.message;
if (osMessage != null && osMessage.isNotEmpty) {
message = osMessage;
}
@@ -125,7 +123,9 @@
@override
final Uri uri;
- DataFileSystemEntity(this.uri);
+ DataFileSystemEntity(this.uri)
+ : assert(uri.scheme == 'data'),
+ assert(uri.data != null);
@override
int get hashCode => uri.hashCode;
@@ -141,7 +141,7 @@
@override
Future<List<int>> readAsBytes() async {
- return uri.data.contentAsBytes();
+ return uri.data!.contentAsBytes();
}
@override
@@ -152,6 +152,6 @@
@override
Future<String> readAsString() async {
- return uri.data.contentAsString();
+ return uri.data!.contentAsString();
}
}
diff --git a/pkg/front_end/lib/src/base/processed_options.dart b/pkg/front_end/lib/src/base/processed_options.dart
index 60c4162..68d1a44 100644
--- a/pkg/front_end/lib/src/base/processed_options.dart
+++ b/pkg/front_end/lib/src/base/processed_options.dart
@@ -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.9
-
import 'dart:io' show exitCode;
import 'dart:typed_data' show Uint8List;
@@ -99,16 +97,16 @@
/// The package map derived from the options, or `null` if the package map has
/// not been computed yet.
- PackageConfig _packages;
+ PackageConfig? _packages;
/// The uri for .packages derived from the options, or `null` if the package
/// map has not been computed yet or there is no .packages in effect.
- Uri _packagesUri;
- Uri get packagesUri => _packagesUri;
+ Uri? _packagesUri;
+ Uri? get packagesUri => _packagesUri;
/// The object that knows how to resolve "package:" and "dart:" URIs,
/// or `null` if it has not been computed yet.
- UriTranslator _uriTranslator;
+ UriTranslator? _uriTranslator;
/// The SDK summary, or `null` if it has not been read yet.
///
@@ -116,7 +114,7 @@
/// where all method bodies are left out. In essence, it contains just API
/// signatures and constants. The summary should include inferred top-level
/// types unless legacy mode is enabled.
- Component _sdkSummaryComponent;
+ Component? _sdkSummaryComponent;
/// The component for each uri in `options.additionalDills`.
///
@@ -124,45 +122,45 @@
/// where all method bodies are left out. In essence, it contains just API
/// signatures and constants. The summaries should include inferred top-level
/// types unless legacy mode is enabled.
- List<Component> _additionalDillComponents;
+ List<Component>? _additionalDillComponents;
/// The location of the SDK, or `null` if the location hasn't been determined
/// yet.
- Uri _sdkRoot;
- Uri get sdkRoot {
+ Uri? _sdkRoot;
+ Uri? get sdkRoot {
_ensureSdkDefaults();
return _sdkRoot;
}
- Uri _sdkSummary;
- Uri get sdkSummary {
+ Uri? _sdkSummary;
+ Uri? get sdkSummary {
_ensureSdkDefaults();
return _sdkSummary;
}
- List<int> _sdkSummaryBytes;
+ List<int>? _sdkSummaryBytes;
bool _triedLoadingSdkSummary = false;
/// Get the bytes of the SDK outline, if any.
- Future<List<int>> loadSdkSummaryBytes() async {
+ Future<List<int>?> loadSdkSummaryBytes() async {
if (_sdkSummaryBytes == null && !_triedLoadingSdkSummary) {
if (sdkSummary == null) return null;
- FileSystemEntity entry = fileSystem.entityForUri(sdkSummary);
+ FileSystemEntity entry = fileSystem.entityForUri(sdkSummary!);
_sdkSummaryBytes = await _readAsBytes(entry);
_triedLoadingSdkSummary = true;
}
return _sdkSummaryBytes;
}
- Uri _librariesSpecificationUri;
- Uri get librariesSpecificationUri {
+ Uri? _librariesSpecificationUri;
+ Uri? get librariesSpecificationUri {
_ensureSdkDefaults();
return _librariesSpecificationUri;
}
Ticker ticker;
- Uri get packagesUriRaw => _raw.packagesFileUri;
+ Uri? get packagesUriRaw => _raw.packagesFileUri;
bool get verbose => _raw.verbose;
@@ -192,9 +190,9 @@
final List<Uri> inputs;
/// The Uri where output is generated, may be null.
- final Uri output;
+ final Uri? output;
- final Map<String, String> environmentDefines;
+ final Map<String, String>? environmentDefines;
bool get errorOnUnevaluatedConstant => _raw.errorOnUnevaluatedConstant;
@@ -202,7 +200,7 @@
int fatalDiagnosticCount = 0;
/// Initializes a [ProcessedOptions] object wrapping the given [rawOptions].
- ProcessedOptions({CompilerOptions options, List<Uri> inputs, this.output})
+ ProcessedOptions({CompilerOptions? options, List<Uri>? inputs, this.output})
: this._raw = options ?? new CompilerOptions(),
this.inputs = inputs ?? <Uri>[],
// TODO(askesc): Copy the map when kernel_service supports that.
@@ -212,20 +210,20 @@
this.ticker = new Ticker(isVerbose: options?.verbose ?? false);
FormattedMessage format(
- LocatedMessage message, Severity severity, List<LocatedMessage> context,
- {List<Uri> involvedFiles}) {
+ LocatedMessage message, Severity severity, List<LocatedMessage>? context,
+ {List<Uri>? involvedFiles}) {
int offset = message.charOffset;
- Uri uri = message.uri;
- Location location = offset == -1 ? null : getLocation(uri, offset);
+ Uri? uri = message.uri;
+ Location? location =
+ offset == -1 || uri == null ? null : getLocation(uri, offset);
PlainAndColorizedString formatted =
command_line_reporting.format(message, severity, location: location);
- List<FormattedMessage> formattedContext;
+ List<FormattedMessage>? formattedContext;
if (context != null && context.isNotEmpty) {
formattedContext =
- new List<FormattedMessage>.filled(context.length, null);
- for (int i = 0; i < context.length; i++) {
- formattedContext[i] = format(context[i], Severity.context, null);
- }
+ new List<FormattedMessage>.generate(context.length, (int i) {
+ return format(context[i], Severity.context, null);
+ });
}
return message.withFormatting(formatted, location?.line ?? -1,
location?.column ?? -1, severity, formattedContext,
@@ -233,7 +231,7 @@
}
void report(LocatedMessage message, Severity severity,
- {List<LocatedMessage> context, List<Uri> involvedFiles}) {
+ {List<LocatedMessage>? context, List<Uri>? involvedFiles}) {
if (command_line_reporting.isHidden(severity)) return;
if (command_line_reporting.isCompileTimeError(severity)) {
CompilerContext.current.logError(message, severity);
@@ -304,13 +302,13 @@
}
if (_raw.sdkRoot != null &&
- !await fileSystem.entityForUri(sdkRoot).exists()) {
+ !await fileSystem.entityForUri(sdkRoot!).exists()) {
reportWithoutLocation(
- templateSdkRootNotFound.withArguments(sdkRoot), Severity.error);
+ templateSdkRootNotFound.withArguments(sdkRoot!), Severity.error);
return false;
}
- Uri summary = sdkSummary;
+ Uri? summary = sdkSummary;
if (summary != null && !await fileSystem.entityForUri(summary).exists()) {
reportWithoutLocation(
templateSdkSummaryNotFound.withArguments(summary), Severity.error);
@@ -340,7 +338,7 @@
/// whole-program.
bool get compileSdk => _raw.compileSdk;
- FileSystem _fileSystem;
+ FileSystem? _fileSystem;
/// Get the [FileSystem] which should be used by the front end to access
/// files.
@@ -358,7 +356,7 @@
/// version).
String get currentSdkVersion => _raw.currentSdkVersion;
- Target _target;
+ Target? _target;
Target get target =>
_target ??= _raw.target ?? new NoneTarget(new TargetFlags());
@@ -429,10 +427,10 @@
/// Get an outline component that summarizes the SDK, if any.
// TODO(sigmund): move, this doesn't feel like an "option".
- Future<Component> loadSdkSummary(CanonicalName nameRoot) async {
+ Future<Component?> loadSdkSummary(CanonicalName nameRoot) async {
if (_sdkSummaryComponent == null) {
if (sdkSummary == null) return null;
- List<int> bytes = await loadSdkSummaryBytes();
+ List<int>? bytes = await loadSdkSummaryBytes();
if (bytes != null && bytes.isNotEmpty) {
_sdkSummaryComponent =
loadComponent(bytes, nameRoot, fileUri: sdkSummary);
@@ -455,19 +453,20 @@
Future<List<Component>> loadAdditionalDills(CanonicalName nameRoot) async {
if (_additionalDillComponents == null) {
List<Uri> uris = _raw.additionalDills;
+ // ignore: unnecessary_null_comparison
if (uris == null || uris.isEmpty) return const <Component>[];
// TODO(sigmund): throttle # of concurrent operations.
- List<List<int>> allBytes = await Future.wait(
+ List<List<int>?> allBytes = await Future.wait(
uris.map((uri) => _readAsBytes(fileSystem.entityForUri(uri))));
List<Component> result = [];
for (int i = 0; i < uris.length; i++) {
- if (allBytes[i] == null) continue;
- List<int> bytes = allBytes[i];
+ List<int>? bytes = allBytes[i];
+ if (bytes == null) continue;
result.add(loadComponent(bytes, nameRoot, fileUri: uris[i]));
}
_additionalDillComponents = result;
}
- return _additionalDillComponents;
+ return _additionalDillComponents!;
}
void set loadAdditionalDillsComponents(List<Component> components) {
@@ -480,7 +479,7 @@
/// Helper to load a .dill file from [uri] using the existing [nameRoot].
Component loadComponent(List<int> bytes, CanonicalName nameRoot,
- {bool alwaysCreateNewNamedNodes, Uri fileUri}) {
+ {bool? alwaysCreateNewNamedNodes, Uri? fileUri}) {
Component component =
target.configureComponent(new Component(nameRoot: nameRoot));
// TODO(ahe): Control lazy loading via an option.
@@ -510,7 +509,7 @@
ticker.logMs("Read packages file");
_uriTranslator = new UriTranslator(libraries, packages);
}
- return _uriTranslator;
+ return _uriTranslator!;
}
Future<TargetLibrariesSpecification> _computeLibrarySpecification() async {
@@ -520,21 +519,22 @@
if (name.endsWith('_fasta')) name = name.substring(0, name.length - 6);
if (librariesSpecificationUri == null ||
- !await fileSystem.entityForUri(librariesSpecificationUri).exists()) {
+ !await fileSystem.entityForUri(librariesSpecificationUri!).exists()) {
if (compileSdk) {
reportWithoutLocation(
templateSdkSpecificationNotFound
- .withArguments(librariesSpecificationUri),
+ .withArguments(librariesSpecificationUri!),
Severity.error);
}
return new TargetLibrariesSpecification(name);
}
- String json =
- await fileSystem.entityForUri(librariesSpecificationUri).readAsString();
+ String json = await fileSystem
+ .entityForUri(librariesSpecificationUri!)
+ .readAsString();
try {
LibrariesSpecification spec =
- await LibrariesSpecification.parse(librariesSpecificationUri, json);
+ await LibrariesSpecification.parse(librariesSpecificationUri!, json);
return spec.specificationFor(name);
} on LibrariesSpecificationException catch (e) {
reportWithoutLocation(
@@ -549,10 +549,10 @@
/// This is an asynchronous getter since file system operations may be
/// required to locate/read the packages file.
Future<PackageConfig> _getPackages() async {
- if (_packages != null) return _packages;
+ if (_packages != null) return _packages!;
_packagesUri = null;
if (_raw.packagesFileUri != null) {
- return _packages = await createPackagesFromFile(_raw.packagesFileUri);
+ return _packages = await createPackagesFromFile(_raw.packagesFileUri!);
}
if (inputs.length > 1) {
@@ -582,7 +582,7 @@
return _packages = await _findPackages(inputs.first);
}
- Future<Uint8List> _readFile(Uri uri, bool reportError) async {
+ Future<Uint8List?> _readFile(Uri uri, bool reportError) async {
try {
// TODO(ahe): We need to compute line endings for this file.
FileSystemEntity entityForUri = fileSystem.entityForUri(uri);
@@ -616,9 +616,9 @@
/// based in [forceCreation]).
/// If the file does exist but is invalid an error is always reported and an
/// empty package config is returned.
- Future<PackageConfig> _createPackagesFromFile(
+ Future<PackageConfig?> _createPackagesFromFile(
Uri requestedUri, bool forceCreation, bool requireJson) async {
- Uint8List contents = await _readFile(requestedUri, forceCreation);
+ Uint8List? contents = await _readFile(requestedUri, forceCreation);
if (contents == null) {
if (forceCreation) {
_packagesUri = null;
@@ -634,7 +634,7 @@
report(
templatePackagesFileFormat
.withArguments(error.message)
- .withLocation(requestedUri, error.offset, noLength),
+ .withLocation(requestedUri, error.offset ?? -1, noLength),
Severity.error);
} else {
reportWithoutLocation(
@@ -658,7 +658,7 @@
report(
templatePackagesFileFormat
.withArguments(e.message)
- .withLocation(requestedUri, e.offset, noLength),
+ .withLocation(requestedUri, e.offset ?? -1, noLength),
Severity.error);
} catch (e) {
reportWithoutLocation(
@@ -679,14 +679,15 @@
// If the input is a ".packages" file we assume the standard layout, and
// if a ".dart_tool/package_config.json" exists, we'll use that (and require
// it to be a json file).
+ PackageConfig? result;
if (file.path.endsWith("/.packages")) {
// .packages -> try the package_config first.
Uri tryFirst = file.resolve(".dart_tool/package_config.json");
- PackageConfig result =
- await _createPackagesFromFile(tryFirst, false, true);
+ result = await _createPackagesFromFile(tryFirst, false, true);
if (result != null) return result;
}
- return _createPackagesFromFile(file, true, false);
+ result = await _createPackagesFromFile(file, true, false);
+ return result ?? PackageConfig.empty;
}
/// Finds a package resolution strategy using a [FileSystem].
@@ -711,8 +712,8 @@
return PackageConfig.empty;
}
- Future<Uri> checkInDir(Uri dir) async {
- Uri candidate;
+ Future<Uri?> checkInDir(Uri dir) async {
+ Uri? candidate;
try {
candidate = dir.resolve('.dart_tool/package_config.json');
if (await fileSystem.entityForUri(candidate).exists()) return candidate;
@@ -721,7 +722,7 @@
return null;
} catch (e) {
Message message =
- templateExceptionReadingFile.withArguments(candidate, '$e');
+ templateExceptionReadingFile.withArguments(candidate!, '$e');
reportWithoutLocation(message, Severity.error);
// We throw a new exception to ensure that the message include the uri
// that led to the exception. Exceptions in Uri don't include the
@@ -731,7 +732,7 @@
}
// Check for $cwd/.packages
- Uri candidate = await checkInDir(dir);
+ Uri? candidate = await checkInDir(dir);
if (candidate != null) return createPackagesFromFile(candidate);
// Check for cwd(/..)+/.packages
@@ -756,7 +757,7 @@
void _ensureSdkDefaults() {
if (_computedSdkDefaults) return;
_computedSdkDefaults = true;
- Uri root = _raw.sdkRoot;
+ Uri? root = _raw.sdkRoot;
if (root != null) {
// Normalize to always end in '/'
if (!root.path.endsWith('/')) {
@@ -781,7 +782,7 @@
if (_raw.librariesSpecificationUri != null) {
_librariesSpecificationUri = _raw.librariesSpecificationUri;
} else if (compileSdk) {
- _librariesSpecificationUri = sdkRoot.resolve('lib/libraries.json');
+ _librariesSpecificationUri = sdkRoot!.resolve('lib/libraries.json');
}
}
@@ -835,7 +836,7 @@
return '$sb';
}
- Future<List<int>> _readAsBytes(FileSystemEntity file) async {
+ Future<List<int>?> _readAsBytes(FileSystemEntity file) async {
try {
return await file.readAsBytes();
} on FileSystemException catch (error) {
diff --git a/pkg/front_end/lib/src/compute_platform_binaries_location.dart b/pkg/front_end/lib/src/compute_platform_binaries_location.dart
index dce1614..0ecacc07 100644
--- a/pkg/front_end/lib/src/compute_platform_binaries_location.dart
+++ b/pkg/front_end/lib/src/compute_platform_binaries_location.dart
@@ -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.9
-
import "dart:io" show File, Platform;
import 'package:kernel/ast.dart' show Source;
@@ -19,7 +17,7 @@
///
/// If the target doesn't have a default platform dill file for the nnbd mode,
/// [onError] is called.
-String computePlatformDillName(
+String? computePlatformDillName(
Target target, NnbdMode nnbdMode, void Function() onError) {
switch (target.name) {
case 'dartdevc':
@@ -69,7 +67,7 @@
/// of the platform libraries that are used to avoid recompiling those
/// libraries.
Uri computePlatformBinariesLocation({bool forceBuildDir: false}) {
- String resolvedExecutable = Platform.environment['resolvedExecutable'];
+ String? resolvedExecutable = Platform.environment['resolvedExecutable'];
// The directory of the Dart VM executable.
Uri vmDirectory = Uri.base
.resolveUri(
@@ -93,7 +91,7 @@
String path = uri.path;
if (path.startsWith("/sdk/")) {
CompilerContext context = CompilerContext.current;
- Uri sdkRoot = context.cachedSdkRoot;
+ Uri? sdkRoot = context.cachedSdkRoot;
if (sdkRoot == null) {
ProcessedOptions options = context.options;
sdkRoot = options.sdkRoot;
@@ -108,6 +106,7 @@
if (sdkRoot == null) {
sdkRoot = (options.sdkSummary ?? computePlatformBinariesLocation())
.resolve("../../");
+ // ignore: unnecessary_null_comparison
if (sdkRoot != null) {
if (!isExistingFile(sdkRoot.resolve("lib/libraries.json"))) {
if (isExistingFile(sdkRoot.resolve("sdk/lib/libraries.json"))) {
@@ -124,7 +123,7 @@
Uri candidate = sdkRoot.resolve(path.substring(5));
if (isExistingFile(candidate)) {
Map<Uri, Source> uriToSource = CompilerContext.current.uriToSource;
- Source source = uriToSource[uri];
+ Source source = uriToSource[uri]!;
if (source.source.isEmpty) {
uriToSource[uri] = new Source(
source.lineStarts,
diff --git a/pkg/front_end/lib/src/fasta/builder/builder.dart b/pkg/front_end/lib/src/fasta/builder/builder.dart
index 4f2897d..fdd91f3 100644
--- a/pkg/front_end/lib/src/fasta/builder/builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/builder.dart
@@ -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.9
-
library fasta.declaration;
import '../problems.dart' show unsupported;
@@ -12,7 +10,7 @@
/// Used when multiple things with the same name are declared within the same
/// parent. Only used for top-level and class-member declarations, not for
/// block scopes.
- Builder next;
+ Builder? next;
Builder get parent;
@@ -211,7 +209,7 @@
abstract class BuilderImpl implements Builder {
@override
- Builder next;
+ Builder? next;
BuilderImpl();
@@ -298,7 +296,6 @@
int finishPatch() {
if (!isPatch) return 0;
unsupported("${runtimeType}.finishPatch", charOffset, fileUri);
- return 0;
}
@override
diff --git a/pkg/front_end/lib/src/fasta/command_line_reporting.dart b/pkg/front_end/lib/src/fasta/command_line_reporting.dart
index 9ff9cf4..528c601 100644
--- a/pkg/front_end/lib/src/fasta/command_line_reporting.dart
+++ b/pkg/front_end/lib/src/fasta/command_line_reporting.dart
@@ -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.9
-
/// Provides a default implementation of the report and format methods of
/// [CompilerContext] that are suitable for command-line tools. The methods in
/// this library aren't intended to be called directly, instead, one should use
@@ -46,7 +44,7 @@
/// command-line tool. This includes source snippets and - in the colorized
/// version - different colors based on [severity].
PlainAndColorizedString format(LocatedMessage message, Severity severity,
- {Location location, Map<Uri, Source> uriToSource}) {
+ {Location? location, Map<Uri, Source>? uriToSource}) {
try {
int length = message.length;
if (length < 1) {
@@ -54,7 +52,7 @@
// empty names.
length = 1;
}
- String prefix = severityPrefixes[severity];
+ String? prefix = severityPrefixes[severity];
String messageTextTmp =
prefix == null ? message.message : "$prefix: ${message.message}";
if (message.tip != null) {
@@ -87,13 +85,13 @@
if (message.uri != null) {
String path =
- relativizeUri(Uri.base, translateSdk(message.uri), isWindows);
+ relativizeUri(Uri.base, translateSdk(message.uri!), isWindows);
int offset = message.charOffset;
- location ??= (offset == -1 ? null : getLocation(message.uri, offset));
+ location ??= (offset == -1 ? null : getLocation(message.uri!, offset));
if (location?.line == TreeNode.noOffset) {
location = null;
}
- String sourceLine = getSourceLine(location, uriToSource);
+ String? sourceLine = getSourceLine(location, uriToSource);
return new PlainAndColorizedString(
formatErrorMessage(
sourceLine, location, length, path, messageTextPlain),
@@ -115,9 +113,9 @@
}
}
-String formatErrorMessage(String sourceLine, Location location,
+String formatErrorMessage(String? sourceLine, Location? location,
int squigglyLength, String path, String messageText) {
- if (sourceLine == null) {
+ if (sourceLine == null || location == null) {
sourceLine = "";
} else if (sourceLine.isNotEmpty) {
// TODO(askesc): Much more could be done to indent properly in the
@@ -167,7 +165,6 @@
case Severity.ignored:
return true;
}
- return unhandled("$severity", "isHidden", -1, null);
}
/// Are problems of [severity] fatal? That is, should the compiler terminate
@@ -188,7 +185,6 @@
case Severity.context:
return false;
}
- return unhandled("$severity", "shouldThrowOn", -1, null);
}
bool isCompileTimeError(Severity severity) {
diff --git a/pkg/front_end/lib/src/fasta/compiler_context.dart b/pkg/front_end/lib/src/fasta/compiler_context.dart
index 67cfc5a..a3a99e1 100644
--- a/pkg/front_end/lib/src/fasta/compiler_context.dart
+++ b/pkg/front_end/lib/src/fasta/compiler_context.dart
@@ -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.9
-
library fasta.compiler_context;
import 'dart:async' show Zone, runZoned;
@@ -53,7 +51,7 @@
FileSystem get fileSystem => options.fileSystem;
- Uri cachedSdkRoot = null;
+ Uri? cachedSdkRoot = null;
bool compilingPlatform = false;
@@ -65,7 +63,7 @@
/// Report [message], for example, by printing it.
void report(LocatedMessage message, Severity severity,
- {List<LocatedMessage> context, List<Uri> involvedFiles}) {
+ {List<LocatedMessage>? context, List<Uri>? involvedFiles}) {
options.report(message, severity,
context: context, involvedFiles: involvedFiles);
}
@@ -91,19 +89,19 @@
if (uri.scheme != "file" && uri.scheme != "http") {
throw new ArgumentError("Expected a file or http URI, but got: '$uri'.");
}
- CompilerContext context = Zone.current[compilerContextKey];
+ CompilerContext? context = Zone.current[compilerContextKey];
if (context != null) {
context.dependencies.add(uri);
}
}
static CompilerContext get current {
- CompilerContext context = Zone.current[compilerContextKey];
+ CompilerContext? context = Zone.current[compilerContextKey];
if (context == null) {
// Note: we throw directly and don't use internalProblem, because
// internalProblem depends on having a compiler context available.
String message = messageInternalProblemMissingContext.message;
- String tip = messageInternalProblemMissingContext.tip;
+ String tip = messageInternalProblemMissingContext.tip!;
throw "Internal problem: $message\nTip: $tip";
}
return context;
diff --git a/pkg/front_end/lib/src/fasta/crash.dart b/pkg/front_end/lib/src/fasta/crash.dart
index 82e44be..cc692ad 100644
--- a/pkg/front_end/lib/src/fasta/crash.dart
+++ b/pkg/front_end/lib/src/fasta/crash.dart
@@ -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.9
-
library fasta.crash;
import 'dart:convert' show jsonEncode;
@@ -22,16 +20,16 @@
/// Tracks the first source URI that has been read and is used as a fall-back
/// for [reportCrash]. Should be reset between each compilation by calling
/// [resetCrashReporting].
-Uri firstSourceUri;
+Uri? firstSourceUri;
class Crash {
- final Uri uri;
+ final Uri? uri;
- final int charOffset;
+ final int? charOffset;
final Object error;
- final StackTrace trace;
+ final StackTrace? trace;
Crash(this.uri, this.charOffset, this.error, this.trace);
@@ -50,7 +48,7 @@
}
Future<T> reportCrash<T>(error, StackTrace trace,
- [Uri uri, int charOffset]) async {
+ [Uri? uri, int? charOffset]) async {
note(String note) async {
stderr.write(note);
await stderr.flush();
@@ -85,12 +83,13 @@
return new Future<T>.error(
new Crash(uri, charOffset, error, trace), trace);
}
+ // ignore: unnecessary_null_comparison
if (request != null) {
await note("\nSending crash report data");
request.persistentConnection = false;
request.bufferOutput = false;
- String host = request?.connectionInfo?.remoteAddress?.host;
- int port = request?.connectionInfo?.remotePort;
+ String? host = request.connectionInfo?.remoteAddress.host;
+ int? port = request.connectionInfo?.remotePort;
await note(" to $host:$port");
await request
..headers.contentType = ContentType.json
diff --git a/pkg/front_end/lib/src/fasta/fasta_codes.dart b/pkg/front_end/lib/src/fasta/fasta_codes.dart
index 446cd72..50f79c1 100644
--- a/pkg/front_end/lib/src/fasta/fasta_codes.dart
+++ b/pkg/front_end/lib/src/fasta/fasta_codes.dart
@@ -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.9
-
library fasta.codes;
import 'package:_fe_analyzer_shared/src/messages/codes.dart'
diff --git a/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart b/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart
index aa44eb0..4efd282 100644
--- a/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart
+++ b/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart
@@ -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.9
-
// NOTE: THIS FILE IS GENERATED. DO NOT EDIT.
//
// Instead modify 'pkg/front_end/messages.yaml' and run
diff --git a/pkg/front_end/lib/src/fasta/hybrid_file_system.dart b/pkg/front_end/lib/src/fasta/hybrid_file_system.dart
index 10b1a47..56b1627 100644
--- a/pkg/front_end/lib/src/fasta/hybrid_file_system.dart
+++ b/pkg/front_end/lib/src/fasta/hybrid_file_system.dart
@@ -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.9
-
/// A memory + physical file system used to mock input for tests but provide
/// sdk sources from disk.
library front_end.src.hybrid_file_system;
@@ -18,7 +16,7 @@
final MemoryFileSystem memory;
final FileSystem physical;
- HybridFileSystem(this.memory, [FileSystem _physical])
+ HybridFileSystem(this.memory, [FileSystem? _physical])
: physical = _physical ?? StandardFileSystem.instance;
@override
@@ -30,19 +28,19 @@
/// entity.
class HybridFileSystemEntity implements FileSystemEntity {
final Uri uri;
- FileSystemEntity _delegate;
+ FileSystemEntity? _delegate;
final HybridFileSystem _fs;
HybridFileSystemEntity(this.uri, this._fs);
Future<FileSystemEntity> get delegate async {
- if (_delegate != null) return _delegate;
+ if (_delegate != null) return _delegate!;
FileSystemEntity entity = _fs.memory.entityForUri(uri);
if (((uri.scheme != 'file' && uri.scheme != 'data') &&
_fs.physical is StandardFileSystem) ||
await entity.exists()) {
_delegate = entity;
- return _delegate;
+ return _delegate!;
}
return _delegate = _fs.physical.entityForUri(uri);
}
diff --git a/pkg/front_end/lib/src/fasta/identifiers.dart b/pkg/front_end/lib/src/fasta/identifiers.dart
index f7dcd4f..422569a 100644
--- a/pkg/front_end/lib/src/fasta/identifiers.dart
+++ b/pkg/front_end/lib/src/fasta/identifiers.dart
@@ -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.9
-
library fasta.qualified_name;
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart' show Token;
@@ -21,7 +19,7 @@
int get charOffset => token.charOffset;
- Expression get initializer => null;
+ Expression? get initializer => null;
int get endCharOffset => charOffset + name.length;
diff --git a/pkg/front_end/lib/src/fasta/ignored_parser_errors.dart b/pkg/front_end/lib/src/fasta/ignored_parser_errors.dart
index 04b0e4a..fbd01f9 100644
--- a/pkg/front_end/lib/src/fasta/ignored_parser_errors.dart
+++ b/pkg/front_end/lib/src/fasta/ignored_parser_errors.dart
@@ -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.9
-
library fasta.ignored_parser_errors;
import 'package:_fe_analyzer_shared/src/parser/parser.dart' show optional;
diff --git a/pkg/front_end/lib/src/fasta/kernel/class_hierarchy_builder.dart b/pkg/front_end/lib/src/fasta/kernel/class_hierarchy_builder.dart
index 38ee51c..2e0f2fb 100644
--- a/pkg/front_end/lib/src/fasta/kernel/class_hierarchy_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/class_hierarchy_builder.dart
@@ -57,7 +57,6 @@
templateCombinedMemberSignatureFailed,
templateDuplicatedDeclaration,
templateDuplicatedDeclarationCause,
- templateDuplicatedDeclarationUse,
templateMissingImplementationCause,
templateMissingImplementationNotAbstract;
@@ -724,34 +723,9 @@
?.getMember(this);
}
- Member getDispatchTargetKernel(Class cls, Name name, bool isSetter) {
- ClassMember classMember =
- getNodeFromClass(cls).getDispatchTarget(name, isSetter);
- Member member = classMember?.getMember(this);
- if (member != null && member.isAbstract) {
- if (cls.superclass != null) {
- return getDispatchTargetKernel(cls.superclass, name, isSetter);
- } else {
- return null;
- }
- }
- return member;
- }
-
- Member getCombinedMemberSignatureKernel(Class cls, Name name, bool isSetter,
- int charOffset, SourceLibraryBuilder library) {
- ClassMember declaration =
- getNodeFromClass(cls).getInterfaceMember(name, isSetter);
- if (declaration?.isStatic ?? true) return null;
- if (declaration.isDuplicate) {
- library?.addProblem(
- templateDuplicatedDeclarationUse.withArguments(name.text),
- charOffset,
- name.text.length,
- library.fileUri);
- return null;
- }
- return declaration.getMember(this);
+ ClassMember getInterfaceClassMember(Class cls, Name name,
+ {bool setter: false}) {
+ return getNodeFromClass(cls).getInterfaceMember(name, setter);
}
static ClassHierarchyBuilder build(ClassBuilder objectClass,
diff --git a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
index d6e8775..cd9256e 100644
--- a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
@@ -2075,6 +2075,18 @@
}
}
+ /// Converts integer constant types to an int value.
+ ///
+ /// Returns [null] on unmatched [intFolder] and [value] type.
+ int _convertToInt(Constant value) {
+ if (intFolder is JsConstantIntFolder && value is DoubleConstant) {
+ return value.value.toInt();
+ } else if (intFolder is VmConstantIntFolder && value is IntConstant) {
+ return value.value;
+ }
+ return null;
+ }
+
Constant _handleInvocation(
Expression node, Name name, Constant receiver, List<Constant> arguments) {
final String op = name.text;
@@ -2107,12 +2119,7 @@
case '[]':
if (enableConstFunctions) {
if (intFolder.isInt(other)) {
- int index;
- if (intFolder is JsConstantIntFolder) {
- index = (other as DoubleConstant).value.toInt();
- } else if (intFolder is VmConstantIntFolder) {
- index = (other as IntConstant).value;
- }
+ int index = _convertToInt(other);
assert(index != null);
if (index < 0 || index >= receiver.value.length) {
@@ -2218,6 +2225,31 @@
}
} else if (receiver is NullConstant) {
return createErrorConstant(node, messageConstEvalNullValue);
+ } else if (receiver is ListConstant && enableConstFunctions) {
+ if (arguments.length == 1) {
+ final Constant other = arguments[0];
+ switch (op) {
+ case '[]':
+ if (intFolder.isInt(other)) {
+ int index = _convertToInt(other);
+ assert(index != null);
+
+ if (index < 0 || index >= receiver.entries.length) {
+ return new _AbortDueToThrowConstant(
+ node, new RangeError.index(index, receiver.entries));
+ }
+ return receiver.entries[index];
+ }
+ return createErrorConstant(
+ node,
+ templateConstEvalInvalidBinaryOperandType.withArguments(
+ '[]',
+ receiver,
+ typeEnvironment.coreTypes.intNonNullableRawType,
+ other.getType(_staticTypeContext),
+ isNonNullableByDefault));
+ }
+ }
} else if (receiver is MapConstant && enableConstFunctions) {
if (arguments.length == 1) {
final Constant other = arguments[0];
diff --git a/pkg/front_end/lib/src/fasta/kernel/implicit_type_argument.dart b/pkg/front_end/lib/src/fasta/kernel/implicit_type_argument.dart
index 3f27451..5582ac5 100644
--- a/pkg/front_end/lib/src/fasta/kernel/implicit_type_argument.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/implicit_type_argument.dart
@@ -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.md file.
-// @dart = 2.9
-
library fasta.implicit_type_argument;
import 'package:kernel/ast.dart'
@@ -35,11 +33,11 @@
@override
R accept1<R, A>(DartTypeVisitor1<R, A> v, A arg) {
- throw unhandled("$runtimeType", "${v.runtimeType}", -1, null);
+ return unhandled("$runtimeType", "${v.runtimeType}", -1, null);
}
@override
- visitChildren(Visitor<Object> v) {
+ visitChildren(Visitor v) {
unhandled("$runtimeType", "${v.runtimeType}", -1, null);
}
@@ -54,7 +52,7 @@
}
@override
- bool equals(Object other, Assumptions assumptions) => this == other;
+ bool equals(Object other, Assumptions? assumptions) => this == other;
@override
void toTextInternal(AstPrinter printer) {
diff --git a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
index 69a9aa7..38e815c 100644
--- a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
@@ -67,7 +67,6 @@
Expression node, DartType typeContext) {
unhandled("${node.runtimeType}", "InferenceVisitor", node.fileOffset,
inferrer.helper.uri);
- return new ExpressionInferenceResult(const InvalidType(), node);
}
@override
diff --git a/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart b/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart
index e097eca..9ac22d9 100644
--- a/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart
@@ -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.9
-
import 'dart:convert' show json;
import 'package:kernel/ast.dart';
@@ -24,7 +22,7 @@
final Map<String, List<LabeledNode>> nameMap = <String, List<LabeledNode>>{};
final bool printNullability;
- List<Object> result;
+ List<Object> result = const [];
TypeLabeler(this.printNullability);
@@ -34,6 +32,7 @@
/// representation (with labels on duplicated names) by the `join()` method.
List<Object> labelType(DartType type) {
// TODO(askesc): Remove null check when we are completely null clean here.
+ // ignore: unnecessary_null_comparison
if (type == null) return ["null-type"];
result = [];
type.accept(this);
@@ -46,6 +45,7 @@
/// representation (with labels on duplicated names) by the `join()` method.
List<Object> labelConstant(Constant constant) {
// TODO(askesc): Remove null check when we are completely null clean here.
+ // ignore: unnecessary_null_comparison
if (constant == null) return ["null-constant"];
result = [];
constant.accept(this);
@@ -73,7 +73,7 @@
LabeledNode nameForEntity(
TreeNode node, String nodeName, Uri importUri, Uri fileUri) {
- List<LabeledNode> labelsForName = nameMap[nodeName];
+ List<LabeledNode>? labelsForName = nameMap[nodeName];
if (labelsForName == null) {
// First encountered entity with this name
LabeledNode name =
@@ -112,8 +112,8 @@
result.add(nameForEntity(
typedefNode,
typedefNode.name,
- typedefNode?.enclosingLibrary?.importUri ?? unknownUri,
- typedefNode?.enclosingLibrary?.fileUri ?? unknownUri));
+ typedefNode.enclosingLibrary.importUri,
+ typedefNode.enclosingLibrary.fileUri));
if (node.typeArguments.isNotEmpty) {
result.add("<");
bool first = true;
@@ -150,17 +150,17 @@
}
void visitTypeParameterType(TypeParameterType node) {
- TreeNode parent = node.parameter;
+ TreeNode? parent = node.parameter;
while (parent is! Library && parent != null) {
parent = parent.parent;
}
// Note that this can be null if, for instance, the erroneous code is not
// actually in the tree - then we don't know where it comes from!
- Library enclosingLibrary = parent;
+ Library? enclosingLibrary = parent as Library?;
result.add(nameForEntity(
node.parameter,
- node.parameter.name,
+ node.parameter.name ?? '',
enclosingLibrary == null ? unknownUri : enclosingLibrary.importUri,
enclosingLibrary == null ? unknownUri : enclosingLibrary.fileUri));
addNullability(node.declaredNullability);
@@ -174,7 +174,7 @@
bool first = true;
for (TypeParameter param in node.typeParameters) {
if (!first) result.add(", ");
- result.add(param.name);
+ result.add(param.name ?? '');
if (isObject(param.bound) && param.defaultType is DynamicType) {
// Bound was not specified, and therefore should not be printed.
} else {
@@ -223,13 +223,14 @@
void visitInterfaceType(InterfaceType node) {
Class classNode = node.classNode;
+ // TODO(johnniwinther): Ensure enclosing libraries on classes earlier
+ // in the compiler to ensure types in error messages have context.
+ Library? enclosingLibrary = classNode.parent as Library?;
result.add(nameForEntity(
classNode,
classNode.name,
- // TODO(johnniwinther): Ensure enclosing libraries on classes earlier
- // in the compiler to ensure types in error messages have context.
- classNode?.enclosingLibrary?.importUri ?? unknownUri,
- classNode?.enclosingLibrary?.fileUri ?? unknownUri));
+ enclosingLibrary?.importUri ?? unknownUri,
+ enclosingLibrary?.fileUri ?? unknownUri));
if (node.typeArguments.isNotEmpty) {
result.add("<");
bool first = true;
@@ -251,11 +252,14 @@
}
void visitExtensionType(ExtensionType node) {
+ // TODO(johnniwinther): Ensure enclosing libraries on extensions earlier
+ // in the compiler to ensure types in error messages have context.
+ Library? enclosingLibrary = node.extension.parent as Library?;
result.add(nameForEntity(
node.extension,
node.extension.name,
- node.extension?.enclosingLibrary?.importUri ?? unknownUri,
- node.extension?.enclosingLibrary?.fileUri ?? unknownUri));
+ enclosingLibrary?.importUri ?? unknownUri,
+ enclosingLibrary?.fileUri ?? unknownUri));
if (node.typeArguments.isNotEmpty) {
result.add("<");
bool first = true;
@@ -289,7 +293,7 @@
void visitSymbolConstant(SymbolConstant node) {
String text = node.libraryReference != null
- ? '#${node.libraryReference.asLibrary.importUri}::${node.name}'
+ ? '#${node.libraryReference!.asLibrary.importUri}::${node.name}'
: '#${node.name}';
result.add(text);
}
@@ -307,7 +311,7 @@
if (field.isStatic) continue;
if (!first) result.add(", ");
result.add("${field.name}: ");
- node.fieldValues[field.getterReference].accept(this);
+ node.fieldValues[field.getterReference]!.accept(this);
first = false;
}
result.add("}");
@@ -358,7 +362,7 @@
void visitTearOffConstant(TearOffConstant node) {
Procedure procedure = node.procedure;
- Class classNode = procedure.enclosingClass;
+ Class? classNode = procedure.enclosingClass;
if (classNode != null) {
result.add(nameForEntity(
classNode,
@@ -406,7 +410,7 @@
this.node, this.name, this.importUri, this.fileUri, this.typeLabeler);
String toString() {
- List<LabeledNode> entityForName = typeLabeler.nameMap[name];
+ List<LabeledNode> entityForName = typeLabeler.nameMap[name]!;
if (entityForName.length == 1) {
return name;
}
@@ -417,7 +421,7 @@
if (importUri.scheme == 'dart' && importUri.path == 'core') {
if (node is Class && denylistedCoreClasses.contains(name)) {
// Denylisted core class. Only print if ambiguous.
- List<LabeledNode> entityForName = typeLabeler.nameMap[name];
+ List<LabeledNode> entityForName = typeLabeler.nameMap[name]!;
if (entityForName.length == 1) {
return "";
}
@@ -426,7 +430,7 @@
if (importUri == unknownUri || node is! Class) {
// We don't know where it comes from and/or it's not a class.
// Only print if ambiguous.
- List<LabeledNode> entityForName = typeLabeler.nameMap[name];
+ List<LabeledNode> entityForName = typeLabeler.nameMap[name]!;
if (entityForName.length == 1) {
return "";
}
diff --git a/pkg/front_end/lib/src/fasta/messages.dart b/pkg/front_end/lib/src/fasta/messages.dart
index 3f1330a..c348215 100644
--- a/pkg/front_end/lib/src/fasta/messages.dart
+++ b/pkg/front_end/lib/src/fasta/messages.dart
@@ -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.9
-
library fasta.messages;
import 'package:kernel/ast.dart'
@@ -15,24 +13,24 @@
bool get isVerbose => CompilerContext.current.options.verbose;
-Location getLocation(Uri uri, int charOffset) {
+Location? getLocation(Uri uri, int charOffset) {
return CompilerContext.current.uriToSource[uri]?.getLocation(uri, charOffset);
}
-Location getLocationFromUri(Uri uri, int charOffset) {
+Location? getLocationFromUri(Uri uri, int charOffset) {
if (charOffset == -1) return null;
return getLocation(uri, charOffset);
}
-String getSourceLine(Location location, [Map<Uri, Source> uriToSource]) {
+String? getSourceLine(Location? location, [Map<Uri, Source>? uriToSource]) {
if (location == null) return null;
uriToSource ??= CompilerContext.current.uriToSource;
return uriToSource[location.file]?.getTextLine(location.line);
}
-Location getLocationFromNode(TreeNode node) {
+Location? getLocationFromNode(TreeNode node) {
if (node.enclosingComponent == null) {
- TreeNode parent = node;
+ TreeNode? parent = node;
while (parent != null && parent is! Library) {
parent = parent.parent;
}
@@ -42,7 +40,7 @@
new Component(uriToSource: CompilerContext.current.uriToSource));
component.libraries.add(parent);
parent.parent = component;
- Location result = node.location;
+ Location? result = node.location;
component.libraries.clear();
parent.parent = null;
return result;
diff --git a/pkg/front_end/lib/src/fasta/modifier.dart b/pkg/front_end/lib/src/fasta/modifier.dart
index 32a6aa2..0a41ca0 100644
--- a/pkg/front_end/lib/src/fasta/modifier.dart
+++ b/pkg/front_end/lib/src/fasta/modifier.dart
@@ -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.9
-
library fasta.modifier;
import 'problems.dart' show unhandled;
@@ -92,7 +90,7 @@
toString() => "modifier(${'$kind'.substring('ModifierEnum.'.length)})";
- static int toMask(List<Modifier> modifiers) {
+ static int toMask(List<Modifier>? modifiers) {
int result = 0;
if (modifiers == null) return result;
for (Modifier modifier in modifiers) {
@@ -101,7 +99,7 @@
return result;
}
- static int validateVarFinalOrConst(String lexeme) {
+ static int validateVarFinalOrConst(String? lexeme) {
if (lexeme == null) return 0;
if (identical('const', lexeme)) return Const.mask;
if (identical('final', lexeme)) return Final.mask;
diff --git a/pkg/front_end/lib/src/fasta/problems.dart b/pkg/front_end/lib/src/fasta/problems.dart
index cd06b1f..00e16c9 100644
--- a/pkg/front_end/lib/src/fasta/problems.dart
+++ b/pkg/front_end/lib/src/fasta/problems.dart
@@ -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.9
-
library fasta.problems;
import 'package:_fe_analyzer_shared/src/messages/severity.dart'
@@ -27,10 +25,14 @@
class DebugAbort {
final LocatedMessage message;
- DebugAbort(Uri uri, int charOffset, Severity severity, StackTrace trace)
- : message = templateInternalProblemDebugAbort
- .withArguments(severityTexts[severity], "$trace")
- .withLocation(uri, charOffset, noLength);
+ DebugAbort(Uri? uri, int charOffset, Severity severity, StackTrace trace)
+ : message = uri != null
+ ? templateInternalProblemDebugAbort
+ .withArguments(severityTexts[severity]!, "$trace")
+ .withLocation(uri, charOffset, noLength)
+ : templateInternalProblemDebugAbort
+ .withArguments(severityTexts[severity]!, "$trace")
+ .withoutLocation();
toString() => "DebugAbort: ${message.message}";
}
@@ -44,45 +46,52 @@
/// ensure that there are no throws anywhere else in the codebase.
///
/// Before printing the message, the string `"Internal error: "` is prepended.
-dynamic internalProblem(Message message, int charOffset, Uri uri) {
- throw CompilerContext.current
- .format(message.withLocation(uri, charOffset, noLength),
- Severity.internalProblem)
- .plain;
+Never internalProblem(Message message, int charOffset, Uri? uri) {
+ if (uri != null) {
+ throw CompilerContext.current
+ .format(message.withLocation(uri, charOffset, noLength),
+ Severity.internalProblem)
+ .plain;
+ } else {
+ throw CompilerContext.current
+ .format(message.withoutLocation(), Severity.internalProblem)
+ .plain;
+ }
}
-dynamic unimplemented(String what, int charOffset, Uri uri) {
+Never unimplemented(String what, int charOffset, Uri? uri) {
return internalProblem(
templateInternalProblemUnimplemented.withArguments(what),
charOffset,
uri);
}
-dynamic unhandled(String what, String where, int charOffset, Uri uri) {
+Never unhandled(String what, String where, int charOffset, Uri? uri) {
return internalProblem(
templateInternalProblemUnhandled.withArguments(what, where),
charOffset,
uri);
}
-dynamic unexpected(String expected, String actual, int charOffset, Uri uri) {
+Never unexpected(String expected, String actual, int charOffset, Uri? uri) {
return internalProblem(
templateInternalProblemUnexpected.withArguments(expected, actual),
charOffset,
uri);
}
-dynamic unsupported(String operation, int charOffset, Uri uri) {
+Never unsupported(String operation, int charOffset, Uri? uri) {
return internalProblem(
templateInternalProblemUnsupported.withArguments(operation),
charOffset,
uri);
}
-Uri getFileUri(TreeNode node) {
+Uri? getFileUri(TreeNode node) {
+ TreeNode? parent = node;
do {
- if (node is FileUriNode) return node.fileUri;
- node = node.parent;
- } while (node is TreeNode);
+ if (parent is FileUriNode) return parent.fileUri;
+ parent = parent!.parent;
+ } while (parent is TreeNode);
return null;
}
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index 1f1cd12..3276b83 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -2723,7 +2723,6 @@
} else {
unhandled("${declaration.runtimeType}", "buildBuilder",
declaration.charOffset, declaration.fileUri);
- return;
}
}
diff --git a/pkg/front_end/lib/src/fasta/type_inference/inference_helper.dart b/pkg/front_end/lib/src/fasta/type_inference/inference_helper.dart
index 572feea..b6f3f9a 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/inference_helper.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/inference_helper.dart
@@ -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.9
-
import 'package:kernel/ast.dart';
import 'package:kernel/core_types.dart' show CoreTypes;
@@ -18,19 +16,19 @@
set transformSetLiterals(bool value);
Expression buildProblem(Message message, int charOffset, int length,
- {List<LocatedMessage> context, bool suppressMessage});
+ {List<LocatedMessage>? context, bool suppressMessage = false});
LocatedMessage checkArgumentsForType(
FunctionType function, Arguments arguments, int offset,
{bool isExtensionMemberInvocation = false});
void addProblem(Message message, int charOffset, int length,
- {List<LocatedMessage> context, bool wasHandled});
+ {List<LocatedMessage>? context, bool wasHandled = false});
Expression wrapInProblem(
Expression expression, Message message, int fileOffset, int length,
- {List<LocatedMessage> context});
+ {List<LocatedMessage>? context});
String constructorNameForDiagnostics(String name,
- {String className, bool isSuper});
+ {String? className, bool isSuper = false});
}
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index aa896d9..8111748 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -11,11 +11,7 @@
import 'package:_fe_analyzer_shared/src/testing/id.dart';
import 'package:_fe_analyzer_shared/src/util/link.dart';
-
-import 'package:front_end/src/fasta/kernel/internal_ast.dart';
-import 'package:front_end/src/fasta/type_inference/type_demotion.dart';
-import 'package:front_end/src/testing/id_extractor.dart';
-import 'package:front_end/src/testing/id_testing_utils.dart';
+import 'package:front_end/src/fasta/kernel/class_hierarchy_builder.dart';
import 'package:kernel/ast.dart';
import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
@@ -35,16 +31,19 @@
import '../../base/nnbd_mode.dart';
+import '../../testing/id_extractor.dart';
+import '../../testing/id_testing_utils.dart';
+
import '../builder/constructor_builder.dart';
import '../builder/extension_builder.dart';
import '../builder/member_builder.dart';
import '../fasta_codes.dart';
+import '../kernel/class_hierarchy_builder.dart' show ClassMember;
import '../kernel/inference_visitor.dart';
-
+import '../kernel/internal_ast.dart';
import '../kernel/invalid_type.dart';
-
import '../kernel/type_algorithms.dart' show hasAnyTypeVariables;
import '../names.dart';
@@ -54,15 +53,11 @@
import '../source/source_library_builder.dart' show SourceLibraryBuilder;
import 'inference_helper.dart' show InferenceHelper;
-
import 'type_constraint_gatherer.dart' show TypeConstraintGatherer;
-
+import 'type_demotion.dart';
import 'type_inference_engine.dart';
-
import 'type_schema.dart' show isKnown, UnknownType;
-
import 'type_schema_elimination.dart' show greatestClosure;
-
import 'type_schema_environment.dart'
show
getNamedParameterType,
@@ -4045,10 +4040,26 @@
Member _getInterfaceMember(
Class class_, Name name, bool setter, int charOffset) {
- Member member = engine.hierarchyBuilder.getCombinedMemberSignatureKernel(
- class_, name, setter, charOffset, library);
+ ClassMember classMember = engine.hierarchyBuilder
+ .getInterfaceClassMember(class_, name, setter: setter);
+ if (classMember != null) {
+ if (classMember.isStatic) {
+ classMember = null;
+ } else if (classMember.isDuplicate) {
+ if (!isTopLevel) {
+ library.addProblem(
+ templateDuplicatedDeclarationUse.withArguments(name.text),
+ charOffset,
+ name.text.length,
+ helper.uri);
+ }
+ classMember = null;
+ }
+ }
+ Member member = classMember?.getMember(engine.hierarchyBuilder);
if (member == null && library.isPatch) {
- // TODO(dmitryas): Hack for parts.
+ // TODO(johnniwinther): Injected members are currently not included
+ // in the class hierarchy builder.
member ??=
classHierarchy.getInterfaceMember(class_, name, setter: setter);
}
diff --git a/pkg/front_end/lib/src/fasta/uri_translator.dart b/pkg/front_end/lib/src/fasta/uri_translator.dart
index cf294d2..c6777ee 100644
--- a/pkg/front_end/lib/src/fasta/uri_translator.dart
+++ b/pkg/front_end/lib/src/fasta/uri_translator.dart
@@ -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.9
-
library fasta.uri_translator;
import 'package:package_config/package_config.dart';
@@ -19,7 +17,7 @@
UriTranslator(this.dartLibraries, this.packages);
- List<Uri> getDartPatches(String libraryName) =>
+ List<Uri>? getDartPatches(String libraryName) =>
dartLibraries.libraryInfoFor(libraryName)?.patches;
bool isPlatformImplementation(Uri uri) {
@@ -31,7 +29,7 @@
// TODO(sigmund, ahe): consider expanding this API to include an error
// callback, so we can provide an error location when one is available. For
// example, if the error occurs in an `import`.
- Uri translate(Uri uri, [bool reportMessage = true]) {
+ Uri? translate(Uri uri, [bool reportMessage = true]) {
if (uri.scheme == "dart") return _translateDartUri(uri);
if (uri.scheme == "package") {
return _translatePackageUri(uri, reportMessage);
@@ -40,7 +38,8 @@
}
/// For a package uri, get the corresponding [Package].
- Package getPackage(Uri uri) {
+ Package? getPackage(Uri uri) {
+ // ignore: unnecessary_null_comparison
if (packages == null) return null;
if (uri.scheme != "package") return null;
int firstSlash = uri.path.indexOf('/');
@@ -55,16 +54,16 @@
return dartLibraries.libraryInfoFor(libraryName)?.isSupported ?? true;
}
- Uri _translateDartUri(Uri uri) {
+ Uri? _translateDartUri(Uri uri) {
if (!uri.isScheme('dart')) return null;
return dartLibraries.libraryInfoFor(uri.path)?.uri;
}
- Uri _translatePackageUri(Uri uri, bool reportMessage) {
+ Uri? _translatePackageUri(Uri uri, bool reportMessage) {
try {
// TODO(sigmund): once we remove the `parse` API, we can ensure that
// packages will never be null and get rid of `?` below.
- Uri translated = packages?.resolve(uri);
+ Uri? translated = packages.resolve(uri);
if (translated == null) {
return (reportMessage
? _packageUriNotFound
@@ -82,7 +81,7 @@
}
}
- static Uri _packageUriNotFound(Uri uri) {
+ static Uri? _packageUriNotFound(Uri uri) {
String name = uri.pathSegments.first;
CompilerContext.current.reportWithoutLocation(
templatePackageNotFound.withArguments(name, uri), Severity.error);
@@ -92,7 +91,7 @@
return null;
}
- static Uri _packageUriNotFoundNoReport(Uri uri) {
+ static Uri? _packageUriNotFoundNoReport(Uri uri) {
return null;
}
}
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index 174bde3..e5d851a 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -2556,8 +2556,9 @@
AnnotationOnFunctionTypeTypeVariable:
template: "A type variable on a function type can't have annotations."
- script:
- - "main() { Function<@Object() T>() x; }"
+ script: |
+ // @dart=2.13
+ main() { Function<@Object() T>() x; }
ExpectedEnumBody:
template: "Expected a enum body, but got '#lexeme'."
@@ -2916,6 +2917,7 @@
# Use this message when a duplicated declaration is used.
DuplicatedDeclarationUse:
template: "Can't use '#name' because it is declared more than once."
+ exampleAllowMoreCodes: true
script:
- main.dart: |
// This test can't pass as tests must produce only one error message.
@@ -2935,6 +2937,18 @@
class C {}
lib2.dart: |
class C {}
+ - main.dart: |
+ class C {
+ method() {}
+ method() {}
+ }
+ main() => new C().method();
+ - main.dart: |
+ class C {
+ method() {}
+ method() {}
+ }
+ var f = new C().method();
DuplicatedNamePreviouslyUsed:
template: "Can't declare '#name' because it was already used in this scope."
@@ -3022,6 +3036,8 @@
template: "The type '#name' can't be used as supertype."
analyzerCode: EXTENDS_NON_CLASS
script: |
+
+
class C extends dynamic {}
SupertypeIsIllegalAliased:
@@ -4013,6 +4029,7 @@
template: "Type variables can't have generic function types in their bounds."
analyzerCode: GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND
script: |
+ // @dart=2.13
class Hest<X extends Y Function<Y>(Y)> {}
VoidExpression:
@@ -4305,13 +4322,15 @@
tip: "Try using a non-generic function type."
analyzerCode: GENERIC_FUNCTION_CANNOT_BE_TYPE_ARGUMENT
script:
- - >-
+ - |
+ // @dart=2.13
typedef F = Class<T> Function<T>(T);
class Class<T> {}
main() {
Class<F> class1;
}
- - >-
+ - |
+ // @dart=2.13
typedef F = Class<T> Function<T>(T);
class Class<T> {}
main() {
@@ -4322,7 +4341,8 @@
template: "Generic function type '#type' inferred as a type argument."
tip: "Try providing a non-generic function type explicitly."
analyzerCode: GENERIC_FUNCTION_CANNOT_BE_TYPE_ARGUMENT
- script:
+ script: |
+ // @dart=2.13
foo<X>(X x) => null;
bar<Y>(Y y) => null;
main() { foo(bar); }
diff --git a/pkg/front_end/test/static_types/cfe_allowed.json b/pkg/front_end/test/static_types/cfe_allowed.json
index ca079c1..13b0b3f 100644
--- a/pkg/front_end/test/static_types/cfe_allowed.json
+++ b/pkg/front_end/test/static_types/cfe_allowed.json
@@ -18,12 +18,6 @@
"Dynamic access of 'name'.": 2,
"Dynamic access of 'type'.": 1
},
- "pkg/front_end/lib/src/fasta/crash.dart": {
- "Dynamic access of 'trace'.": 1,
- "Dynamic access of 'uri'.": 1,
- "Dynamic access of 'charOffset'.": 1,
- "Dynamic access of 'error'.": 1
- },
"pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart": {
"Dynamic access of 'fileUri'.": 1
},
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list.dart b/pkg/front_end/testcases/const_functions/const_functions_list.dart
index 4d16542..ee6c222 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list.dart
+++ b/pkg/front_end/testcases/const_functions/const_functions_list.dart
@@ -93,6 +93,23 @@
return x.runtimeType;
}
+const getWithIndexVar = getWithIndexFn();
+int getWithIndexFn() {
+ const List<int> x = [1];
+ return x[0];
+}
+
+const rangeErrorCatchVar = rangeErrorCatchFn();
+int rangeErrorCatchFn() {
+ try {
+ const List<int> x = [1];
+ var v = x[1];
+ } on RangeError {
+ return 0;
+ }
+ return 1;
+}
+
void main() {
Expect.equals(firstVar, 1);
Expect.equals(firstCatchVar, 0);
@@ -105,4 +122,6 @@
Expect.equals(singleCatchVar, 0);
Expect.equals(singleCatchVar2, 0);
Expect.equals(typeVar, int);
+ Expect.equals(getWithIndexVar, 1);
+ Expect.equals(rangeErrorCatchVar, 0);
}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list.dart.strong.expect b/pkg/front_end/testcases/const_functions/const_functions_list.dart.strong.expect
index b978859..3a26c41 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list.dart.strong.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list.dart.strong.expect
@@ -17,6 +17,8 @@
static const field core::int singleCatchVar2 = #C2;
static const field core::Type typeExample = #C6;
static const field core::Type typeVar = #C6;
+static const field core::int getWithIndexVar = #C1;
+static const field core::int rangeErrorCatchVar = #C2;
static method firstFn() → core::int {
return (#C7).{core::Iterable::first};
}
@@ -74,6 +76,18 @@
static method typeFn() → core::Type {
return (#C7).{core::Object::runtimeType};
}
+static method getWithIndexFn() → core::int {
+ return (#C9).{core::List::[]}(0);
+}
+static method rangeErrorCatchFn() → core::int {
+ try {
+ core::int v = (#C9).{core::List::[]}(1);
+ }
+ on core::RangeError catch(no-exception-var) {
+ return 0;
+ }
+ return 1;
+}
static method main() → void {
exp::Expect::equals(#C1, 1);
exp::Expect::equals(#C2, 0);
@@ -86,6 +100,8 @@
exp::Expect::equals(#C2, 0);
exp::Expect::equals(#C2, 0);
exp::Expect::equals(#C6, #C6);
+ exp::Expect::equals(#C1, 1);
+ exp::Expect::equals(#C2, 0);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list.dart.strong.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_list.dart.strong.transformed.expect
index b978859..3a26c41 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list.dart.strong.transformed.expect
@@ -17,6 +17,8 @@
static const field core::int singleCatchVar2 = #C2;
static const field core::Type typeExample = #C6;
static const field core::Type typeVar = #C6;
+static const field core::int getWithIndexVar = #C1;
+static const field core::int rangeErrorCatchVar = #C2;
static method firstFn() → core::int {
return (#C7).{core::Iterable::first};
}
@@ -74,6 +76,18 @@
static method typeFn() → core::Type {
return (#C7).{core::Object::runtimeType};
}
+static method getWithIndexFn() → core::int {
+ return (#C9).{core::List::[]}(0);
+}
+static method rangeErrorCatchFn() → core::int {
+ try {
+ core::int v = (#C9).{core::List::[]}(1);
+ }
+ on core::RangeError catch(no-exception-var) {
+ return 0;
+ }
+ return 1;
+}
static method main() → void {
exp::Expect::equals(#C1, 1);
exp::Expect::equals(#C2, 0);
@@ -86,6 +100,8 @@
exp::Expect::equals(#C2, 0);
exp::Expect::equals(#C2, 0);
exp::Expect::equals(#C6, #C6);
+ exp::Expect::equals(#C1, 1);
+ exp::Expect::equals(#C2, 0);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list.dart.textual_outline.expect b/pkg/front_end/testcases/const_functions/const_functions_list.dart.textual_outline.expect
index 91be3d9..0e77dc5 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list.dart.textual_outline.expect
@@ -23,4 +23,8 @@
const typeExample = int;
const typeVar = typeFn();
Type typeFn() {}
+const getWithIndexVar = getWithIndexFn();
+int getWithIndexFn() {}
+const rangeErrorCatchVar = rangeErrorCatchFn();
+int rangeErrorCatchFn() {}
void main() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/const_functions/const_functions_list.dart.textual_outline_modelled.expect
index a297feb..d57d3a1 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list.dart.textual_outline_modelled.expect
@@ -5,11 +5,13 @@
bool isNotEmptyFn() {}
const firstCatchVar = firstCatchFn();
const firstVar = firstFn();
+const getWithIndexVar = getWithIndexFn();
const isEmptyVar = isEmptyFn();
const isNotEmptyVar = isNotEmptyFn();
const lastCatchVar = lastCatchFn();
const lastVar = lastFn();
const lengthVar = lengthFn();
+const rangeErrorCatchVar = rangeErrorCatchFn();
const singleCatchVar = singleCatchFn();
const singleCatchVar2 = singleCatchFn2();
const singleVar = singleFn();
@@ -17,9 +19,11 @@
const typeVar = typeFn();
int firstCatchFn() {}
int firstFn() {}
+int getWithIndexFn() {}
int lastCatchFn() {}
int lastFn() {}
int lengthFn() {}
+int rangeErrorCatchFn() {}
int singleCatchFn() {}
int singleCatchFn2() {}
int singleFn() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.expect b/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.expect
index e5b0a71..e3fdeb2 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.expect
@@ -17,6 +17,8 @@
static const field core::int singleCatchVar2 = #C2;
static const field core::Type typeExample = #C6;
static const field core::Type typeVar = #C6;
+static const field core::int getWithIndexVar = #C1;
+static const field core::int rangeErrorCatchVar = #C2;
static method firstFn() → core::int {
return (#C7).{core::Iterable::first};
}
@@ -74,6 +76,18 @@
static method typeFn() → core::Type {
return (#C7).{core::Object::runtimeType};
}
+static method getWithIndexFn() → core::int {
+ return (#C9).{core::List::[]}(0);
+}
+static method rangeErrorCatchFn() → core::int {
+ try {
+ core::int v = (#C9).{core::List::[]}(1);
+ }
+ on core::RangeError catch(no-exception-var) {
+ return 0;
+ }
+ return 1;
+}
static method main() → void {
exp::Expect::equals(#C1, 1);
exp::Expect::equals(#C2, 0);
@@ -86,6 +100,8 @@
exp::Expect::equals(#C2, 0);
exp::Expect::equals(#C2, 0);
exp::Expect::equals(#C6, #C6);
+ exp::Expect::equals(#C1, 1);
+ exp::Expect::equals(#C2, 0);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.outline.expect b/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.outline.expect
index dcd0734..70812a7 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.outline.expect
@@ -16,6 +16,8 @@
static const field core::int singleCatchVar2 = self::singleCatchFn2();
static const field core::Type typeExample = core::int;
static const field core::Type typeVar = self::typeFn();
+static const field core::int getWithIndexVar = self::getWithIndexFn();
+static const field core::int rangeErrorCatchVar = self::rangeErrorCatchFn();
static method firstFn() → core::int
;
static method firstCatchFn() → core::int
@@ -38,10 +40,14 @@
;
static method typeFn() → core::Type
;
+static method getWithIndexFn() → core::int
+ ;
+static method rangeErrorCatchFn() → core::int
+ ;
static method main() → void
;
Extra constant evaluation status:
Evaluated: TypeLiteral @ org-dartlang-testcase:///const_functions_list.dart:89:21 -> TypeLiteralConstant(int*)
-Extra constant evaluation: evaluated: 12, effectively constant: 1
+Extra constant evaluation: evaluated: 14, effectively constant: 1
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.transformed.expect
index e5b0a71..e3fdeb2 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list.dart.weak.transformed.expect
@@ -17,6 +17,8 @@
static const field core::int singleCatchVar2 = #C2;
static const field core::Type typeExample = #C6;
static const field core::Type typeVar = #C6;
+static const field core::int getWithIndexVar = #C1;
+static const field core::int rangeErrorCatchVar = #C2;
static method firstFn() → core::int {
return (#C7).{core::Iterable::first};
}
@@ -74,6 +76,18 @@
static method typeFn() → core::Type {
return (#C7).{core::Object::runtimeType};
}
+static method getWithIndexFn() → core::int {
+ return (#C9).{core::List::[]}(0);
+}
+static method rangeErrorCatchFn() → core::int {
+ try {
+ core::int v = (#C9).{core::List::[]}(1);
+ }
+ on core::RangeError catch(no-exception-var) {
+ return 0;
+ }
+ return 1;
+}
static method main() → void {
exp::Expect::equals(#C1, 1);
exp::Expect::equals(#C2, 0);
@@ -86,6 +100,8 @@
exp::Expect::equals(#C2, 0);
exp::Expect::equals(#C2, 0);
exp::Expect::equals(#C6, #C6);
+ exp::Expect::equals(#C1, 1);
+ exp::Expect::equals(#C2, 0);
}
constants {
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart
index b2e29ac..7112539 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart
+++ b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart
@@ -36,4 +36,22 @@
return x.invalidProperty;
}
+const getWithIndexException = getWithIndexExceptionFn();
+int getWithIndexExceptionFn() {
+ const List<int> x = [1];
+ return x[1];
+}
+
+const getWithIndexException2 = getWithIndexExceptionFn2();
+int getWithIndexExceptionFn2() {
+ const List<int> x = [1];
+ return x[-1];
+}
+
+const getWithIndexException3 = getWithIndexExceptionFn3();
+int getWithIndexExceptionFn3() {
+ const List<int> x = [1];
+ return x[0.1];
+}
+
void main() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.strong.expect b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.strong.expect
index 8f1cc49..c0f7a01 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.strong.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.strong.expect
@@ -8,6 +8,10 @@
// return x.invalidProperty;
// ^^^^^^^^^^^^^^^
//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+// return x[0.1];
+// ^
+//
// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:9:24: Error: Constant evaluation error:
// const firstException = firstExceptionFn();
// ^
@@ -36,6 +40,20 @@
// return x.single;
// ^
//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:39:31: Error: Constant evaluation error:
+// const getWithIndexException = getWithIndexExceptionFn();
+// ^
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:42:11: Context: Unhandled core exception: RangeError: Index out of range: index should be less than 1: 1
+// return x[1];
+// ^
+//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:45:32: Error: Constant evaluation error:
+// const getWithIndexException2 = getWithIndexExceptionFn2();
+// ^
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:48:11: Context: Unhandled core exception: RangeError: Index out of range: index must not be negative: -1
+// return x[-1];
+// ^
+//
import self as self;
import "dart:core" as core;
@@ -50,6 +68,11 @@
Try correcting the name to the name of an existing getter, or defining a getter or field named 'invalidProperty'.
return x.invalidProperty;
^^^^^^^^^^^^^^^";
+static const field core::int getWithIndexException = invalid-expression "Unhandled core exception: RangeError: Index out of range: index should be less than 1: 1";
+static const field core::int getWithIndexException2 = invalid-expression "Unhandled core exception: RangeError: Index out of range: index must not be negative: -1";
+static const field core::int getWithIndexException3 = invalid-expression "pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+ return x[0.1];
+ ^";
static method firstExceptionFn() → core::int {
return (#C1).{core::Iterable::first};
}
@@ -69,6 +92,17 @@
return x.invalidProperty;
^^^^^^^^^^^^^^^" as{TypeError,ForDynamic,ForNonNullableByDefault} core::int;
}
+static method getWithIndexExceptionFn() → core::int {
+ return (#C5).{core::List::[]}(1);
+}
+static method getWithIndexExceptionFn2() → core::int {
+ return (#C5).{core::List::[]}(1.{core::int::unary-}());
+}
+static method getWithIndexExceptionFn3() → core::int {
+ return (#C5).{core::List::[]}(let final Never #t1 = invalid-expression "pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+ return x[0.1];
+ ^" in 0.1 as{TypeError,ForNonNullableByDefault} core::int);
+}
static method main() → void {}
constants {
@@ -76,4 +110,5 @@
#C2 = 1
#C3 = 2
#C4 = <core::int>[#C2, #C3]
+ #C5 = <core::int>[#C2]
}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.strong.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.strong.transformed.expect
index 8ec1037..e279288 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.strong.transformed.expect
@@ -8,6 +8,10 @@
// return x.invalidProperty;
// ^^^^^^^^^^^^^^^
//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+// return x[0.1];
+// ^
+//
// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:9:24: Error: Constant evaluation error:
// const firstException = firstExceptionFn();
// ^
@@ -36,6 +40,20 @@
// return x.single;
// ^
//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:39:31: Error: Constant evaluation error:
+// const getWithIndexException = getWithIndexExceptionFn();
+// ^
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:42:11: Context: Unhandled core exception: RangeError: Index out of range: index should be less than 1: 1
+// return x[1];
+// ^
+//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:45:32: Error: Constant evaluation error:
+// const getWithIndexException2 = getWithIndexExceptionFn2();
+// ^
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:48:11: Context: Unhandled core exception: RangeError: Index out of range: index must not be negative: -1
+// return x[-1];
+// ^
+//
import self as self;
import "dart:core" as core;
@@ -50,6 +68,11 @@
Try correcting the name to the name of an existing getter, or defining a getter or field named 'invalidProperty'.
return x.invalidProperty;
^^^^^^^^^^^^^^^";
+static const field core::int getWithIndexException = invalid-expression "Unhandled core exception: RangeError: Index out of range: index should be less than 1: 1";
+static const field core::int getWithIndexException2 = invalid-expression "Unhandled core exception: RangeError: Index out of range: index must not be negative: -1";
+static const field core::int getWithIndexException3 = invalid-expression "pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+ return x[0.1];
+ ^";
static method firstExceptionFn() → core::int {
return (#C1).{core::Iterable::first};
}
@@ -69,6 +92,17 @@
return x.invalidProperty;
^^^^^^^^^^^^^^^";
}
+static method getWithIndexExceptionFn() → core::int {
+ return (#C5).{core::List::[]}(1);
+}
+static method getWithIndexExceptionFn2() → core::int {
+ return (#C5).{core::List::[]}(1.{core::int::unary-}());
+}
+static method getWithIndexExceptionFn3() → core::int {
+ return (#C5).{core::List::[]}(let final Never #t1 = invalid-expression "pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+ return x[0.1];
+ ^" in 0.1 as{TypeError,ForNonNullableByDefault} core::int);
+}
static method main() → void {}
constants {
@@ -76,4 +110,9 @@
#C2 = 1
#C3 = 2
#C4 = <core::int>[#C2, #C3]
+ #C5 = <core::int>[#C2]
}
+
+Extra constant evaluation status:
+Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_list_error.dart:48:12 -> IntConstant(-1)
+Extra constant evaluation: evaluated: 10, effectively constant: 1
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.textual_outline.expect b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.textual_outline.expect
index 4697c853..0305a22 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.textual_outline.expect
@@ -10,4 +10,10 @@
int singleExceptionMultiFn() {}
const invalidProperty = invalidPropertyFn();
int invalidPropertyFn() {}
+const getWithIndexException = getWithIndexExceptionFn();
+int getWithIndexExceptionFn() {}
+const getWithIndexException2 = getWithIndexExceptionFn2();
+int getWithIndexExceptionFn2() {}
+const getWithIndexException3 = getWithIndexExceptionFn3();
+int getWithIndexExceptionFn3() {}
void main() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.textual_outline_modelled.expect
index c41226a..6ad769d 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.textual_outline_modelled.expect
@@ -1,11 +1,17 @@
import "package:expect/expect.dart";
const firstException = firstExceptionFn();
+const getWithIndexException = getWithIndexExceptionFn();
+const getWithIndexException2 = getWithIndexExceptionFn2();
+const getWithIndexException3 = getWithIndexExceptionFn3();
const invalidProperty = invalidPropertyFn();
const lastException = lastExceptionFn();
const singleException = singleExceptionFn();
const singleExceptionMulti = singleExceptionMultiFn();
int firstExceptionFn() {}
+int getWithIndexExceptionFn() {}
+int getWithIndexExceptionFn2() {}
+int getWithIndexExceptionFn3() {}
int invalidPropertyFn() {}
int lastExceptionFn() {}
int singleExceptionFn() {}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.expect b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.expect
index 6d2f2a4..f063521 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.expect
@@ -8,6 +8,10 @@
// return x.invalidProperty;
// ^^^^^^^^^^^^^^^
//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+// return x[0.1];
+// ^
+//
// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:9:24: Error: Constant evaluation error:
// const firstException = firstExceptionFn();
// ^
@@ -36,6 +40,20 @@
// return x.single;
// ^
//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:39:31: Error: Constant evaluation error:
+// const getWithIndexException = getWithIndexExceptionFn();
+// ^
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:42:11: Context: Unhandled core exception: RangeError: Index out of range: index should be less than 1: 1
+// return x[1];
+// ^
+//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:45:32: Error: Constant evaluation error:
+// const getWithIndexException2 = getWithIndexExceptionFn2();
+// ^
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:48:11: Context: Unhandled core exception: RangeError: Index out of range: index must not be negative: -1
+// return x[-1];
+// ^
+//
import self as self;
import "dart:core" as core;
@@ -50,6 +68,11 @@
Try correcting the name to the name of an existing getter, or defining a getter or field named 'invalidProperty'.
return x.invalidProperty;
^^^^^^^^^^^^^^^";
+static const field core::int getWithIndexException = invalid-expression "Unhandled core exception: RangeError: Index out of range: index should be less than 1: 1";
+static const field core::int getWithIndexException2 = invalid-expression "Unhandled core exception: RangeError: Index out of range: index must not be negative: -1";
+static const field core::int getWithIndexException3 = invalid-expression "pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+ return x[0.1];
+ ^";
static method firstExceptionFn() → core::int {
return (#C1).{core::Iterable::first};
}
@@ -69,6 +92,17 @@
return x.invalidProperty;
^^^^^^^^^^^^^^^" as{TypeError,ForDynamic,ForNonNullableByDefault} core::int;
}
+static method getWithIndexExceptionFn() → core::int {
+ return (#C5).{core::List::[]}(1);
+}
+static method getWithIndexExceptionFn2() → core::int {
+ return (#C5).{core::List::[]}(1.{core::int::unary-}());
+}
+static method getWithIndexExceptionFn3() → core::int {
+ return (#C5).{core::List::[]}(let final Never #t1 = invalid-expression "pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+ return x[0.1];
+ ^" in 0.1 as{TypeError,ForNonNullableByDefault} core::int);
+}
static method main() → void {}
constants {
@@ -76,4 +110,5 @@
#C2 = 1
#C3 = 2
#C4 = <core::int*>[#C2, #C3]
+ #C5 = <core::int*>[#C2]
}
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.outline.expect b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.outline.expect
index 49a82fb..85d4fbd 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.outline.expect
@@ -9,6 +9,9 @@
static const field core::int singleException = self::singleExceptionFn();
static const field core::int singleExceptionMulti = self::singleExceptionMultiFn();
static const field core::int invalidProperty = self::invalidPropertyFn();
+static const field core::int getWithIndexException = self::getWithIndexExceptionFn();
+static const field core::int getWithIndexException2 = self::getWithIndexExceptionFn2();
+static const field core::int getWithIndexException3 = self::getWithIndexExceptionFn3();
static method firstExceptionFn() → core::int
;
static method lastExceptionFn() → core::int
@@ -19,5 +22,11 @@
;
static method invalidPropertyFn() → core::int
;
+static method getWithIndexExceptionFn() → core::int
+ ;
+static method getWithIndexExceptionFn2() → core::int
+ ;
+static method getWithIndexExceptionFn3() → core::int
+ ;
static method main() → void
;
diff --git a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.transformed.expect b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.transformed.expect
index 54d1e2b..83813a5 100644
--- a/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/const_functions/const_functions_list_error.dart.weak.transformed.expect
@@ -8,6 +8,10 @@
// return x.invalidProperty;
// ^^^^^^^^^^^^^^^
//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+// return x[0.1];
+// ^
+//
// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:9:24: Error: Constant evaluation error:
// const firstException = firstExceptionFn();
// ^
@@ -36,6 +40,20 @@
// return x.single;
// ^
//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:39:31: Error: Constant evaluation error:
+// const getWithIndexException = getWithIndexExceptionFn();
+// ^
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:42:11: Context: Unhandled core exception: RangeError: Index out of range: index should be less than 1: 1
+// return x[1];
+// ^
+//
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:45:32: Error: Constant evaluation error:
+// const getWithIndexException2 = getWithIndexExceptionFn2();
+// ^
+// pkg/front_end/testcases/const_functions/const_functions_list_error.dart:48:11: Context: Unhandled core exception: RangeError: Index out of range: index must not be negative: -1
+// return x[-1];
+// ^
+//
import self as self;
import "dart:core" as core;
@@ -50,6 +68,11 @@
Try correcting the name to the name of an existing getter, or defining a getter or field named 'invalidProperty'.
return x.invalidProperty;
^^^^^^^^^^^^^^^";
+static const field core::int getWithIndexException = invalid-expression "Unhandled core exception: RangeError: Index out of range: index should be less than 1: 1";
+static const field core::int getWithIndexException2 = invalid-expression "Unhandled core exception: RangeError: Index out of range: index must not be negative: -1";
+static const field core::int getWithIndexException3 = invalid-expression "pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+ return x[0.1];
+ ^";
static method firstExceptionFn() → core::int {
return (#C1).{core::Iterable::first};
}
@@ -69,6 +92,17 @@
return x.invalidProperty;
^^^^^^^^^^^^^^^";
}
+static method getWithIndexExceptionFn() → core::int {
+ return (#C5).{core::List::[]}(1);
+}
+static method getWithIndexExceptionFn2() → core::int {
+ return (#C5).{core::List::[]}(1.{core::int::unary-}());
+}
+static method getWithIndexExceptionFn3() → core::int {
+ return (#C5).{core::List::[]}(let final Never #t1 = invalid-expression "pkg/front_end/testcases/const_functions/const_functions_list_error.dart:54:12: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
+ return x[0.1];
+ ^" in 0.1 as{TypeError,ForNonNullableByDefault} core::int);
+}
static method main() → void {}
constants {
@@ -76,4 +110,9 @@
#C2 = 1
#C3 = 2
#C4 = <core::int*>[#C2, #C3]
+ #C5 = <core::int*>[#C2]
}
+
+Extra constant evaluation status:
+Evaluated: MethodInvocation @ org-dartlang-testcase:///const_functions_list_error.dart:48:12 -> IntConstant(-1)
+Extra constant evaluation: evaluated: 10, effectively constant: 1
diff --git a/pkg/front_end/testcases/general/function_type_parameter.dart b/pkg/front_end/testcases/general/function_type_parameter.dart
index a9cb3ee..4e2e409 100644
--- a/pkg/front_end/testcases/general/function_type_parameter.dart
+++ b/pkg/front_end/testcases/general/function_type_parameter.dart
@@ -2,6 +2,8 @@
// 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.13
+
class A {
const A();
}
diff --git a/pkg/front_end/testcases/general/function_type_parameter.dart.textual_outline.expect b/pkg/front_end/testcases/general/function_type_parameter.dart.textual_outline.expect
index 31291f6..9af2a2f 100644
--- a/pkg/front_end/testcases/general/function_type_parameter.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/general/function_type_parameter.dart.textual_outline.expect
@@ -1,3 +1,4 @@
+// @dart = 2.13
class A {
const A();
}
diff --git a/pkg/front_end/testcases/general/function_type_parameter.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/function_type_parameter.dart.textual_outline_modelled.expect
index e028d49..7c7763b3 100644
--- a/pkg/front_end/testcases/general/function_type_parameter.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/general/function_type_parameter.dart.textual_outline_modelled.expect
@@ -1,3 +1,4 @@
+// @dart = 2.13
class A {
const A();
}
diff --git a/pkg/front_end/testcases/general/function_type_parameter.dart.weak.expect b/pkg/front_end/testcases/general/function_type_parameter.dart.weak.expect
index 35519c9..9c2602d 100644
--- a/pkg/front_end/testcases/general/function_type_parameter.dart.weak.expect
+++ b/pkg/front_end/testcases/general/function_type_parameter.dart.weak.expect
@@ -2,27 +2,27 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:9:20: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:11:20: Error: A type variable on a function type can't have annotations.
// void Function<@A() T>(T)? f;
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:11:32: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:13:32: Error: A type variable on a function type can't have annotations.
// typedef F = void Function<@A() T>(T);
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:17:33: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:19:33: Error: A type variable on a function type can't have annotations.
// void method2(void Function<@A() T>(T) f) {}
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:19:42: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:21:42: Error: A type variable on a function type can't have annotations.
// class Class<T extends void Function<@A() S>(S)> {}
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:19:13: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/general/function_type_parameter.dart:21:13: Error: Type variables can't have generic function types in their bounds.
// class Class<T extends void Function<@A() S>(S)> {}
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:24:22: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:26:22: Error: A type variable on a function type can't have annotations.
// void Function<@A() T>(T)? f;
// ^
//
@@ -56,5 +56,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///function_type_parameter.dart:
-- A. (from org-dartlang-testcase:///function_type_parameter.dart:6:9)
+- A. (from org-dartlang-testcase:///function_type_parameter.dart:8:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/general/function_type_parameter.dart.weak.outline.expect b/pkg/front_end/testcases/general/function_type_parameter.dart.weak.outline.expect
index 0ce97a7..962cf4d 100644
--- a/pkg/front_end/testcases/general/function_type_parameter.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/function_type_parameter.dart.weak.outline.expect
@@ -2,23 +2,23 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:9:20: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:11:20: Error: A type variable on a function type can't have annotations.
// void Function<@A() T>(T)? f;
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:11:32: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:13:32: Error: A type variable on a function type can't have annotations.
// typedef F = void Function<@A() T>(T);
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:17:33: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:19:33: Error: A type variable on a function type can't have annotations.
// void method2(void Function<@A() T>(T) f) {}
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:19:42: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:21:42: Error: A type variable on a function type can't have annotations.
// class Class<T extends void Function<@A() S>(S)> {}
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:19:13: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/general/function_type_parameter.dart:21:13: Error: Type variables can't have generic function types in their bounds.
// class Class<T extends void Function<@A() S>(S)> {}
// ^
//
@@ -46,6 +46,6 @@
Extra constant evaluation status:
-Evaluated: ConstructorInvocation @ org-dartlang-testcase:///function_type_parameter.dart:13:17 -> InstanceConstant(const A{})
-Evaluated: ConstructorInvocation @ org-dartlang-testcase:///function_type_parameter.dart:15:15 -> InstanceConstant(const A{})
+Evaluated: ConstructorInvocation @ org-dartlang-testcase:///function_type_parameter.dart:15:17 -> InstanceConstant(const A{})
+Evaluated: ConstructorInvocation @ org-dartlang-testcase:///function_type_parameter.dart:17:15 -> InstanceConstant(const A{})
Extra constant evaluation: evaluated: 2, effectively constant: 2
diff --git a/pkg/front_end/testcases/general/function_type_parameter.dart.weak.transformed.expect b/pkg/front_end/testcases/general/function_type_parameter.dart.weak.transformed.expect
index 35519c9..9c2602d 100644
--- a/pkg/front_end/testcases/general/function_type_parameter.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/function_type_parameter.dart.weak.transformed.expect
@@ -2,27 +2,27 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:9:20: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:11:20: Error: A type variable on a function type can't have annotations.
// void Function<@A() T>(T)? f;
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:11:32: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:13:32: Error: A type variable on a function type can't have annotations.
// typedef F = void Function<@A() T>(T);
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:17:33: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:19:33: Error: A type variable on a function type can't have annotations.
// void method2(void Function<@A() T>(T) f) {}
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:19:42: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:21:42: Error: A type variable on a function type can't have annotations.
// class Class<T extends void Function<@A() S>(S)> {}
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:19:13: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/general/function_type_parameter.dart:21:13: Error: Type variables can't have generic function types in their bounds.
// class Class<T extends void Function<@A() S>(S)> {}
// ^
//
-// pkg/front_end/testcases/general/function_type_parameter.dart:24:22: Error: A type variable on a function type can't have annotations.
+// pkg/front_end/testcases/general/function_type_parameter.dart:26:22: Error: A type variable on a function type can't have annotations.
// void Function<@A() T>(T)? f;
// ^
//
@@ -56,5 +56,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///function_type_parameter.dart:
-- A. (from org-dartlang-testcase:///function_type_parameter.dart:6:9)
+- A. (from org-dartlang-testcase:///function_type_parameter.dart:8:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/general/issue45330.dart b/pkg/front_end/testcases/general/issue45330.dart
index 95ebfd0..9abd261 100644
--- a/pkg/front_end/testcases/general/issue45330.dart
+++ b/pkg/front_end/testcases/general/issue45330.dart
@@ -2,6 +2,8 @@
// 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.13
+
part 'issue45330_lib.dart';
void genericMethod<T>() {}
diff --git a/pkg/front_end/testcases/general/issue45330.dart.textual_outline.expect b/pkg/front_end/testcases/general/issue45330.dart.textual_outline.expect
index 23719be..163c7be 100644
--- a/pkg/front_end/testcases/general/issue45330.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/general/issue45330.dart.textual_outline.expect
@@ -1,3 +1,4 @@
+// @dart = 2.13
part 'issue45330_lib.dart';
void genericMethod<T>() {}
diff --git a/pkg/front_end/testcases/general/issue45330.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/issue45330.dart.textual_outline_modelled.expect
index eb6bf12..d75e4ed 100644
--- a/pkg/front_end/testcases/general/issue45330.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/general/issue45330.dart.textual_outline_modelled.expect
@@ -1,3 +1,4 @@
+// @dart = 2.13
part 'issue45330_lib.dart';
main() {}
diff --git a/pkg/front_end/testcases/general/issue45330.dart.weak.expect b/pkg/front_end/testcases/general/issue45330.dart.weak.expect
index 22c456a..56fe32f 100644
--- a/pkg/front_end/testcases/general/issue45330.dart.weak.expect
+++ b/pkg/front_end/testcases/general/issue45330.dart.weak.expect
@@ -2,22 +2,22 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/issue45330.dart:10:31: Error: Type 'T' is a bound of itself via 'T'.
+// pkg/front_end/testcases/general/issue45330.dart:12:31: Error: Type 'T' is a bound of itself via 'T'.
// Try breaking the cycle by removing at least on of the 'extends' clauses in the cycle.
// genericMethod<void Function<T extends T>()>();
// ^
//
-// pkg/front_end/testcases/general/issue45330.dart:10:3: Error: A generic function type can't be used as a type argument.
+// pkg/front_end/testcases/general/issue45330.dart:12:3: Error: A generic function type can't be used as a type argument.
// Try using a non-generic function type.
// genericMethod<void Function<T extends T>()>();
// ^
//
-// pkg/front_end/testcases/general/issue45330_lib.dart:35:31: Error: Type 'T' is a bound of itself via 'T'.
+// pkg/front_end/testcases/general/issue45330_lib.dart:37:31: Error: Type 'T' is a bound of itself via 'T'.
// Try breaking the cycle by removing at least on of the 'extends' clauses in the cycle.
// genericMethod<void Function<T extends T>()>();
// ^
//
-// pkg/front_end/testcases/general/issue45330_lib.dart:35:3: Error: A generic function type can't be used as a type argument.
+// pkg/front_end/testcases/general/issue45330_lib.dart:37:3: Error: A generic function type can't be used as a type argument.
// Try using a non-generic function type.
// genericMethod<void Function<T extends T>()>();
// ^
diff --git a/pkg/front_end/testcases/general/issue45330.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue45330.dart.weak.transformed.expect
index 22c456a..56fe32f 100644
--- a/pkg/front_end/testcases/general/issue45330.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/issue45330.dart.weak.transformed.expect
@@ -2,22 +2,22 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/issue45330.dart:10:31: Error: Type 'T' is a bound of itself via 'T'.
+// pkg/front_end/testcases/general/issue45330.dart:12:31: Error: Type 'T' is a bound of itself via 'T'.
// Try breaking the cycle by removing at least on of the 'extends' clauses in the cycle.
// genericMethod<void Function<T extends T>()>();
// ^
//
-// pkg/front_end/testcases/general/issue45330.dart:10:3: Error: A generic function type can't be used as a type argument.
+// pkg/front_end/testcases/general/issue45330.dart:12:3: Error: A generic function type can't be used as a type argument.
// Try using a non-generic function type.
// genericMethod<void Function<T extends T>()>();
// ^
//
-// pkg/front_end/testcases/general/issue45330_lib.dart:35:31: Error: Type 'T' is a bound of itself via 'T'.
+// pkg/front_end/testcases/general/issue45330_lib.dart:37:31: Error: Type 'T' is a bound of itself via 'T'.
// Try breaking the cycle by removing at least on of the 'extends' clauses in the cycle.
// genericMethod<void Function<T extends T>()>();
// ^
//
-// pkg/front_end/testcases/general/issue45330_lib.dart:35:3: Error: A generic function type can't be used as a type argument.
+// pkg/front_end/testcases/general/issue45330_lib.dart:37:3: Error: A generic function type can't be used as a type argument.
// Try using a non-generic function type.
// genericMethod<void Function<T extends T>()>();
// ^
diff --git a/pkg/front_end/testcases/general/issue45330_lib.dart b/pkg/front_end/testcases/general/issue45330_lib.dart
index 1772937..93b958b 100644
--- a/pkg/front_end/testcases/general/issue45330_lib.dart
+++ b/pkg/front_end/testcases/general/issue45330_lib.dart
@@ -2,6 +2,8 @@
// 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.13
+
// Long comment to increase error offset.
// Long comment to increase error offset.
// Long comment to increase error offset.
diff --git a/pkg/front_end/testcases/nnbd/issue34803.dart b/pkg/front_end/testcases/nnbd/issue34803.dart
index ec6eda3..0069fc6d 100644
--- a/pkg/front_end/testcases/nnbd/issue34803.dart
+++ b/pkg/front_end/testcases/nnbd/issue34803.dart
@@ -2,6 +2,8 @@
// 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.13
+
class A<X extends G<num>> {}
typedef G<X> = void Function<Y extends X>();
diff --git a/pkg/front_end/testcases/nnbd/issue34803.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue34803.dart.strong.expect
index 7cf7baa..fc4163c 100644
--- a/pkg/front_end/testcases/nnbd/issue34803.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/issue34803.dart.strong.expect
@@ -2,7 +2,7 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd/issue34803.dart:5:9: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/nnbd/issue34803.dart:7:9: Error: Type variables can't have generic function types in their bounds.
// class A<X extends G<num>> {}
// ^
//
diff --git a/pkg/front_end/testcases/nnbd/issue34803.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/issue34803.dart.strong.transformed.expect
index 7cf7baa..fc4163c 100644
--- a/pkg/front_end/testcases/nnbd/issue34803.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/issue34803.dart.strong.transformed.expect
@@ -2,7 +2,7 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd/issue34803.dart:5:9: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/nnbd/issue34803.dart:7:9: Error: Type variables can't have generic function types in their bounds.
// class A<X extends G<num>> {}
// ^
//
diff --git a/pkg/front_end/testcases/nnbd/issue34803.dart.textual_outline.expect b/pkg/front_end/testcases/nnbd/issue34803.dart.textual_outline.expect
index 3d362ac..987cefd 100644
--- a/pkg/front_end/testcases/nnbd/issue34803.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/nnbd/issue34803.dart.textual_outline.expect
@@ -1,3 +1,4 @@
+// @dart = 2.13
class A<X extends G<num>> {}
typedef G<X> = void Function<Y extends X>();
diff --git a/pkg/front_end/testcases/nnbd/issue34803.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/nnbd/issue34803.dart.textual_outline_modelled.expect
index 92dc404..ff10684 100644
--- a/pkg/front_end/testcases/nnbd/issue34803.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/nnbd/issue34803.dart.textual_outline_modelled.expect
@@ -1,3 +1,4 @@
+// @dart = 2.13
class A<X extends G<num>> {}
main() {}
diff --git a/pkg/front_end/testcases/nnbd/issue34803.dart.weak.expect b/pkg/front_end/testcases/nnbd/issue34803.dart.weak.expect
index 7cf7baa..fc4163c 100644
--- a/pkg/front_end/testcases/nnbd/issue34803.dart.weak.expect
+++ b/pkg/front_end/testcases/nnbd/issue34803.dart.weak.expect
@@ -2,7 +2,7 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd/issue34803.dart:5:9: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/nnbd/issue34803.dart:7:9: Error: Type variables can't have generic function types in their bounds.
// class A<X extends G<num>> {}
// ^
//
diff --git a/pkg/front_end/testcases/nnbd/issue34803.dart.weak.outline.expect b/pkg/front_end/testcases/nnbd/issue34803.dart.weak.outline.expect
index 81ae317..9735668 100644
--- a/pkg/front_end/testcases/nnbd/issue34803.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/nnbd/issue34803.dart.weak.outline.expect
@@ -2,7 +2,7 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd/issue34803.dart:5:9: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/nnbd/issue34803.dart:7:9: Error: Type variables can't have generic function types in their bounds.
// class A<X extends G<num>> {}
// ^
//
diff --git a/pkg/front_end/testcases/nnbd/issue34803.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd/issue34803.dart.weak.transformed.expect
index 7cf7baa..fc4163c 100644
--- a/pkg/front_end/testcases/nnbd/issue34803.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/issue34803.dart.weak.transformed.expect
@@ -2,7 +2,7 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd/issue34803.dart:5:9: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/nnbd/issue34803.dart:7:9: Error: Type variables can't have generic function types in their bounds.
// class A<X extends G<num>> {}
// ^
//
diff --git a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart
index 11be33b..142da10 100644
--- a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart
+++ b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart
@@ -2,6 +2,8 @@
// 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.13
+
// Derived from
// instantiate_to_bound/non_simple_class_parameterized_typedef_cycle
diff --git a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.textual_outline.expect b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.textual_outline.expect
index a72af38..89ae237 100644
--- a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.textual_outline.expect
@@ -1,3 +1,4 @@
+// @dart = 2.13
import 'cyclic_typedef_lib.dart';
class Hest2<TypeX extends Fisk2> {}
diff --git a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.textual_outline_modelled.expect
index d03bf62..6813f4a 100644
--- a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.textual_outline_modelled.expect
@@ -1,3 +1,4 @@
+// @dart = 2.13
import 'cyclic_typedef_lib.dart';
class Hest2<TypeX extends Fisk2> {}
diff --git a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.expect b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.expect
index c05d772..83322f3 100644
--- a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.expect
+++ b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.expect
@@ -2,25 +2,25 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:10:7: Error: Generic type 'Hest2' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Fisk2'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:7: Error: Generic type 'Hest2' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Fisk2'.
// Try providing type arguments to 'Fisk2' here or to some other raw types in the bounds along the reference chain.
// class Hest2<TypeX extends Fisk2> {}
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:10:13: Context: Bound of this variable references raw type 'Fisk2'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:13: Context: Bound of this variable references raw type 'Fisk2'.
// class Hest2<TypeX extends Fisk2> {}
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:12:31: Context: Bound of this variable references raw type 'Hest2'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:14:31: Context: Bound of this variable references raw type 'Hest2'.
// typedef Fisk2 = void Function<TypeY extends Hest2>();
// ^^^^^
//
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:9: Error: Generic type 'Fisk1' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Hest1'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:14:9: Error: Generic type 'Fisk1' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Hest1'.
// Try providing type arguments to 'Hest1' here or to some other raw types in the bounds along the reference chain.
// typedef Fisk1 = void Function<TypeY extends Hest1>();
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:31: Context: Bound of this variable references raw type 'Hest1'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:14:31: Context: Bound of this variable references raw type 'Hest1'.
// typedef Fisk1 = void Function<TypeY extends Hest1>();
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:10:13: Context: Bound of this variable references raw type 'Fisk1'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:12:13: Context: Bound of this variable references raw type 'Fisk1'.
// class Hest1<TypeX extends Fisk1> {}
// ^^^^^
//
@@ -41,7 +41,7 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:10:13: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:12:13: Error: Type variables can't have generic function types in their bounds.
// class Hest1<TypeX extends Fisk1> {}
// ^^^^^
//
diff --git a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.outline.expect b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.outline.expect
index 13ca055..429487d 100644
--- a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.outline.expect
@@ -2,25 +2,25 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:10:7: Error: Generic type 'Hest2' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Fisk2'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:7: Error: Generic type 'Hest2' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Fisk2'.
// Try providing type arguments to 'Fisk2' here or to some other raw types in the bounds along the reference chain.
// class Hest2<TypeX extends Fisk2> {}
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:10:13: Context: Bound of this variable references raw type 'Fisk2'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:13: Context: Bound of this variable references raw type 'Fisk2'.
// class Hest2<TypeX extends Fisk2> {}
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:12:31: Context: Bound of this variable references raw type 'Hest2'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:14:31: Context: Bound of this variable references raw type 'Hest2'.
// typedef Fisk2 = void Function<TypeY extends Hest2>();
// ^^^^^
//
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:9: Error: Generic type 'Fisk1' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Hest1'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:14:9: Error: Generic type 'Fisk1' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Hest1'.
// Try providing type arguments to 'Hest1' here or to some other raw types in the bounds along the reference chain.
// typedef Fisk1 = void Function<TypeY extends Hest1>();
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:31: Context: Bound of this variable references raw type 'Hest1'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:14:31: Context: Bound of this variable references raw type 'Hest1'.
// typedef Fisk1 = void Function<TypeY extends Hest1>();
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:10:13: Context: Bound of this variable references raw type 'Fisk1'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:12:13: Context: Bound of this variable references raw type 'Fisk1'.
// class Hest1<TypeX extends Fisk1> {}
// ^^^^^
//
@@ -41,7 +41,7 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:10:13: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:12:13: Error: Type variables can't have generic function types in their bounds.
// class Hest1<TypeX extends Fisk1> {}
// ^^^^^
//
diff --git a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.transformed.expect
index c05d772..83322f3 100644
--- a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart.weak.transformed.expect
@@ -2,25 +2,25 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:10:7: Error: Generic type 'Hest2' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Fisk2'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:7: Error: Generic type 'Hest2' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Fisk2'.
// Try providing type arguments to 'Fisk2' here or to some other raw types in the bounds along the reference chain.
// class Hest2<TypeX extends Fisk2> {}
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:10:13: Context: Bound of this variable references raw type 'Fisk2'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:13: Context: Bound of this variable references raw type 'Fisk2'.
// class Hest2<TypeX extends Fisk2> {}
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:12:31: Context: Bound of this variable references raw type 'Hest2'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:14:31: Context: Bound of this variable references raw type 'Hest2'.
// typedef Fisk2 = void Function<TypeY extends Hest2>();
// ^^^^^
//
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:9: Error: Generic type 'Fisk1' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Hest1'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:14:9: Error: Generic type 'Fisk1' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Hest1'.
// Try providing type arguments to 'Hest1' here or to some other raw types in the bounds along the reference chain.
// typedef Fisk1 = void Function<TypeY extends Hest1>();
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:12:31: Context: Bound of this variable references raw type 'Hest1'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef.dart:14:31: Context: Bound of this variable references raw type 'Hest1'.
// typedef Fisk1 = void Function<TypeY extends Hest1>();
// ^^^^^
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:10:13: Context: Bound of this variable references raw type 'Fisk1'.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:12:13: Context: Bound of this variable references raw type 'Fisk1'.
// class Hest1<TypeX extends Fisk1> {}
// ^^^^^
//
@@ -41,7 +41,7 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:10:13: Error: Type variables can't have generic function types in their bounds.
+// pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart:12:13: Error: Type variables can't have generic function types in their bounds.
// class Hest1<TypeX extends Fisk1> {}
// ^^^^^
//
diff --git a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart
index 46e47dc..fa70b9c 100644
--- a/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart
+++ b/pkg/front_end/testcases/nnbd_mixed/cyclic_typedef_lib.dart
@@ -2,6 +2,8 @@
// 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.13
+
// Derived from
// instantiate_to_bound/non_simple_class_parameterized_typedef_cycle
diff --git a/pkg/front_end/tool/_fasta/generate_messages.dart b/pkg/front_end/tool/_fasta/generate_messages.dart
index 23a3487..ba52246 100644
--- a/pkg/front_end/tool/_fasta/generate_messages.dart
+++ b/pkg/front_end/tool/_fasta/generate_messages.dart
@@ -81,8 +81,6 @@
cfeMessages.writeln(preamble1);
cfeMessages.writeln("""
-// @dart = 2.9
-
""");
cfeMessages.writeln(preamble2);
cfeMessages.writeln("""
diff --git a/runtime/tests/vm/dart/regress_lsl_with_constant_test.dart b/runtime/tests/vm/dart/regress_lsl_with_constant_test.dart
new file mode 100644
index 0000000..368a98b
--- /dev/null
+++ b/runtime/tests/vm/dart/regress_lsl_with_constant_test.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2021, 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.
+
+// Regression test which checks that shift left with constant operand compiles
+// correctly even if narrowed to Int32 shift.
+
+import 'dart:typed_data';
+
+import 'package:expect/expect.dart';
+
+const int N = 10;
+
+@pragma('vm:never-inline')
+void test(Int32List v) {
+ // The shape of the code here is choosen to trigger Int64->Int32
+ // narrowing in the range analysis.
+ v[0] = (v[0] & 0xFF) << (N - 1);
+}
+
+void main() {
+ final list = Int32List(1);
+ for (var i = 0; i < 10; i++) {
+ list[0] = i;
+ test(list);
+ Expect.equals(i << 9, list[0]);
+ }
+}
diff --git a/runtime/tests/vm/dart_2/regress_lsl_with_constant_test.dart b/runtime/tests/vm/dart_2/regress_lsl_with_constant_test.dart
new file mode 100644
index 0000000..368a98b
--- /dev/null
+++ b/runtime/tests/vm/dart_2/regress_lsl_with_constant_test.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2021, 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.
+
+// Regression test which checks that shift left with constant operand compiles
+// correctly even if narrowed to Int32 shift.
+
+import 'dart:typed_data';
+
+import 'package:expect/expect.dart';
+
+const int N = 10;
+
+@pragma('vm:never-inline')
+void test(Int32List v) {
+ // The shape of the code here is choosen to trigger Int64->Int32
+ // narrowing in the range analysis.
+ v[0] = (v[0] & 0xFF) << (N - 1);
+}
+
+void main() {
+ final list = Int32List(1);
+ for (var i = 0; i < 10; i++) {
+ list[0] = i;
+ test(list);
+ Expect.equals(i << 9, list[0]);
+ }
+}
diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc
index 85561c4..3e59fa6 100644
--- a/runtime/vm/compiler/backend/il.cc
+++ b/runtime/vm/compiler/backend/il.cc
@@ -3302,6 +3302,21 @@
Definition* IntConverterInstr::Canonicalize(FlowGraph* flow_graph) {
if (!HasUses()) return NULL;
+ // Fold IntConverter({Unboxed}Constant(...)) to UnboxedConstant.
+ if (auto constant = value()->definition()->AsConstant()) {
+ if (from() != kUntagged && to() != kUntagged &&
+ constant->representation() == from() && constant->value().IsInteger()) {
+ const int64_t value = Integer::Cast(constant->value()).AsInt64Value();
+ const int64_t result =
+ Evaluator::TruncateTo(Evaluator::TruncateTo(value, from()), to());
+ if (is_truncating() || (value == result)) {
+ auto& box = Integer::Handle(Integer::New(result, Heap::kOld));
+ box ^= box.Canonicalize(flow_graph->thread());
+ return flow_graph->GetConstant(box, to());
+ }
+ }
+ }
+
IntConverterInstr* box_defn = value()->definition()->AsIntConverter();
if ((box_defn != NULL) && (box_defn->representation() == from())) {
// If the first convertion can erase bits (or deoptimize) we can't
diff --git a/runtime/vm/compiler/backend/il_printer.cc b/runtime/vm/compiler/backend/il_printer.cc
index b9907ec..6c903ec 100644
--- a/runtime/vm/compiler/backend/il_printer.cc
+++ b/runtime/vm/compiler/backend/il_printer.cc
@@ -845,6 +845,8 @@
f->AddString(" {");
for (intptr_t i = 0; i < defns.length(); ++i) {
Definition* def = defns[i];
+ // Skip constants which are not used in the graph.
+ if (def->IsConstant() && !def->HasUses()) continue;
f->AddString("\n ");
def->PrintTo(f);
}
diff --git a/tests/language/const_functions/const_functions_list_error_test.dart b/tests/language/const_functions/const_functions_list_error_test.dart
index 64a05e7..45e6f96 100644
--- a/tests/language/const_functions/const_functions_list_error_test.dart
+++ b/tests/language/const_functions/const_functions_list_error_test.dart
@@ -54,3 +54,32 @@
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_GETTER
// [cfe] The getter 'invalidProperty' isn't defined for the class 'List<int>'.
}
+
+const getWithIndexException = getWithIndexExceptionFn();
+// ^^^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Constant evaluation error:
+int getWithIndexExceptionFn() {
+ const List<int> x = [1];
+ return x[1];
+}
+
+const getWithIndexException2 = getWithIndexExceptionFn2();
+// ^^^^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Constant evaluation error:
+int getWithIndexExceptionFn2() {
+ const List<int> x = [1];
+ return x[-1];
+}
+
+const getWithIndexException3 = getWithIndexExceptionFn3();
+// ^^^^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+int getWithIndexExceptionFn3() {
+ const List<int> x = [1];
+ return x[0.1];
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] A value of type 'double' can't be assigned to a variable of type 'int'.
+}
diff --git a/tests/language/const_functions/const_functions_list_test.dart b/tests/language/const_functions/const_functions_list_test.dart
index 0810d57..31746a5 100644
--- a/tests/language/const_functions/const_functions_list_test.dart
+++ b/tests/language/const_functions/const_functions_list_test.dart
@@ -137,6 +137,27 @@
return x.runtimeType;
}
+const getWithIndexVar = getWithIndexFn();
+// ^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+int getWithIndexFn() {
+ const List<int> x = [1];
+ return x[0];
+}
+
+const rangeErrorCatchVar = rangeErrorCatchFn();
+// ^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+int rangeErrorCatchFn() {
+ try {
+ const List<int> x = [1];
+ var v = x[1];
+ } on RangeError {
+ return 0;
+ }
+ return 1;
+}
+
void main() {
Expect.equals(firstVar, 1);
Expect.equals(firstCatchVar, 0);
@@ -150,4 +171,6 @@
Expect.equals(singleCatchVar, 0);
Expect.equals(singleCatchVar2, 0);
Expect.equals(typeVar, int);
+ Expect.equals(getWithIndexVar, 1);
+ Expect.equals(rangeErrorCatchVar, 0);
}
diff --git a/tools/VERSION b/tools/VERSION
index fac5e16..8e39ebb 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 45
+PRERELEASE 46
PRERELEASE_PATCH 0
\ No newline at end of file