diff --git a/pkg/_fe_analyzer_shared/lib/src/util/libraries_specification.dart b/pkg/_fe_analyzer_shared/lib/src/util/libraries_specification.dart index bcbe4856162..7bc929b5fd1 100644 --- a/pkg/_fe_analyzer_shared/lib/src/util/libraries_specification.dart +++ b/pkg/_fe_analyzer_shared/lib/src/util/libraries_specification.dart @@ -76,6 +76,9 @@ /// report that such library is still not supported in conditional imports /// and const `fromEnvironment` expressions. /// +/// Internal libraries are never supported through conditional imports and +/// const `fromEnvironment` expressions. +/// /// /// Note: we currently have several different files that need to be updated /// when changing libraries, sources, and patch files: @@ -270,8 +273,10 @@ class LibrariesSpecification { if (supported is! bool) { _reportError(messageSupportedIsNotABool(supported)); } - libraries[libraryName] = - new LibraryInfo(libraryName, uri, patches, isSupported: supported); + libraries[libraryName] = new LibraryInfo(libraryName, uri, patches, + // Internal libraries are never supported through conditional + // imports and const `fromEnvironment` expressions. + isSupported: supported && !libraryName.startsWith('_')); }); currentTargets.remove(targetName); return targets[targetName] = diff --git a/pkg/compiler/lib/src/apiimpl.dart b/pkg/compiler/lib/src/apiimpl.dart index 2b0ad7dc68d..ed1087c7893 100644 --- a/pkg/compiler/lib/src/apiimpl.dart +++ b/pkg/compiler/lib/src/apiimpl.dart @@ -5,10 +5,6 @@ library leg_apiimpl; import 'dart:async'; -import 'dart:convert' show utf8; - -import 'package:front_end/src/api_unstable/dart2js.dart' - show getSupportedLibraryNames; import '../compiler_new.dart' as api; import 'common/metrics.dart' show Metrics, Metric; @@ -17,7 +13,6 @@ import 'common.dart'; import 'compiler.dart'; import 'diagnostics/messages.dart' show Message; import 'environment.dart'; -import 'io/source_file.dart'; import 'options.dart' show CompilerOptions; /// Implements the [Compiler] using a [api.CompilerInput] for supplying the @@ -58,61 +53,22 @@ class CompilerImpl extends Compiler { null, null, null, null, message, api.Diagnostic.VERBOSE_INFO); } - Future setupSdk() { - var future = Future.value(null); - _Environment env = environment; - if (env.supportedLibraries == null) { - future = future.then((_) { - Uri specificationUri = options.librariesSpecificationUri; - - Future readJson(Uri uri) async { - api.Input spec = await provider.readFromUri(specificationUri); - String json = null; - // TODO(sigmund): simplify this, we have some API inconsistencies when - // our internal input adds a terminating zero. - if (spec is SourceFile) { - json = spec.slowText(); - } else if (spec is Binary) { - json = utf8.decode(spec.data); - } - return json; - } - - // TODO(sigmund): would be nice to front-load some of the CFE option - // processing and parse this .json file only once. - return getSupportedLibraryNames(specificationUri, - options.compileForServer ? "dart2js_server" : "dart2js", - readJson: readJson) - .then((libraries) { - env.supportedLibraries = libraries.toSet(); - }); - }); - } - // TODO(johnniwinther): This does not apply anymore. - // The incremental compiler sets up the sdk before run. - // Therefore this will be called a second time. - return future; - } - @override Future run() { Duration setupDuration = measurer.elapsedWallClock; - return selfTask.measureSubtask("impl.run", () { - return setupSdk().then((_) { - return super.run(); - }).then((bool success) { - if (options.verbose) { - StringBuffer timings = StringBuffer(); - computeTimings(setupDuration, timings); - logVerbose('$timings'); - } - if (options.reportPrimaryMetrics || options.reportSecondaryMetrics) { - StringBuffer metrics = StringBuffer(); - collectMetrics(metrics); - logInfo('$metrics'); - } - return success; - }); + return selfTask.measureSubtask("impl.run", () async { + bool success = await super.run(); + if (options.verbose) { + StringBuffer timings = StringBuffer(); + computeTimings(setupDuration, timings); + logVerbose('$timings'); + } + if (options.reportPrimaryMetrics || options.reportSecondaryMetrics) { + StringBuffer metrics = StringBuffer(); + collectMetrics(metrics); + logInfo('$metrics'); + } + return success; }); } @@ -239,50 +195,18 @@ class CompilerImpl extends Compiler { class _Environment implements Environment { final Map definitions; Map _completeMap; - Set supportedLibraries; _Environment(this.definitions); - @override - String valueOf(String name) { - if (_completeMap != null) return _completeMap[name]; - var result = definitions[name]; - if (result != null || definitions.containsKey(name)) return result; - if (!name.startsWith(_dartLibraryEnvironmentPrefix)) return null; - - String libraryName = name.substring(_dartLibraryEnvironmentPrefix.length); - - // Private libraries are not exposed to the users. - if (libraryName.startsWith("_")) return null; - if (supportedLibraries.contains(libraryName)) return "true"; - return null; - } - @override Map toMap() { if (_completeMap == null) { _completeMap = Map.from(definitions); - for (String libraryName in supportedLibraries) { - if (!libraryName.startsWith("_")) { - String key = '${_dartLibraryEnvironmentPrefix}${libraryName}'; - if (!definitions.containsKey(key)) { - _completeMap[key] = "true"; - } - } - } } return _completeMap; } } -/// For every 'dart:' library, a corresponding environment variable is set -/// to "true". The environment variable's name is the concatenation of -/// this prefix and the name (without the 'dart:'. -/// -/// For example 'dart:html' has the environment variable 'dart.library.html' set -/// to "true". -const String _dartLibraryEnvironmentPrefix = 'dart.library.'; - class _TimingData { final String description; final int milliseconds; diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart index dad3d72052b..35d9f525867 100644 --- a/pkg/compiler/lib/src/compiler.dart +++ b/pkg/compiler/lib/src/compiler.dart @@ -1086,9 +1086,6 @@ class _MapImpactCacheDeleter implements ImpactCacheDeleter { class _EmptyEnvironment implements Environment { const _EmptyEnvironment(); - @override - String valueOf(String key) => null; - @override Map toMap() => const {}; } diff --git a/pkg/compiler/lib/src/environment.dart b/pkg/compiler/lib/src/environment.dart index 67db9ac1c38..efc2bb0a3b0 100644 --- a/pkg/compiler/lib/src/environment.dart +++ b/pkg/compiler/lib/src/environment.dart @@ -8,12 +8,6 @@ /// conditional imports, and from `const String.fromEnvironment` and /// other similar constructors. abstract class Environment { - /// Return the string value of the given key. - /// - /// Note that `bool.fromEnvironment` and `int.fromEnvironment` are also - /// implemented in terms of `String.fromEnvironment`. - String valueOf(String key); - /// Returns the full environment as map. Map toMap(); } diff --git a/pkg/compiler/lib/src/ir/constants.dart b/pkg/compiler/lib/src/ir/constants.dart index 6994046cb11..d95ffb21ddc 100644 --- a/pkg/compiler/lib/src/ir/constants.dart +++ b/pkg/compiler/lib/src/ir/constants.dart @@ -2,11 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:front_end/src/api_prototype/constant_evaluator.dart' as ir; +import 'package:front_end/src/api_unstable/dart2js.dart' as ir; import 'package:kernel/ast.dart' as ir; import 'package:kernel/src/printer.dart' as ir; import 'package:kernel/type_environment.dart' as ir; -import 'package:front_end/src/api_prototype/constant_evaluator.dart' as ir; -import 'package:front_end/src/api_unstable/dart2js.dart' as ir; import '../kernel/dart2js_target.dart'; @@ -18,7 +18,7 @@ class Dart2jsConstantEvaluator extends ir.ConstantEvaluator { bool requiresConstant; - Dart2jsConstantEvaluator( + Dart2jsConstantEvaluator(ir.Component component, ir.TypeEnvironment typeEnvironment, ReportErrorFunction reportError, {Map environment = const {}, bool supportReevaluationForTesting = false, @@ -26,7 +26,9 @@ class Dart2jsConstantEvaluator extends ir.ConstantEvaluator { : _supportReevaluationForTesting = supportReevaluationForTesting, assert(evaluationMode != null), super( + const Dart2jsDartLibrarySupport(), const Dart2jsConstantsBackend(supportsUnevaluatedConstants: false), + component, environment, typeEnvironment, ErrorReporter(reportError), diff --git a/pkg/compiler/lib/src/js_model/element_map_impl.dart b/pkg/compiler/lib/src/js_model/element_map_impl.dart index 3bb766f2972..ae9a0a08935 100644 --- a/pkg/compiler/lib/src/js_model/element_map_impl.dart +++ b/pkg/compiler/lib/src/js_model/element_map_impl.dart @@ -1164,14 +1164,15 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap { } Dart2jsConstantEvaluator get constantEvaluator { - return _constantEvaluator ??= Dart2jsConstantEvaluator(typeEnvironment, - (ir.LocatedMessage message, List context) { + return _constantEvaluator ??= + Dart2jsConstantEvaluator(programEnv.mainComponent, typeEnvironment, + (ir.LocatedMessage message, List context) { reportLocatedMessage(reporter, message, context); }, - environment: _environment.toMap(), - evaluationMode: options.useLegacySubtyping - ? ir.EvaluationMode.weak - : ir.EvaluationMode.strong); + environment: _environment.toMap(), + evaluationMode: options.useLegacySubtyping + ? ir.EvaluationMode.weak + : ir.EvaluationMode.strong); } @override diff --git a/pkg/compiler/lib/src/kernel/dart2js_target.dart b/pkg/compiler/lib/src/kernel/dart2js_target.dart index 01f42be21c9..156e7a4f6a0 100644 --- a/pkg/compiler/lib/src/kernel/dart2js_target.dart +++ b/pkg/compiler/lib/src/kernel/dart2js_target.dart @@ -221,6 +221,10 @@ class Dart2jsTarget extends Target { @override ConstantsBackend get constantsBackend => const Dart2jsConstantsBackend(supportsUnevaluatedConstants: true); + + @override + DartLibrarySupport get dartLibrarySupport => + const Dart2jsDartLibrarySupport(); } // TODO(sigmund): this "extraRequiredLibraries" needs to be removed... @@ -314,3 +318,8 @@ class Dart2jsConstantsBackend extends ConstantsBackend { @override NumberSemantics get numberSemantics => NumberSemantics.js; } + +class Dart2jsDartLibrarySupport extends CustomizedDartLibrarySupport { + const Dart2jsDartLibrarySupport() + : super(supported: const {'_dart2js_runtime_metrics'}); +} diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart index f82c5eff943..b4a93afa558 100644 --- a/pkg/compiler/lib/src/kernel/element_map_impl.dart +++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart @@ -812,14 +812,15 @@ class KernelToElementMapImpl implements KernelToElementMap, IrToElementMap { } Dart2jsConstantEvaluator get constantEvaluator { - return _constantEvaluator ??= Dart2jsConstantEvaluator(typeEnvironment, - (ir.LocatedMessage message, List context) { + return _constantEvaluator ??= + Dart2jsConstantEvaluator(env.mainComponent, typeEnvironment, + (ir.LocatedMessage message, List context) { reportLocatedMessage(reporter, message, context); }, - environment: _environment.toMap(), - evaluationMode: options.useLegacySubtyping - ? ir.EvaluationMode.weak - : ir.EvaluationMode.strong); + environment: _environment.toMap(), + evaluationMode: options.useLegacySubtyping + ? ir.EvaluationMode.weak + : ir.EvaluationMode.strong); } @override diff --git a/pkg/compiler/test/analyses/analysis_helper.dart b/pkg/compiler/test/analyses/analysis_helper.dart index 559d972f639..b104a00d58a 100644 --- a/pkg/compiler/test/analyses/analysis_helper.dart +++ b/pkg/compiler/test/analyses/analysis_helper.dart @@ -86,7 +86,7 @@ class StaticTypeVisitorBase extends StaticTypeVisitor { classHierarchy, new StaticTypeCacheImpl()) { _constantEvaluator = new Dart2jsConstantEvaluator( - typeEnvironment, const ir.SimpleErrorReporter().report, + component, typeEnvironment, const ir.SimpleErrorReporter().report, evaluationMode: evaluationMode); } diff --git a/pkg/compiler/test/end_to_end/dill_loader_test.dart b/pkg/compiler/test/end_to_end/dill_loader_test.dart index 7bf0330040d..46626f43e18 100644 --- a/pkg/compiler/test/end_to_end/dill_loader_test.dart +++ b/pkg/compiler/test/end_to_end/dill_loader_test.dart @@ -43,7 +43,6 @@ main() { memorySourceFiles: {'main.dill': kernelBinary}, diagnosticHandler: diagnostics, outputProvider: output); - await compiler.setupSdk(); KernelResult result = await compiler.kernelLoader.load(); compiler.frontendStrategy.registerLoadedLibraries(result); diff --git a/pkg/compiler/test/end_to_end/library_env_test.dart b/pkg/compiler/test/end_to_end/library_env_test.dart deleted file mode 100644 index f194f370bf1..00000000000 --- a/pkg/compiler/test/end_to_end/library_env_test.dart +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) 2016, 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. - -// @dart = 2.7 - -/// Check that 'dart:' libraries have their corresponding dart.library.X -/// environment variable set. - -import 'dart:async'; - -import '../helpers/memory_compiler.dart'; -import '../helpers/memory_source_file_helper.dart'; - -import "package:async_helper/async_helper.dart"; - -import 'package:expect/expect.dart' show Expect; - -import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput; - -import 'package:compiler/src/options.dart' show CompilerOptions; - -import 'package:compiler/src/commandline_options.dart'; - -import 'package:compiler/src/io/source_file.dart' show Binary; - -import 'package:compiler/compiler_new.dart' - show CompilerInput, CompilerDiagnostics, Input, InputKind; - -const String librariesJson = r''' -{ - "dart2js": { - "libraries": { - "mock.client": {"uri": "mock1.dart"}, - "mock.shared": {"uri": "mock3.dart"}, - "collection": {"uri": "collection/collection.dart"}, - "html": {"uri": "html/dart2js/html_dart2js.dart"} - } - }, - "dart2js_server": { - "libraries": { - "mock.server": {"uri": "mock2.dart"}, - "mock.shared": {"uri": "mock3.dart"}, - "collection": {"uri": "collection/collection.dart"}, - "io": {"uri": "io/io.dart"} - } - } -} -'''; - -class DummyCompilerInput implements CompilerInput { - const DummyCompilerInput(); - - @override - Future readFromUri(Uri uri, - {InputKind inputKind: InputKind.UTF8}) async { - if (uri.path.endsWith("libraries.json")) { - return new Binary(uri, librariesJson.codeUnits); - } else { - throw "should not be needed $uri"; - } - } -} - -class DummyCompilerDiagnostics implements CompilerDiagnostics { - const DummyCompilerDiagnostics(); - - @override - report(code, uri, begin, end, text, kind) { - throw "should not be needed"; - } -} - -class CustomCompiler extends CompilerImpl { - CustomCompiler(List options, Map environment) - : super( - const DummyCompilerInput(), - const NullCompilerOutput(), - const DummyCompilerDiagnostics(), - CompilerOptions.parse( - ['--platform-binaries=$sdkPlatformBinariesPath'] - ..addAll(options), - librariesSpecificationUri: sdkLibrariesSpecificationUri) - ..environment = environment); -} - -runTest() async { - { - final compiler = new CustomCompiler([], {}); - - await compiler.setupSdk(); - final lookup = compiler.environment.valueOf; - - // Core libraries are always present. - Expect.equals("true", lookup("dart.library.collection")); - // Non-existing entries in the environment return 'null'. - Expect.isNull(lookup("not in env")); - // Check for client libraries (default if there are no flags to the compiler). - Expect.equals("true", lookup("dart.library.mock.client")); - Expect.equals("true", lookup("dart.library.html")); - // Check for shared libraries.. - Expect.equals("true", lookup("dart.library.mock.shared")); - // Check server libraries are not present. - Expect.equals(null, lookup("dart.library.mock.server")); - Expect.equals(null, lookup("dart.library.io")); - } - { - final compiler = new CustomCompiler([Flags.serverMode], {}); - - await compiler.setupSdk(); - final lookup = compiler.environment.valueOf; - - // Core libraries are always present. - Expect.equals("true", lookup("dart.library.collection")); - // Non-existing entries in the environment return 'null'. - Expect.isNull(lookup("not in env")); - // Check client libraries are not present. - Expect.equals(null, lookup("dart.library.mock.client")); - Expect.equals(null, lookup("dart.library.html")); - // Check for shared libraries.. - Expect.equals("true", lookup("dart.library.mock.shared")); - // Check for server libraries. - Expect.equals("true", lookup("dart.library.mock.server")); - Expect.equals("true", lookup("dart.library.io")); - } - { - // Check that user-defined env-variables win. - final compiler = new CustomCompiler([], { - 'dart.library.collection': "false", - 'dart.library.mock.client': "foo" - }); - - await compiler.setupSdk(); - final lookup = compiler.environment.valueOf; - - Expect.equals("false", lookup("dart.library.collection")); - Expect.equals("foo", lookup("dart.library.mock.client")); - } -} - -main() { - asyncStart(); - runTest().then((_) { - asyncEnd(); - }); -} diff --git a/pkg/compiler/test/end_to_end/modular_loader_test.dart b/pkg/compiler/test/end_to_end/modular_loader_test.dart index 35c1066eb64..b5819f07c73 100644 --- a/pkg/compiler/test/end_to_end/modular_loader_test.dart +++ b/pkg/compiler/test/end_to_end/modular_loader_test.dart @@ -44,7 +44,6 @@ main() { memorySourceFiles: {'a.dill': aDill, 'b.dill': bDill, 'c.dill': cDill}, diagnosticHandler: diagnostics, outputProvider: output); - await compiler.setupSdk(); KernelResult result = await compiler.kernelLoader.load(); compiler.frontendStrategy.registerLoadedLibraries(result); diff --git a/pkg/compiler/test/model/cfe_constant_evaluation_test.dart b/pkg/compiler/test/model/cfe_constant_evaluation_test.dart index b133fd4ca30..24c4a58f186 100644 --- a/pkg/compiler/test/model/cfe_constant_evaluation_test.dart +++ b/pkg/compiler/test/model/cfe_constant_evaluation_test.dart @@ -596,9 +596,9 @@ Future testData(TestData data) async { expectedResults .forEach((Map environment, String expectedText) { List errors = []; - Dart2jsConstantEvaluator evaluator = - new Dart2jsConstantEvaluator(elementMap.typeEnvironment, - (ir.LocatedMessage message, List context) { + Dart2jsConstantEvaluator evaluator = new Dart2jsConstantEvaluator( + elementMap.env.mainComponent, elementMap.typeEnvironment, + (ir.LocatedMessage message, List context) { // TODO(johnniwinther): Assert that `message.uri != null`. Currently // all unevaluated constants have no uri. // The actual message is a "constant errors starts here" message, @@ -606,11 +606,11 @@ Future testData(TestData data) async { errors.add(context.first.code.name); reportLocatedMessage(elementMap.reporter, message, context); }, - environment: environment, - supportReevaluationForTesting: true, - evaluationMode: compiler.options.useLegacySubtyping - ? ir.EvaluationMode.weak - : ir.EvaluationMode.strong); + environment: environment, + supportReevaluationForTesting: true, + evaluationMode: compiler.options.useLegacySubtyping + ? ir.EvaluationMode.weak + : ir.EvaluationMode.strong); ir.Constant evaluatedConstant = evaluator.evaluate( new ir.StaticTypeContext(node, typeEnvironment), initializer); diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart index 5b514be2ff4..9b9fd08e442 100644 --- a/pkg/dev_compiler/lib/src/kernel/command.dart +++ b/pkg/dev_compiler/lib/src/kernel/command.dart @@ -825,10 +825,6 @@ Map parseAndRemoveDeclaredVariables(List args) { } } - // Add platform defined variables - // TODO(47243) Remove when all code paths read these from the `Target`. - declaredVariables.addAll(sdkLibraryEnvironmentDefines); - return declaredVariables; } diff --git a/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart b/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart index 6d5c4182787..215ba19c6dc 100644 --- a/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart +++ b/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart @@ -25,7 +25,6 @@ import '../../dev_compiler.dart'; import '../compiler/js_names.dart'; import 'asset_file_system.dart'; import 'command.dart'; -import 'target.dart' show sdkLibraryEnvironmentDefines; /// The service that handles expression compilation requests from /// the debugger. @@ -231,8 +230,6 @@ class ExpressionCompilerWorker { ..omitPlatform = true ..environmentDefines = { if (environmentDefines != null) ...environmentDefines, - // TODO(47243) Remove when all code paths read these from the `Target`. - ...sdkLibraryEnvironmentDefines } ..explicitExperimentalFlags = explicitExperimentalFlags ..onDiagnostic = _onDiagnosticHandler(errors, warnings, infos) diff --git a/pkg/dev_compiler/lib/src/kernel/target.dart b/pkg/dev_compiler/lib/src/kernel/target.dart index bb79eb83e96..90dc78ecd92 100644 --- a/pkg/dev_compiler/lib/src/kernel/target.dart +++ b/pkg/dev_compiler/lib/src/kernel/target.dart @@ -20,34 +20,6 @@ import 'package:kernel/transformations/track_widget_constructor_locations.dart'; import 'constants.dart' show DevCompilerConstantsBackend; import 'kernel_helpers.dart'; -/// Boolean environment variables that indicate which libraries are available in -/// dev compiler. -// TODO(jmesserly): provide an option to compile without dart:html & friends? -const sdkLibraryEnvironmentDefines = { - 'dart.isVM': 'false', - 'dart.library.async': 'true', - 'dart.library.core': 'true', - 'dart.library.collection': 'true', - 'dart.library.convert': 'true', - // TODO(jmesserly): this is not really supported in dart4web other than - // `debugger()` - 'dart.library.developer': 'true', - 'dart.library.io': 'false', - 'dart.library.isolate': 'false', - 'dart.library.js': 'true', - 'dart.library.js_util': 'true', - 'dart.library.math': 'true', - 'dart.library.mirrors': 'false', - 'dart.library.typed_data': 'true', - 'dart.library.indexed_db': 'true', - 'dart.library.html': 'true', - 'dart.library.html_common': 'true', - 'dart.library.svg': 'true', - 'dart.library.ui': 'false', - 'dart.library.web_audio': 'true', - 'dart.library.web_gl': 'true', -}; - /// A kernel [Target] to configure the Dart Front End for dartdevc. class DevCompilerTarget extends Target { DevCompilerTarget(this.flags); @@ -59,10 +31,6 @@ class DevCompilerTarget extends Target { Map? _nativeClasses; - @override - Map updateEnvironmentDefines(Map map) => - map..addAll(sdkLibraryEnvironmentDefines); - @override bool get enableSuperMixins => true; diff --git a/pkg/front_end/lib/src/api_unstable/dart2js.dart b/pkg/front_end/lib/src/api_unstable/dart2js.dart index d008fd6303d..357b21f4e51 100644 --- a/pkg/front_end/lib/src/api_unstable/dart2js.dart +++ b/pkg/front_end/lib/src/api_unstable/dart2js.dart @@ -12,9 +12,6 @@ import 'package:_fe_analyzer_shared/src/messages/severity.dart' show Severity; import 'package:_fe_analyzer_shared/src/scanner/scanner.dart' show StringToken; -import 'package:_fe_analyzer_shared/src/util/libraries_specification.dart' - show LibrariesSpecification; - import 'package:kernel/kernel.dart' show Component; import 'package:kernel/ast.dart' as ir; @@ -217,28 +214,6 @@ Future compile( return compilerResult?.component; } -/// Retrieve the name of the libraries that are supported by [target] according -/// to the libraries specification [json] file. -/// -/// Dart2js uses these names to determine the value of library environment -/// constants, such as `const bool.fromEnvironment("dart.library.io")`. -// TODO(sigmund): refactor dart2js so that we can retrieve this data later in -// the compilation pipeline. At that point we can get it from the CFE -// results directly and completely hide the libraries specification file from -// dart2js. -// TODO(sigmund): delete after all constant evaluation is done in the CFE, as -// this data will no longer be needed on the dart2js side. -Future> getSupportedLibraryNames( - Uri librariesSpecificationUri, String target, - {required Future readJson(Uri uri)}) async { - return (await LibrariesSpecification.load( - librariesSpecificationUri, readJson)) - .specificationFor(target) - .allLibraries - .where((l) => l.isSupported) - .map((l) => l.name); -} - /// Desugar API to determine whether [member] is a redirecting factory /// constructor. // TODO(sigmund): Delete this API once `member.isRedirectingFactory` diff --git a/pkg/front_end/lib/src/fasta/builder/library_builder.dart b/pkg/front_end/lib/src/fasta/builder/library_builder.dart index f2c63b83f2a..c86c3c004a7 100644 --- a/pkg/front_end/lib/src/fasta/builder/library_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/library_builder.dart @@ -69,6 +69,10 @@ abstract class LibraryBuilder implements ModifierBuilder { /// This is the canonical uri for the library, for instance 'dart:core'. Uri get importUri; + /// If true, the library is not supported through the 'dart.library.*' value + /// used in conditional imports and `bool.fromEnvironment` constants. + bool get isUnsupported; + Iterator get iterator; NameIterator get nameIterator; diff --git a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart index b3675032667..d09fac5fd91 100644 --- a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart +++ b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart @@ -130,6 +130,9 @@ class DillLibraryBuilder extends LibraryBuilderImpl { } } + @override + bool get isUnsupported => library.isUnsupported; + @override bool get isSynthetic => library.isSynthetic; diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart index 6e012464579..8152374d4ec 100644 --- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart +++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart @@ -1735,6 +1735,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { loader: lastGoodKernelTarget.loader, scope: libraryBuilder.scope.createNestedScope("expression"), nameOrigin: libraryBuilder, + isUnsupported: libraryBuilder.isUnsupported, ); _ticker.logMs("Created debug library"); 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 f9bfef439b0..63f0ffdacfa 100644 --- a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart +++ b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart @@ -39,8 +39,8 @@ import 'constant_int_folder.dart'; part 'constant_collection_builders.dart'; Component transformComponent( + Target target, Component component, - ConstantsBackend backend, Map environmentDefines, ErrorReporter errorReporter, EvaluationMode evaluationMode, @@ -70,7 +70,7 @@ Component transformComponent( final TypeEnvironment typeEnvironment = new TypeEnvironment(coreTypes, hierarchy); - transformLibraries(component.libraries, backend, environmentDefines, + transformLibraries(component, component.libraries, target, environmentDefines, typeEnvironment, errorReporter, evaluationMode, enableTripleShift: enableTripleShift, enableConstFunctions: enableConstFunctions, @@ -81,8 +81,9 @@ Component transformComponent( } ConstantEvaluationData transformLibraries( + Component component, List libraries, - ConstantsBackend backend, + Target target, Map? environmentDefines, TypeEnvironment typeEnvironment, ErrorReporter errorReporter, @@ -103,13 +104,14 @@ ConstantEvaluationData transformLibraries( // ignore: unnecessary_null_comparison assert(enableConstructorTearOff != null); final ConstantsTransformer constantsTransformer = new ConstantsTransformer( - backend, + target, environmentDefines, evaluateAnnotations, enableTripleShift, enableConstFunctions, enableConstructorTearOff, errorOnUnevaluatedConstant, + component, typeEnvironment, errorReporter, evaluationMode); @@ -124,7 +126,8 @@ ConstantEvaluationData transformLibraries( void transformProcedure( Procedure procedure, - ConstantsBackend backend, + Target target, + Component component, Map? environmentDefines, TypeEnvironment typeEnvironment, ErrorReporter errorReporter, @@ -145,13 +148,14 @@ void transformProcedure( // ignore: unnecessary_null_comparison assert(enableConstructorTearOff != null); final ConstantsTransformer constantsTransformer = new ConstantsTransformer( - backend, + target, environmentDefines, evaluateAnnotations, enableTripleShift, enableConstFunctions, enableConstructorTearOff, errorOnUnevaluatedConstant, + component, typeEnvironment, errorReporter, evaluationMode); @@ -341,18 +345,25 @@ class ConstantsTransformer extends RemovingTransformer { final bool errorOnUnevaluatedConstant; ConstantsTransformer( - this.backend, + Target target, Map? environmentDefines, this.evaluateAnnotations, this.enableTripleShift, this.enableConstFunctions, this.enableConstructorTearOff, this.errorOnUnevaluatedConstant, + Component component, this.typeEnvironment, ErrorReporter errorReporter, EvaluationMode evaluationMode) - : constantEvaluator = new ConstantEvaluator( - backend, environmentDefines, typeEnvironment, errorReporter, + : this.backend = target.constantsBackend, + constantEvaluator = new ConstantEvaluator( + target.dartLibrarySupport, + target.constantsBackend, + component, + environmentDefines, + typeEnvironment, + errorReporter, enableTripleShift: enableTripleShift, enableConstFunctions: enableConstFunctions, errorOnUnevaluatedConstant: errorOnUnevaluatedConstant, @@ -871,11 +882,13 @@ class ConstantsTransformer extends RemovingTransformer { } class ConstantEvaluator implements ExpressionVisitor { + final DartLibrarySupport dartLibrarySupport; final ConstantsBackend backend; final NumberSemantics numberSemantics; late ConstantIntFolder intFolder; - Map? environmentDefines; + Map? _environmentDefines; final bool errorOnUnevaluatedConstant; + final Component component; final CoreTypes coreTypes; final TypeEnvironment typeEnvironment; StaticTypeContext? _staticTypeContext; @@ -914,8 +927,8 @@ class ConstantEvaluator implements ExpressionVisitor { late ConstantWeakener _weakener; - ConstantEvaluator(this.backend, this.environmentDefines, this.typeEnvironment, - this.errorReporter, + ConstantEvaluator(this.dartLibrarySupport, this.backend, this.component, + this._environmentDefines, this.typeEnvironment, this.errorReporter, {this.enableTripleShift = false, this.enableConstFunctions = false, this.errorOnUnevaluatedConstant = false, @@ -925,7 +938,7 @@ class ConstantEvaluator implements ExpressionVisitor { canonicalizationCache = {}, nodeCache = {}, env = new EvaluationEnvironment() { - if (environmentDefines == null && !backend.supportsUnevaluatedConstants) { + if (_environmentDefines == null && !backend.supportsUnevaluatedConstants) { throw new ArgumentError( "No 'environmentDefines' passed to the constant evaluator but the " "ConstantsBackend does not support unevaluated constants."); @@ -947,6 +960,43 @@ class ConstantEvaluator implements ExpressionVisitor { _weakener = new ConstantWeakener(this); } + Map? _supportedLibrariesCache; + + Map _computeSupportedLibraries() { + Map map = {}; + for (Library library in component.libraries) { + if (library.importUri.scheme == 'dart') { + map[library.importUri.path] = + DartLibrarySupport.getDartLibrarySupportValue( + library.importUri.path, + libraryExists: true, + isSynthetic: library.isSynthetic, + isUnsupported: library.isUnsupported, + dartLibrarySupport: dartLibrarySupport); + } + } + return map; + } + + String? lookupEnvironment(String key) { + if (DartLibrarySupport.isDartLibraryQualifier(key)) { + String libraryName = DartLibrarySupport.getDartLibraryName(key); + String? value = (_supportedLibrariesCache ??= + _computeSupportedLibraries())[libraryName]; + return value ?? ""; + } + return _environmentDefines![key]; + } + + bool hasEnvironmentKey(String key) { + if (key.startsWith(DartLibrarySupport.dartLibraryPrefix)) { + return true; + } + return _environmentDefines!.containsKey(key); + } + + bool get hasEnvironment => _environmentDefines != null; + DartType convertType(DartType type) { switch (evaluationMode) { case EvaluationMode.strong: @@ -1375,7 +1425,7 @@ class ConstantEvaluator implements ExpressionVisitor { Constant constant = node.constant; Constant result = constant; if (constant is UnevaluatedConstant) { - if (environmentDefines != null) { + if (hasEnvironment) { result = _evaluateSubexpression(constant.expression); if (result is AbortConstant) return result; } else { @@ -2902,7 +2952,7 @@ class ConstantEvaluator implements ExpressionVisitor { Constant _handleFromEnvironment( Procedure target, StringConstant name, Map named) { - String? value = environmentDefines![name.value]; + String? value = lookupEnvironment(name.value); Constant? defaultValue = named["defaultValue"]; if (target.enclosingClass == coreTypes.boolClass) { Constant boolConstant; @@ -2961,9 +3011,7 @@ class ConstantEvaluator implements ExpressionVisitor { } Constant _handleHasEnvironment(StringConstant name) { - return environmentDefines!.containsKey(name.value) - ? trueConstant - : falseConstant; + return hasEnvironmentKey(name.value) ? trueConstant : falseConstant; } @override @@ -3015,7 +3063,7 @@ class ConstantEvaluator implements ExpressionVisitor { positionals.length == 1 && (target.name.text == "fromEnvironment" || target.name.text == "hasEnvironment")) { - if (environmentDefines != null) { + if (hasEnvironment) { // Evaluate environment constant. Constant name = positionals.single; if (name is StringConstant) { diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart index 00736780467..79ff78dbe18 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart @@ -1343,8 +1343,9 @@ class KernelTarget extends TargetImplementation { constants.ConstantEvaluationData constantEvaluationData = constants.transformLibraries( + component!, loader.libraries, - backendTarget.constantsBackend, + backendTarget, environmentDefines, environment, new KernelConstantErrorReporter(loader), @@ -1400,7 +1401,8 @@ class KernelTarget extends TargetImplementation { constants.transformProcedure( procedure, - backendTarget.constantsBackend, + backendTarget, + component!, environmentDefines, environment, new KernelConstantErrorReporter(loader), 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 01f02a8e415..915ff8d2a31 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 @@ -139,6 +139,9 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { Uri? get packageUriForTesting => _packageUri; + @override + final bool isUnsupported; + final List accessors = []; @override @@ -250,7 +253,8 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { Library library, LibraryBuilder? nameOrigin, Library? referencesFrom, - bool? referenceIsPartOwner) + bool? referenceIsPartOwner, + bool isUnsupported) : this.fromScopes( loader, fileUri, @@ -261,7 +265,8 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { origin, library, nameOrigin, - referencesFrom); + referencesFrom, + isUnsupported); SourceLibraryBuilder.fromScopes( this.loader, @@ -273,7 +278,8 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { SourceLibraryBuilder? origin, this.library, this._nameOrigin, - this.referencesFrom) + this.referencesFrom, + this.isUnsupported) : _languageVersion = packageLanguageVersion, currentTypeParameterScopeBuilder = _libraryTypeParameterScopeBuilder, referencesFromIndexed = @@ -462,7 +468,8 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { Library? target, LibraryBuilder? nameOrigin, Library? referencesFrom, - bool? referenceIsPartOwner}) + bool? referenceIsPartOwner, + required bool isUnsupported}) : this.internal( loader, fileUri, @@ -480,7 +487,8 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { ..setLanguageVersion(packageLanguageVersion.version)), nameOrigin, referencesFrom, - referenceIsPartOwner); + referenceIsPartOwner, + isUnsupported); @override bool get isPart => partOfName != null || partOfUri != null; @@ -703,7 +711,8 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { int uriOffset) { if (configurations != null) { for (Configuration config in configurations) { - if (lookupImportCondition(config.dottedName) == config.condition) { + if (loader.getLibrarySupportValue(config.dottedName) == + config.condition) { uri = config.importUri; break; } @@ -717,26 +726,6 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { exports.add(new Export(this, exportedLibrary, combinators, charOffset)); } - String lookupImportCondition(String dottedName) { - const String prefix = "dart.library."; - if (!dottedName.startsWith(prefix)) return ""; - dottedName = dottedName.substring(prefix.length); - if (!loader.target.uriTranslator.isLibrarySupported(dottedName)) return ""; - - LibraryBuilder? imported = - loader.lookupLibraryBuilder(new Uri(scheme: "dart", path: dottedName)); - - if (imported == null) { - LibraryBuilder coreLibrary = loader.readAsEntryPoint(resolve( - this.importUri, - new Uri(scheme: "dart", path: "core").toString(), - -1)); - imported = coreLibrary.loader - .lookupLibraryBuilder(new Uri(scheme: 'dart', path: dottedName)); - } - return imported != null && !imported.isSynthetic ? "true" : ""; - } - void addImport( List? metadata, String uri, @@ -750,7 +739,8 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { int importIndex) { if (configurations != null) { for (Configuration config in configurations) { - if (lookupImportCondition(config.dottedName) == config.condition) { + if (loader.getLibrarySupportValue(config.dottedName) == + config.condition) { uri = config.importUri; break; } @@ -1076,6 +1066,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl { if (!modifyTarget) return library; library.isSynthetic = isSynthetic; + library.isUnsupported = isUnsupported; addDependencies(library, new Set()); library.name = name; diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart index afd4413a440..40412d7f223 100644 --- a/pkg/front_end/lib/src/fasta/source/source_loader.dart +++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart @@ -26,6 +26,7 @@ import 'package:kernel/class_hierarchy.dart' show ClassHierarchy, HandleAmbiguousSupertypes; import 'package:kernel/core_types.dart' show CoreTypes; import 'package:kernel/reference_from_index.dart' show ReferenceFromIndex; +import 'package:kernel/target/targets.dart'; import 'package:kernel/type_environment.dart'; import 'package:kernel/util/graph.dart'; import 'package:package_config/package_config.dart' as package_config; @@ -318,7 +319,32 @@ class SourceLoader extends Loader { loader: this, origin: origin, referencesFrom: referencesFrom, - referenceIsPartOwner: referenceIsPartOwner); + referenceIsPartOwner: referenceIsPartOwner, + isUnsupported: origin?.library.isUnsupported ?? + importUri.scheme == 'dart' && + !target.uriTranslator.isLibrarySupported(importUri.path)); + } + + /// Return `"true"` if the [dottedName] is a 'dart.library.*' qualifier for a + /// supported dart:* library, and `""` otherwise. + /// + /// This is used to determine conditional imports and `bool.fromEnvironment` + /// constant values for "dart.library.[libraryName]" values. + String getLibrarySupportValue(String dottedName) { + if (!DartLibrarySupport.isDartLibraryQualifier(dottedName)) { + return ""; + } + String libraryName = DartLibrarySupport.getDartLibraryName(dottedName); + Uri uri = new Uri(scheme: "dart", path: libraryName); + LibraryBuilder? library = lookupLibraryBuilder(uri); + // TODO(johnniwinther): Why is the dill target sometimes not loaded at this + // point? And does it matter? + library ??= target.dillTarget.loader.lookupLibraryBuilder(uri); + return DartLibrarySupport.getDartLibrarySupportValue(libraryName, + libraryExists: library != null, + isSynthetic: library?.isSynthetic ?? true, + isUnsupported: library?.isUnsupported ?? true, + dartLibrarySupport: target.backendTarget.dartLibrarySupport); } SourceLibraryBuilder _createSourceLibraryBuilder( diff --git a/pkg/front_end/lib/src/fasta/uri_translator.dart b/pkg/front_end/lib/src/fasta/uri_translator.dart index cf624b4f7fc..dac88453a75 100644 --- a/pkg/front_end/lib/src/fasta/uri_translator.dart +++ b/pkg/front_end/lib/src/fasta/uri_translator.dart @@ -50,9 +50,7 @@ class UriTranslator { } bool isLibrarySupported(String libraryName) { - // TODO(sigmund): change this to `?? false` when all backends provide the - // `libraries.json` file by default (Issue #32657). - return dartLibraries.libraryInfoFor(libraryName)?.isSupported ?? true; + return dartLibraries.libraryInfoFor(libraryName)?.isSupported ?? false; } Uri? _translateDartUri(Uri uri) { diff --git a/pkg/front_end/test/constant_evaluator_benchmark.dart b/pkg/front_end/test/constant_evaluator_benchmark.dart index 35f5faa95eb..c86c066239b 100644 --- a/pkg/front_end/test/constant_evaluator_benchmark.dart +++ b/pkg/front_end/test/constant_evaluator_benchmark.dart @@ -7,43 +7,33 @@ import 'dart:typed_data' show Uint8List; import 'package:_fe_analyzer_shared/src/messages/codes.dart'; import 'package:compiler/src/kernel/dart2js_target.dart' show Dart2jsTarget; - import 'package:dev_compiler/src/kernel/target.dart' show DevCompilerTarget; - import 'package:front_end/src/api_prototype/compiler_options.dart' show CompilerOptions, DiagnosticMessage; - import 'package:front_end/src/api_prototype/experimental_flags.dart' show ExperimentalFlag; - import 'package:front_end/src/base/processed_options.dart' show ProcessedOptions; - import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; - import 'package:front_end/src/fasta/incremental_compiler.dart' show IncrementalCompiler; import 'package:front_end/src/fasta/kernel/constant_evaluator.dart' as constants show EvaluationMode, transformLibraries, ErrorReporter; - import 'package:front_end/src/fasta/kernel/kernel_target.dart'; +import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent; import 'package:kernel/ast.dart'; import 'package:kernel/binary/ast_from_binary.dart'; -import 'package:kernel/core_types.dart'; import 'package:kernel/class_hierarchy.dart'; +import 'package:kernel/core_types.dart'; import 'package:kernel/target/changed_structure_notifier.dart'; import 'package:kernel/target/targets.dart' - show ConstantsBackend, DiagnosticReporter, Target, TargetFlags; + show DiagnosticReporter, Target, TargetFlags; import 'package:kernel/type_environment.dart'; - import "package:vm/target/flutter.dart" show FlutterTarget; - import "package:vm/target/vm.dart" show VmTarget; import 'incremental_suite.dart' show getOptions; -import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent; - bool? tryWithNoEnvironment; bool verbose = false; bool skipNonNullEnvironment = false; @@ -80,8 +70,6 @@ void benchmark(Component component, List libraries) { stopwatch.reset(); CoreTypes coreTypes = new CoreTypes(component); - ConstantsBackend constantsBackend = - target.backendTarget.constantsBackend; ClassHierarchy hierarchy = new ClassHierarchy(component, coreTypes); TypeEnvironment environment = new TypeEnvironment(coreTypes, hierarchy); if (verbose) { @@ -91,8 +79,9 @@ void benchmark(Component component, List libraries) { stopwatch.reset(); constants.transformLibraries( + component, component.libraries, - constantsBackend, + target.backendTarget, environmentDefines, environment, new SilentErrorReporter(), diff --git a/pkg/front_end/test/fasta/generator_to_string_test.dart b/pkg/front_end/test/fasta/generator_to_string_test.dart index f4790b9ad08..787ad86e8c0 100644 --- a/pkg/front_end/test/fasta/generator_to_string_test.dart +++ b/pkg/front_end/test/fasta/generator_to_string_test.dart @@ -94,7 +94,8 @@ Future main() async { new DillTarget(c.options.ticker, uriTranslator, new NoneTarget(new TargetFlags())), uriTranslator) - .loader); + .loader, + isUnsupported: false); libraryBuilder.markLanguageVersionFinal(); LoadLibraryBuilder loadLibraryBuilder = new LoadLibraryBuilder(libraryBuilder, dummyLibraryDependency, -1); diff --git a/pkg/front_end/test/fasta/testing/suite.dart b/pkg/front_end/test/fasta/testing/suite.dart index f7221fd8689..2c4da283955 100644 --- a/pkg/front_end/test/fasta/testing/suite.dart +++ b/pkg/front_end/test/fasta/testing/suite.dart @@ -5,91 +5,63 @@ library fasta.testing.suite; import 'dart:convert' show jsonDecode, utf8; - import 'dart:io' show Directory, File, Platform; - import 'dart:typed_data' show Uint8List; import 'package:_fe_analyzer_shared/src/scanner/token.dart' show LanguageVersionToken, Token; - import 'package:_fe_analyzer_shared/src/util/colors.dart' as colors; import 'package:_fe_analyzer_shared/src/util/libraries_specification.dart' show LibraryInfo; import 'package:_fe_analyzer_shared/src/util/options.dart'; import 'package:compiler/src/kernel/dart2js_target.dart'; import 'package:dev_compiler/src/kernel/target.dart'; - import 'package:front_end/src/api_prototype/compiler_options.dart' show CompilerOptions, DiagnosticMessage, parseExperimentalArguments, parseExperimentalFlags; - import 'package:front_end/src/api_prototype/constant_evaluator.dart' show ConstantEvaluator, ErrorReporter, EvaluationMode; - import 'package:front_end/src/api_prototype/experimental_flags.dart' show AllowedExperimentalFlags, ExperimentalFlag, defaultAllowedExperimentalFlags, isExperimentEnabled; - import 'package:front_end/src/api_prototype/file_system.dart' show FileSystem, FileSystemEntity, FileSystemException; - import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart' show IncrementalCompilerResult; - import 'package:front_end/src/api_prototype/standard_file_system.dart' show StandardFileSystem; - +import 'package:front_end/src/base/command_line_options.dart'; +import 'package:front_end/src/base/nnbd_mode.dart' show NnbdMode; import 'package:front_end/src/base/processed_options.dart' show ProcessedOptions; - import 'package:front_end/src/compute_platform_binaries_location.dart' show computePlatformBinariesLocation, computePlatformDillName; - -import 'package:front_end/src/base/command_line_options.dart'; - -import 'package:front_end/src/base/nnbd_mode.dart' show NnbdMode; - import 'package:front_end/src/fasta/builder/library_builder.dart' show LibraryBuilder; - import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; - import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; - import 'package:front_end/src/fasta/incremental_compiler.dart' show IncrementalCompiler; - import 'package:front_end/src/fasta/kernel/hierarchy/hierarchy_builder.dart' show ClassHierarchyBuilder; - import 'package:front_end/src/fasta/kernel/hierarchy/hierarchy_node.dart' show ClassHierarchyNode; - import 'package:front_end/src/fasta/kernel/kernel_target.dart' show KernelTarget; - import 'package:front_end/src/fasta/kernel/utils.dart' show ByteSink; - -import 'package:front_end/src/fasta/messages.dart' show LocatedMessage; - -import 'package:front_end/src/fasta/ticker.dart' show Ticker; - -import 'package:front_end/src/fasta/uri_translator.dart' show UriTranslator; - import 'package:front_end/src/fasta/kernel/verifier.dart' show verifyComponent; - +import 'package:front_end/src/fasta/messages.dart' show LocatedMessage; +import 'package:front_end/src/fasta/ticker.dart' show Ticker; +import 'package:front_end/src/fasta/uri_translator.dart' show UriTranslator; import 'package:front_end/src/fasta/util/parser_ast.dart' show ParserAstVisitor, getAST; - import 'package:front_end/src/fasta/util/parser_ast_helper.dart'; - import 'package:kernel/ast.dart' show AwaitExpression, @@ -111,24 +83,16 @@ import 'package:kernel/ast.dart' Version, Visitor, VisitorVoidMixin; - import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter; - import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; - import 'package:kernel/core_types.dart' show CoreTypes; - import 'package:kernel/kernel.dart' show RecursiveResultVisitor, loadComponentFromBytes; - import 'package:kernel/reference_from_index.dart' show ReferenceFromIndex; - import 'package:kernel/target/changed_structure_notifier.dart' show ChangedStructureNotifier; - import 'package:kernel/target/targets.dart' show - ConstantsBackend, DiagnosticReporter, NoneConstantsBackend, NoneTarget, @@ -137,10 +101,8 @@ import 'package:kernel/target/targets.dart' TestTargetFlags, TestTargetMixin, TestTargetWrapper; - import 'package:kernel/type_environment.dart' show StaticTypeContext, TypeEnvironment; - import 'package:testing/testing.dart' show Chain, @@ -151,11 +113,9 @@ import 'package:testing/testing.dart' Step, TestDescription, StdioProcess; - import 'package:vm/target/vm.dart' show VmTarget; import '../../testing_utils.dart' show checkEnvironment; - import '../../utils/kernel_chain.dart' show ComponentResult, @@ -165,7 +125,6 @@ import '../../utils/kernel_chain.dart' Print, TypeCheck, WriteDill; - import '../../utils/validating_instrumentation.dart' show ValidatingInstrumentation; @@ -901,12 +860,12 @@ class StressConstantEvaluatorStep Future> run( ComponentResult result, FastaContext context) { KernelTarget target = result.sourceTarget; - ConstantsBackend constantsBackend = target.backendTarget.constantsBackend; TypeEnvironment environment = new TypeEnvironment(target.loader.coreTypes, target.loader.hierarchy); StressConstantEvaluatorVisitor stressConstantEvaluatorVisitor = new StressConstantEvaluatorVisitor( - constantsBackend, + target.backendTarget, + result.component, result.options.environmentDefines, target.isExperimentEnabledGlobally(ExperimentalFlag.tripleShift), environment, @@ -937,7 +896,8 @@ class StressConstantEvaluatorVisitor extends RecursiveResultVisitor List output = []; StressConstantEvaluatorVisitor( - ConstantsBackend backend, + Target target, + Component component, Map? environmentDefines, bool enableTripleShift, TypeEnvironment typeEnvironment, @@ -945,12 +905,22 @@ class StressConstantEvaluatorVisitor extends RecursiveResultVisitor bool errorOnUnevaluatedConstant, EvaluationMode evaluationMode) { constantEvaluator = new ConstantEvaluator( - backend, environmentDefines, typeEnvironment, this, + target.dartLibrarySupport, + target.constantsBackend, + component, + environmentDefines, + typeEnvironment, + this, enableTripleShift: enableTripleShift, errorOnUnevaluatedConstant: errorOnUnevaluatedConstant, evaluationMode: evaluationMode); constantEvaluatorWithEmptyEnvironment = new ConstantEvaluator( - backend, {}, typeEnvironment, this, + target.dartLibrarySupport, + target.constantsBackend, + component, + {}, + typeEnvironment, + this, enableTripleShift: enableTripleShift, errorOnUnevaluatedConstant: errorOnUnevaluatedConstant, evaluationMode: evaluationMode); @@ -990,7 +960,7 @@ class StressConstantEvaluatorVisitor extends RecursiveResultVisitor } } if (!evaluate) return node; - if (constantEvaluator.environmentDefines != null) { + if (constantEvaluator.hasEnvironment) { throw "Unexpected UnevaluatedConstant " "when the environment is not null."; } @@ -1010,7 +980,7 @@ class StressConstantEvaluatorVisitor extends RecursiveResultVisitor bool evaluatedWithEmptyEnvironment = false; if (x is UnevaluatedConstant && x.expression is! InvalidExpression) { // try with an environment - if (constantEvaluator.environmentDefines != null) { + if (constantEvaluator.hasEnvironment) { throw "Unexpected UnevaluatedConstant (with an InvalidExpression in " "it) when the environment is not null."; } @@ -1760,6 +1730,8 @@ Target createTarget(FolderOptions folderOptions, FastaContext context) { forceConstructorTearOffLoweringForTesting: folderOptions.forceConstructorTearOffLowering, enableNullSafety: context.soundNullSafety, + supportedDartLibraries: {'_supported.by.target'}, + unsupportedDartLibraries: {'unsupported.by.target'}, ); Target target; switch (folderOptions.target) { diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt index 8b9b65b4047..7cfd23ad122 100644 --- a/pkg/front_end/test/spell_checking_list_code.txt +++ b/pkg/front_end/test/spell_checking_list_code.txt @@ -688,6 +688,7 @@ jakemac java jenkins jensj +jit job johnniwinther js diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart b/pkg/front_end/testcases/dart2js/conditional_import.dart index 61224510565..58ccbe77fc8 100644 --- a/pkg/front_end/testcases/dart2js/conditional_import.dart +++ b/pkg/front_end/testcases/dart2js/conditional_import.dart @@ -8,7 +8,11 @@ import "conditional_import.dart" if (dart.library.html) "dart:html" as a; // All three libraries have an HttpRequest class. -import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b; +import "conditional_import.dart" + if (dart.library.html) "dart:html" + if (dart.library.io) "dart:io" as b; + +import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c; class HttpRequest {} @@ -20,6 +24,13 @@ testA(a.HttpRequest request) { } testB(b.HttpRequest request) { + request.certificate; // error (from dart:io) + request.response; // ok (from dart:io and dart:html) + request.readyState; // ok (from dart:html) + request.hashCode; // ok +} + +testC(c.HttpRequest request) { request.certificate; // error request.response; // error request.readyState; // error diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.expect index 5f33ec12d1d..560176d068f 100644 --- a/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.expect +++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. -// - 'HttpRequest' is from 'dart:_http'. -// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. -// request.readyState; // ok (from dart:html) -// ^^^^^^^^^^ +// pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ +// +// pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -28,11 +34,12 @@ library /*isNonNullableByDefault*/; // import self as self; import "dart:core" as core; -import "dart:_http" as _ht; -import "dart:io" as io; +import "dart:html" as html; +import "dart:_interceptors" as _in; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -41,28 +48,38 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic { - request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; - request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - - 'HttpRequest' is from 'dart:_http'. -Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. - request.readyState; // ok (from dart:html) - ^^^^^^^^^^" in request{}.readyState; - request.{core::Object::hashCode}{core::int}; +static method testA(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{_in::Interceptor::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{_in::Interceptor::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -71,7 +88,7 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(false, #C1); - self::expect(true, #C1); + self::expect(true, #C2); self::expect(false, #C1); } static method expect(dynamic expected, dynamic actual) → dynamic { @@ -81,4 +98,5 @@ static method expect(dynamic expected, dynamic actual) → dynamic { constants { #C1 = false + #C2 = true } diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.transformed.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.transformed.expect index 5f33ec12d1d..560176d068f 100644 --- a/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.transformed.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. -// - 'HttpRequest' is from 'dart:_http'. -// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. -// request.readyState; // ok (from dart:html) -// ^^^^^^^^^^ +// pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ +// +// pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -28,11 +34,12 @@ library /*isNonNullableByDefault*/; // import self as self; import "dart:core" as core; -import "dart:_http" as _ht; -import "dart:io" as io; +import "dart:html" as html; +import "dart:_interceptors" as _in; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -41,28 +48,38 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic { - request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; - request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - - 'HttpRequest' is from 'dart:_http'. -Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. - request.readyState; // ok (from dart:html) - ^^^^^^^^^^" in request{}.readyState; - request.{core::Object::hashCode}{core::int}; +static method testA(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{_in::Interceptor::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{_in::Interceptor::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -71,7 +88,7 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(false, #C1); - self::expect(true, #C1); + self::expect(true, #C2); self::expect(false, #C1); } static method expect(dynamic expected, dynamic actual) → dynamic { @@ -81,4 +98,5 @@ static method expect(dynamic expected, dynamic actual) → dynamic { constants { #C1 = false + #C2 = true } diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline.expect index dc1072741fe..a62da80b3d2 100644 --- a/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline.expect +++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline.expect @@ -1,11 +1,15 @@ import "conditional_import.dart" if (dart.library.io) "dart:io" if (dart.library.html) "dart:html" as a; -import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b; +import "conditional_import.dart" + if (dart.library.html) "dart:html" + if (dart.library.io) "dart:io" as b; +import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c; class HttpRequest {} testA(a.HttpRequest request) {} testB(b.HttpRequest request) {} +testC(c.HttpRequest request) {} void main() {} expect(expected, actual) {} diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline_modelled.expect index 6e90f3d3e27..7af9c6fc6c5 100644 --- a/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline_modelled.expect +++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline_modelled.expect @@ -1,4 +1,7 @@ -import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b; +import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c; +import "conditional_import.dart" + if (dart.library.html) "dart:html" + if (dart.library.io) "dart:io" as b; import "conditional_import.dart" if (dart.library.io) "dart:io" if (dart.library.html) "dart:html" as a; @@ -8,4 +11,5 @@ class HttpRequest {} expect(expected, actual) {} testA(a.HttpRequest request) {} testB(b.HttpRequest request) {} +testC(c.HttpRequest request) {} void main() {} diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.expect index 5f33ec12d1d..560176d068f 100644 --- a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.expect +++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. -// - 'HttpRequest' is from 'dart:_http'. -// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. -// request.readyState; // ok (from dart:html) -// ^^^^^^^^^^ +// pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ +// +// pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -28,11 +34,12 @@ library /*isNonNullableByDefault*/; // import self as self; import "dart:core" as core; -import "dart:_http" as _ht; -import "dart:io" as io; +import "dart:html" as html; +import "dart:_interceptors" as _in; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -41,28 +48,38 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic { - request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; - request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - - 'HttpRequest' is from 'dart:_http'. -Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. - request.readyState; // ok (from dart:html) - ^^^^^^^^^^" in request{}.readyState; - request.{core::Object::hashCode}{core::int}; +static method testA(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{_in::Interceptor::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{_in::Interceptor::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -71,7 +88,7 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(false, #C1); - self::expect(true, #C1); + self::expect(true, #C2); self::expect(false, #C1); } static method expect(dynamic expected, dynamic actual) → dynamic { @@ -81,4 +98,5 @@ static method expect(dynamic expected, dynamic actual) → dynamic { constants { #C1 = false + #C2 = true } diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.modular.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.modular.expect index 5f33ec12d1d..560176d068f 100644 --- a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.modular.expect +++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.modular.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. -// - 'HttpRequest' is from 'dart:_http'. -// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. -// request.readyState; // ok (from dart:html) -// ^^^^^^^^^^ +// pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ +// +// pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -28,11 +34,12 @@ library /*isNonNullableByDefault*/; // import self as self; import "dart:core" as core; -import "dart:_http" as _ht; -import "dart:io" as io; +import "dart:html" as html; +import "dart:_interceptors" as _in; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -41,28 +48,38 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic { - request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; - request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - - 'HttpRequest' is from 'dart:_http'. -Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. - request.readyState; // ok (from dart:html) - ^^^^^^^^^^" in request{}.readyState; - request.{core::Object::hashCode}{core::int}; +static method testA(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{_in::Interceptor::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{_in::Interceptor::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -71,7 +88,7 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(false, #C1); - self::expect(true, #C1); + self::expect(true, #C2); self::expect(false, #C1); } static method expect(dynamic expected, dynamic actual) → dynamic { @@ -81,4 +98,5 @@ static method expect(dynamic expected, dynamic actual) → dynamic { constants { #C1 = false + #C2 = true } diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.outline.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.outline.expect index 8e7ea0fbe1a..b5be69ac5b9 100644 --- a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.outline.expect +++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.outline.expect @@ -1,10 +1,11 @@ library /*isNonNullableByDefault*/; import self as self; import "dart:core" as core; -import "dart:_http" as _ht; +import "dart:html" as html; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -12,9 +13,11 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic +static method testA(html::HttpRequest request) → dynamic ; -static method testB(self::HttpRequest request) → dynamic +static method testB(html::HttpRequest request) → dynamic + ; +static method testC(self::HttpRequest request) → dynamic ; static method main() → void ; diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.transformed.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.transformed.expect index 5f33ec12d1d..560176d068f 100644 --- a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.transformed.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. -// - 'HttpRequest' is from 'dart:_http'. -// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. -// request.readyState; // ok (from dart:html) -// ^^^^^^^^^^ +// pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ +// +// pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -28,11 +34,12 @@ library /*isNonNullableByDefault*/; // import self as self; import "dart:core" as core; -import "dart:_http" as _ht; -import "dart:io" as io; +import "dart:html" as html; +import "dart:_interceptors" as _in; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -41,28 +48,38 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic { - request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; - request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - - 'HttpRequest' is from 'dart:_http'. -Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. - request.readyState; // ok (from dart:html) - ^^^^^^^^^^" in request{}.readyState; - request.{core::Object::hashCode}{core::int}; +static method testA(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{_in::Interceptor::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{_in::Interceptor::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -71,7 +88,7 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(false, #C1); - self::expect(true, #C1); + self::expect(true, #C2); self::expect(false, #C1); } static method expect(dynamic expected, dynamic actual) → dynamic { @@ -81,4 +98,5 @@ static method expect(dynamic expected, dynamic actual) → dynamic { constants { #C1 = false + #C2 = true } diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart b/pkg/front_end/testcases/dartdevc/conditional_import.dart index 61224510565..58ccbe77fc8 100644 --- a/pkg/front_end/testcases/dartdevc/conditional_import.dart +++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart @@ -8,7 +8,11 @@ import "conditional_import.dart" if (dart.library.html) "dart:html" as a; // All three libraries have an HttpRequest class. -import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b; +import "conditional_import.dart" + if (dart.library.html) "dart:html" + if (dart.library.io) "dart:io" as b; + +import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c; class HttpRequest {} @@ -20,6 +24,13 @@ testA(a.HttpRequest request) { } testB(b.HttpRequest request) { + request.certificate; // error (from dart:io) + request.response; // ok (from dart:io and dart:html) + request.readyState; // ok (from dart:html) + request.hashCode; // ok +} + +testC(c.HttpRequest request) { request.certificate; // error request.response; // error request.readyState; // error diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.expect index 3b668f735de..efcac9a64fe 100644 --- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.expect +++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. -// - 'HttpRequest' is from 'dart:_http'. -// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. -// request.readyState; // ok (from dart:html) -// ^^^^^^^^^^ +// pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ +// +// pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -28,11 +34,11 @@ library /*isNonNullableByDefault*/; // import self as self; import "dart:core" as core; -import "dart:_http" as _ht; -import "dart:io" as io; +import "dart:html" as html; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -41,28 +47,38 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic { - request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; - request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - - 'HttpRequest' is from 'dart:_http'. -Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. - request.readyState; // ok (from dart:html) - ^^^^^^^^^^" in request{}.readyState; +static method testA(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; request.{core::Object::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{core::Object::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -71,7 +87,7 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(false, #C1); - self::expect(true, #C1); + self::expect(true, #C2); self::expect(false, #C1); } static method expect(dynamic expected, dynamic actual) → dynamic { @@ -81,4 +97,5 @@ static method expect(dynamic expected, dynamic actual) → dynamic { constants { #C1 = false + #C2 = true } diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.transformed.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.transformed.expect index 3b668f735de..efcac9a64fe 100644 --- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.transformed.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. -// - 'HttpRequest' is from 'dart:_http'. -// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. -// request.readyState; // ok (from dart:html) -// ^^^^^^^^^^ +// pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ +// +// pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -28,11 +34,11 @@ library /*isNonNullableByDefault*/; // import self as self; import "dart:core" as core; -import "dart:_http" as _ht; -import "dart:io" as io; +import "dart:html" as html; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -41,28 +47,38 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic { - request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; - request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - - 'HttpRequest' is from 'dart:_http'. -Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. - request.readyState; // ok (from dart:html) - ^^^^^^^^^^" in request{}.readyState; +static method testA(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; request.{core::Object::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{core::Object::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -71,7 +87,7 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(false, #C1); - self::expect(true, #C1); + self::expect(true, #C2); self::expect(false, #C1); } static method expect(dynamic expected, dynamic actual) → dynamic { @@ -81,4 +97,5 @@ static method expect(dynamic expected, dynamic actual) → dynamic { constants { #C1 = false + #C2 = true } diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline.expect index dc1072741fe..a62da80b3d2 100644 --- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline.expect +++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline.expect @@ -1,11 +1,15 @@ import "conditional_import.dart" if (dart.library.io) "dart:io" if (dart.library.html) "dart:html" as a; -import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b; +import "conditional_import.dart" + if (dart.library.html) "dart:html" + if (dart.library.io) "dart:io" as b; +import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c; class HttpRequest {} testA(a.HttpRequest request) {} testB(b.HttpRequest request) {} +testC(c.HttpRequest request) {} void main() {} expect(expected, actual) {} diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline_modelled.expect index 6e90f3d3e27..7af9c6fc6c5 100644 --- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline_modelled.expect +++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline_modelled.expect @@ -1,4 +1,7 @@ -import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b; +import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c; +import "conditional_import.dart" + if (dart.library.html) "dart:html" + if (dart.library.io) "dart:io" as b; import "conditional_import.dart" if (dart.library.io) "dart:io" if (dart.library.html) "dart:html" as a; @@ -8,4 +11,5 @@ class HttpRequest {} expect(expected, actual) {} testA(a.HttpRequest request) {} testB(b.HttpRequest request) {} +testC(c.HttpRequest request) {} void main() {} diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.expect index 3b668f735de..efcac9a64fe 100644 --- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.expect +++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. -// - 'HttpRequest' is from 'dart:_http'. -// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. -// request.readyState; // ok (from dart:html) -// ^^^^^^^^^^ +// pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ +// +// pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -28,11 +34,11 @@ library /*isNonNullableByDefault*/; // import self as self; import "dart:core" as core; -import "dart:_http" as _ht; -import "dart:io" as io; +import "dart:html" as html; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -41,28 +47,38 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic { - request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; - request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - - 'HttpRequest' is from 'dart:_http'. -Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. - request.readyState; // ok (from dart:html) - ^^^^^^^^^^" in request{}.readyState; +static method testA(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; request.{core::Object::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{core::Object::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -71,7 +87,7 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(false, #C1); - self::expect(true, #C1); + self::expect(true, #C2); self::expect(false, #C1); } static method expect(dynamic expected, dynamic actual) → dynamic { @@ -81,4 +97,5 @@ static method expect(dynamic expected, dynamic actual) → dynamic { constants { #C1 = false + #C2 = true } diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.modular.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.modular.expect index 3b668f735de..efcac9a64fe 100644 --- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.modular.expect +++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.modular.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. -// - 'HttpRequest' is from 'dart:_http'. -// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. -// request.readyState; // ok (from dart:html) -// ^^^^^^^^^^ +// pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ +// +// pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -28,11 +34,11 @@ library /*isNonNullableByDefault*/; // import self as self; import "dart:core" as core; -import "dart:_http" as _ht; -import "dart:io" as io; +import "dart:html" as html; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -41,28 +47,38 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic { - request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; - request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - - 'HttpRequest' is from 'dart:_http'. -Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. - request.readyState; // ok (from dart:html) - ^^^^^^^^^^" in request{}.readyState; +static method testA(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; request.{core::Object::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{core::Object::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -71,7 +87,7 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(false, #C1); - self::expect(true, #C1); + self::expect(true, #C2); self::expect(false, #C1); } static method expect(dynamic expected, dynamic actual) → dynamic { @@ -81,4 +97,5 @@ static method expect(dynamic expected, dynamic actual) → dynamic { constants { #C1 = false + #C2 = true } diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.outline.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.outline.expect index 8e7ea0fbe1a..b5be69ac5b9 100644 --- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.outline.expect +++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.outline.expect @@ -1,10 +1,11 @@ library /*isNonNullableByDefault*/; import self as self; import "dart:core" as core; -import "dart:_http" as _ht; +import "dart:html" as html; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -12,9 +13,11 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic +static method testA(html::HttpRequest request) → dynamic ; -static method testB(self::HttpRequest request) → dynamic +static method testB(html::HttpRequest request) → dynamic + ; +static method testC(self::HttpRequest request) → dynamic ; static method main() → void ; diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.transformed.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.transformed.expect index 3b668f735de..efcac9a64fe 100644 --- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.transformed.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. -// - 'HttpRequest' is from 'dart:_http'. -// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. -// request.readyState; // ok (from dart:html) -// ^^^^^^^^^^ +// pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:html'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. +// request.certificate; // error (from dart:io) +// ^^^^^^^^^^^ +// +// pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -28,11 +34,11 @@ library /*isNonNullableByDefault*/; // import self as self; import "dart:core" as core; -import "dart:_http" as _ht; -import "dart:io" as io; +import "dart:html" as html; -import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:html" as a; +import "dart:html" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -41,28 +47,38 @@ class HttpRequest extends core::Object { static method _#new#tearOff() → self::HttpRequest return new self::HttpRequest::•(); } -static method testA(_ht::HttpRequest request) → dynamic { - request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; - request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - - 'HttpRequest' is from 'dart:_http'. -Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. - request.readyState; // ok (from dart:html) - ^^^^^^^^^^" in request{}.readyState; +static method testA(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; request.{core::Object::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(html::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:html'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. + request.certificate; // error (from dart:io) + ^^^^^^^^^^^" in request{}.certificate; + request.{html::HttpRequest::response}{dynamic}; + request.{html::HttpRequest::readyState}{core::int}; + request.{core::Object::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -71,7 +87,7 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(false, #C1); - self::expect(true, #C1); + self::expect(true, #C2); self::expect(false, #C1); } static method expect(dynamic expected, dynamic actual) → dynamic { @@ -81,4 +97,5 @@ static method expect(dynamic expected, dynamic actual) → dynamic { constants { #C1 = false + #C2 = true } diff --git a/pkg/front_end/testcases/general/conditional_import.dart b/pkg/front_end/testcases/general/conditional_import.dart index 067c7845a0f..648ea9b8e99 100644 --- a/pkg/front_end/testcases/general/conditional_import.dart +++ b/pkg/front_end/testcases/general/conditional_import.dart @@ -8,7 +8,11 @@ import "conditional_import.dart" if (dart.library.html) "dart:html" as a; // All three libraries have an HttpRequest class. -import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b; +import "conditional_import.dart" + if (dart.library.html) "dart:html" + if (dart.library.io) "dart:io" as b; + +import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c; class HttpRequest {} @@ -20,6 +24,13 @@ testA(a.HttpRequest request) { } testB(b.HttpRequest request) { + request.certificate; // ok (from dart:io) + request.response; // ok (from dart:io and dart:html) + request.readyState; // error (from dart:html) + request.hashCode; // ok +} + +testC(c.HttpRequest request) { request.certificate; // error request.response; // error request.readyState; // error diff --git a/pkg/front_end/testcases/general/conditional_import.dart.textual_outline.expect b/pkg/front_end/testcases/general/conditional_import.dart.textual_outline.expect index dc1072741fe..a62da80b3d2 100644 --- a/pkg/front_end/testcases/general/conditional_import.dart.textual_outline.expect +++ b/pkg/front_end/testcases/general/conditional_import.dart.textual_outline.expect @@ -1,11 +1,15 @@ import "conditional_import.dart" if (dart.library.io) "dart:io" if (dart.library.html) "dart:html" as a; -import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b; +import "conditional_import.dart" + if (dart.library.html) "dart:html" + if (dart.library.io) "dart:io" as b; +import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c; class HttpRequest {} testA(a.HttpRequest request) {} testB(b.HttpRequest request) {} +testC(c.HttpRequest request) {} void main() {} expect(expected, actual) {} diff --git a/pkg/front_end/testcases/general/conditional_import.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/conditional_import.dart.textual_outline_modelled.expect index 6e90f3d3e27..7af9c6fc6c5 100644 --- a/pkg/front_end/testcases/general/conditional_import.dart.textual_outline_modelled.expect +++ b/pkg/front_end/testcases/general/conditional_import.dart.textual_outline_modelled.expect @@ -1,4 +1,7 @@ -import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b; +import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c; +import "conditional_import.dart" + if (dart.library.html) "dart:html" + if (dart.library.io) "dart:io" as b; import "conditional_import.dart" if (dart.library.io) "dart:io" if (dart.library.html) "dart:html" as a; @@ -8,4 +11,5 @@ class HttpRequest {} expect(expected, actual) {} testA(a.HttpRequest request) {} testB(b.HttpRequest request) {} +testC(c.HttpRequest request) {} void main() {} diff --git a/pkg/front_end/testcases/general/conditional_import.dart.weak.expect b/pkg/front_end/testcases/general/conditional_import.dart.weak.expect index 0ae3432d4cd..00999c9078b 100644 --- a/pkg/front_end/testcases/general/conditional_import.dart.weak.expect +++ b/pkg/front_end/testcases/general/conditional_import.dart.weak.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'dart:_http'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error (from dart:html) // ^^^^^^^^^^ // -// pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:_http'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. +// request.readyState; // error (from dart:html) +// ^^^^^^^^^^ +// +// pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -32,7 +38,8 @@ import "dart:_http" as _ht; import "dart:io" as io; import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:io" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -42,25 +49,35 @@ class HttpRequest extends core::Object { static method testA(_ht::HttpRequest request) → dynamic { request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'dart:_http'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error (from dart:html) ^^^^^^^^^^" in request{}.readyState; request.{core::Object::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(_ht::HttpRequest request) → dynamic { + request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; + request.{_ht::HttpRequest::response}{_ht::HttpResponse}; + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:_http'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. + request.readyState; // error (from dart:html) + ^^^^^^^^^^" in request{}.readyState; + request.{core::Object::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -69,8 +86,8 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(true, #C1); - self::expect(false, #C1); - self::expect(false, #C1); + self::expect(false, #C2); + self::expect(false, #C2); } static method expect(dynamic expected, dynamic actual) → dynamic { if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual)) @@ -78,5 +95,6 @@ static method expect(dynamic expected, dynamic actual) → dynamic { } constants { - #C1 = false + #C1 = true + #C2 = false } diff --git a/pkg/front_end/testcases/general/conditional_import.dart.weak.modular.expect b/pkg/front_end/testcases/general/conditional_import.dart.weak.modular.expect index 0ae3432d4cd..00999c9078b 100644 --- a/pkg/front_end/testcases/general/conditional_import.dart.weak.modular.expect +++ b/pkg/front_end/testcases/general/conditional_import.dart.weak.modular.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'dart:_http'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error (from dart:html) // ^^^^^^^^^^ // -// pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:_http'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. +// request.readyState; // error (from dart:html) +// ^^^^^^^^^^ +// +// pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -32,7 +38,8 @@ import "dart:_http" as _ht; import "dart:io" as io; import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:io" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -42,25 +49,35 @@ class HttpRequest extends core::Object { static method testA(_ht::HttpRequest request) → dynamic { request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'dart:_http'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error (from dart:html) ^^^^^^^^^^" in request{}.readyState; request.{core::Object::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(_ht::HttpRequest request) → dynamic { + request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; + request.{_ht::HttpRequest::response}{_ht::HttpResponse}; + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:_http'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. + request.readyState; // error (from dart:html) + ^^^^^^^^^^" in request{}.readyState; + request.{core::Object::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -69,8 +86,8 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(true, #C1); - self::expect(false, #C1); - self::expect(false, #C1); + self::expect(false, #C2); + self::expect(false, #C2); } static method expect(dynamic expected, dynamic actual) → dynamic { if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual)) @@ -78,5 +95,6 @@ static method expect(dynamic expected, dynamic actual) → dynamic { } constants { - #C1 = false + #C1 = true + #C2 = false } diff --git a/pkg/front_end/testcases/general/conditional_import.dart.weak.outline.expect b/pkg/front_end/testcases/general/conditional_import.dart.weak.outline.expect index 17e396c0d75..98d76441bdb 100644 --- a/pkg/front_end/testcases/general/conditional_import.dart.weak.outline.expect +++ b/pkg/front_end/testcases/general/conditional_import.dart.weak.outline.expect @@ -4,7 +4,8 @@ import "dart:core" as core; import "dart:_http" as _ht; import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:io" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -12,7 +13,9 @@ class HttpRequest extends core::Object { } static method testA(_ht::HttpRequest request) → dynamic ; -static method testB(self::HttpRequest request) → dynamic +static method testB(_ht::HttpRequest request) → dynamic + ; +static method testC(self::HttpRequest request) → dynamic ; static method main() → void ; diff --git a/pkg/front_end/testcases/general/conditional_import.dart.weak.transformed.expect b/pkg/front_end/testcases/general/conditional_import.dart.weak.transformed.expect index 0ae3432d4cd..00999c9078b 100644 --- a/pkg/front_end/testcases/general/conditional_import.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/general/conditional_import.dart.weak.transformed.expect @@ -2,25 +2,31 @@ library /*isNonNullableByDefault*/; // // Problems in library: // -// pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'dart:_http'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error (from dart:html) // ^^^^^^^^^^ // -// pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// - 'HttpRequest' is from 'dart:_http'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. +// request.readyState; // error (from dart:html) +// ^^^^^^^^^^ +// +// pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. // request.certificate; // error // ^^^^^^^^^^^ // -// pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. // request.response; // error // ^^^^^^^^ // -// pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. +// pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. // - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. // Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. // request.readyState; // error @@ -32,7 +38,8 @@ import "dart:_http" as _ht; import "dart:io" as io; import "dart:io" as a; -import "org-dartlang-testcase:///conditional_import.dart" as b; +import "dart:io" as b; +import "org-dartlang-testcase:///conditional_import.dart" as c; class HttpRequest extends core::Object { synthetic constructor •() → self::HttpRequest @@ -42,25 +49,35 @@ class HttpRequest extends core::Object { static method testA(_ht::HttpRequest request) → dynamic { request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; request.{_ht::HttpRequest::response}{_ht::HttpResponse}; - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'dart:_http'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error (from dart:html) ^^^^^^^^^^" in request{}.readyState; request.{core::Object::hashCode}{core::int}; } -static method testB(self::HttpRequest request) → dynamic { - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. +static method testB(_ht::HttpRequest request) → dynamic { + request.{_ht::HttpRequest::certificate}{io::X509Certificate?}; + request.{_ht::HttpRequest::response}{_ht::HttpResponse}; + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + - 'HttpRequest' is from 'dart:_http'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. + request.readyState; // error (from dart:html) + ^^^^^^^^^^" in request{}.readyState; + request.{core::Object::hashCode}{core::int}; +} +static method testC(self::HttpRequest request) → dynamic { + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'. request.certificate; // error ^^^^^^^^^^^" in request{}.certificate; - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'. request.response; // error ^^^^^^^^" in request{}.response; - invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. + invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'. - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'. request.readyState; // error @@ -69,8 +86,8 @@ Try correcting the name to the name of an existing getter, or defining a getter } static method main() → void { self::expect(true, #C1); - self::expect(false, #C1); - self::expect(false, #C1); + self::expect(false, #C2); + self::expect(false, #C2); } static method expect(dynamic expected, dynamic actual) → dynamic { if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual)) @@ -78,5 +95,6 @@ static method expect(dynamic expected, dynamic actual) → dynamic { } constants { - #C1 = false + #C1 = true + #C2 = false } diff --git a/pkg/front_end/testcases/general/supported_libraries/import_default_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_default_lib.dart new file mode 100644 index 00000000000..00ee7692644 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/import_default_lib.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2022, 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. + +String field = 'default'; diff --git a/pkg/front_end/testcases/general/supported_libraries/import_supported.by.spec_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_supported.by.spec_lib.dart new file mode 100644 index 00000000000..1c3a6c71716 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/import_supported.by.spec_lib.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2022, 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. + +String field = 'supported.by.spec'; diff --git a/pkg/front_end/testcases/general/supported_libraries/import_supported.by.target_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_supported.by.target_lib.dart new file mode 100644 index 00000000000..36d5727c331 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/import_supported.by.target_lib.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2022, 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. + +String field = 'supported.by.target'; diff --git a/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_internal_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_internal_lib.dart new file mode 100644 index 00000000000..27ca30346e3 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_internal_lib.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2022, 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. + +String field = 'unsupported.by.spec_internal'; diff --git a/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_lib.dart new file mode 100644 index 00000000000..3b9f7f276bf --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_lib.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2022, 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. + +String field = 'unsupported.by.spec'; diff --git a/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.target_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.target_lib.dart new file mode 100644 index 00000000000..d0216e75d11 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.target_lib.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2022, 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. + +String field = 'unsupported.by.target'; diff --git a/pkg/front_end/testcases/general/supported_libraries/libraries.json b/pkg/front_end/testcases/general/supported_libraries/libraries.json new file mode 100644 index 00000000000..13d244b84ac --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/libraries.json @@ -0,0 +1,23 @@ +{ + "none": { + "libraries": { + "supported.by.spec": { + "uri": "supported.by.spec_lib.dart" + }, + "_supported.by.target": { + "uri": "supported.by.target_lib.dart" + }, + "unsupported.by.spec": { + "uri": "unsupported.by.spec_lib.dart", + "supported": false + }, + "unsupported.by.target": { + "uri": "unsupported.by.target_lib.dart", + "supported": true + }, + "_unsupported.by.spec_internal": { + "uri": "unsupported.by.spec_internal_lib.dart" + } + } + } +} diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart b/pkg/front_end/testcases/general/supported_libraries/main.dart new file mode 100644 index 00000000000..0677973621b --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/main.dart @@ -0,0 +1,63 @@ +// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:supported.by.spec'; +import 'dart:unsupported.by.spec'; +import 'dart:unsupported.by.target'; + +import 'import_default_lib.dart' + if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart' + if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart' + if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart' + if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart' + if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart' + as from_supported_by_spec_first; + +import 'import_default_lib.dart' + if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart' + if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart' + if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart' + if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart' + if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart' + as from_supported_by_target; + +import 'import_default_lib.dart' + if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart' + if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart' + if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart' + if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart' + if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart' + as from_supported_by_spec_last; + +main() { + supportedBySpec(); + supportedByTarget(); // Exported through dart:supported.by.spec + unsupportedBySpec(); + unsupportedByTarget(); + unsupportedBySpecInternal(); // Exported through dart:unsupported.by.spec + + expect('supported.by.spec', from_supported_by_spec_first.field); + expect('supported.by.target', from_supported_by_target.field); + expect('supported.by.spec', from_supported_by_spec_last.field); + + // `dart:supported.by.spec` is supported by the libraries specification. + expect(true, const bool.fromEnvironment('dart.library.supported.by.spec')); + // `dart:_supported.by.target` is internal and therefore not supported by + // the libraries specification, but the test target supports it explicitly. + expect(true, const bool.fromEnvironment('dart.library._supported.by.target')); + // `dart:unsupported.by.spec` is unsupported by the libraries specification. + expect(false, const bool.fromEnvironment('dart.library.unsupported.by.spec')); + // `dart:unsupported.by.target` is unsupported by the libraries specification, + // but the test target explicitly marks it as unsupported. + expect( + false, const bool.fromEnvironment('dart.library.unsupported.by.target')); + // `dart:_unsupported.by.spec_internal` is internal and therefore not + // supported by the libraries specification. + expect(false, + const bool.fromEnvironment('dart.library._unsupported.by.spec_internal')); +} + +expect(expected, actual) { + if (expected != actual) throw 'Expected $expected, actual $actual'; +} diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline.expect new file mode 100644 index 00000000000..da8d39f08a0 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline.expect @@ -0,0 +1,27 @@ +import 'dart:supported.by.spec'; +import 'dart:unsupported.by.spec'; +import 'dart:unsupported.by.target'; +import 'import_default_lib.dart' + if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart' + if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart' + if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart' + if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart' + if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart' + as from_supported_by_spec_first; +import 'import_default_lib.dart' + if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart' + if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart' + if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart' + if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart' + if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart' + as from_supported_by_target; +import 'import_default_lib.dart' + if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart' + if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart' + if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart' + if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart' + if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart' + as from_supported_by_spec_last; + +main() {} +expect(expected, actual) {} diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline_modelled.expect new file mode 100644 index 00000000000..29001ab6cf0 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline_modelled.expect @@ -0,0 +1,27 @@ +import 'dart:supported.by.spec'; +import 'dart:unsupported.by.spec'; +import 'dart:unsupported.by.target'; +import 'import_default_lib.dart' + if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart' + if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart' + if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart' + if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart' + if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart' + as from_supported_by_spec_first; +import 'import_default_lib.dart' + if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart' + if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart' + if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart' + if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart' + if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart' + as from_supported_by_target; +import 'import_default_lib.dart' + if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart' + if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart' + if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart' + if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart' + if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart' + as from_supported_by_spec_last; + +expect(expected, actual) {} +main() {} diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.expect new file mode 100644 index 00000000000..85a3cb75f71 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.expect @@ -0,0 +1,87 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "dart:supported.by.spec" as spec; +import "dart:_supported.by.target" as by_; +import "dart:unsupported.by.spec" as spec2; +import "dart:unsupported.by.target" as tar; +import "dart:_unsupported.by.spec_internal" as spe; +import "import_supported.by.spec_lib.dart" as spe2; +import "import_supported.by.target_lib.dart" as tar2; +import "dart:core" as core; + +import "dart:supported.by.spec"; +import "dart:unsupported.by.spec"; +import "dart:unsupported.by.target"; +import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_first; +import "org-dartlang-testcase:///import_supported.by.target_lib.dart" as from_supported_by_target; +import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_last; + +static method main() → dynamic { + spec::supportedBySpec(); + by_::supportedByTarget(); + spec2::unsupportedBySpec(); + tar::unsupportedByTarget(); + spe::unsupportedBySpecInternal(); + self::expect("supported.by.spec", spe2::field); + self::expect("supported.by.target", tar2::field); + self::expect("supported.by.spec", spe2::field); + self::expect(true, #C1); + self::expect(true, #C1); + self::expect(false, #C2); + self::expect(false, #C2); + self::expect(false, #C2); +} +static method expect(dynamic expected, dynamic actual) → dynamic { + if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual)) + throw "Expected ${expected}, actual ${actual}"; +} + +library dart.supported.by.spec /*isNonNullableByDefault*/; +import self as spec; +import "dart:_supported.by.target" as by_; +additionalExports = (by_::supportedByTarget) + +export "dart:_supported.by.target"; + +static method supportedBySpec() → void {} + +library dart.unsupported.by.spec /*isUnsupported,isNonNullableByDefault*/; +import self as spec2; +import "dart:_unsupported.by.spec_internal" as spe; +additionalExports = (spe::unsupportedBySpecInternal) + +export "dart:_unsupported.by.spec_internal"; + +static method unsupportedBySpec() → void {} + +library dart.unsupported.by.target /*isNonNullableByDefault*/; +import self as tar; + +static method unsupportedByTarget() → void {} + +library /*isNonNullableByDefault*/; +import self as spe2; +import "dart:core" as core; + +static field core::String field = "supported.by.spec"; + +library /*isNonNullableByDefault*/; +import self as tar2; +import "dart:core" as core; + +static field core::String field = "supported.by.target"; + +library dart._supported.by_target /*isUnsupported,isNonNullableByDefault*/; +import self as by_; + +static method supportedByTarget() → void {} + +library dart._unsupported.by.spec_internal /*isUnsupported,isNonNullableByDefault*/; +import self as spe; + +static method unsupportedBySpecInternal() → void {} + +constants { + #C1 = true + #C2 = false +} diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.modular.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.modular.expect new file mode 100644 index 00000000000..85a3cb75f71 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.modular.expect @@ -0,0 +1,87 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "dart:supported.by.spec" as spec; +import "dart:_supported.by.target" as by_; +import "dart:unsupported.by.spec" as spec2; +import "dart:unsupported.by.target" as tar; +import "dart:_unsupported.by.spec_internal" as spe; +import "import_supported.by.spec_lib.dart" as spe2; +import "import_supported.by.target_lib.dart" as tar2; +import "dart:core" as core; + +import "dart:supported.by.spec"; +import "dart:unsupported.by.spec"; +import "dart:unsupported.by.target"; +import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_first; +import "org-dartlang-testcase:///import_supported.by.target_lib.dart" as from_supported_by_target; +import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_last; + +static method main() → dynamic { + spec::supportedBySpec(); + by_::supportedByTarget(); + spec2::unsupportedBySpec(); + tar::unsupportedByTarget(); + spe::unsupportedBySpecInternal(); + self::expect("supported.by.spec", spe2::field); + self::expect("supported.by.target", tar2::field); + self::expect("supported.by.spec", spe2::field); + self::expect(true, #C1); + self::expect(true, #C1); + self::expect(false, #C2); + self::expect(false, #C2); + self::expect(false, #C2); +} +static method expect(dynamic expected, dynamic actual) → dynamic { + if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual)) + throw "Expected ${expected}, actual ${actual}"; +} + +library dart.supported.by.spec /*isNonNullableByDefault*/; +import self as spec; +import "dart:_supported.by.target" as by_; +additionalExports = (by_::supportedByTarget) + +export "dart:_supported.by.target"; + +static method supportedBySpec() → void {} + +library dart.unsupported.by.spec /*isUnsupported,isNonNullableByDefault*/; +import self as spec2; +import "dart:_unsupported.by.spec_internal" as spe; +additionalExports = (spe::unsupportedBySpecInternal) + +export "dart:_unsupported.by.spec_internal"; + +static method unsupportedBySpec() → void {} + +library dart.unsupported.by.target /*isNonNullableByDefault*/; +import self as tar; + +static method unsupportedByTarget() → void {} + +library /*isNonNullableByDefault*/; +import self as spe2; +import "dart:core" as core; + +static field core::String field = "supported.by.spec"; + +library /*isNonNullableByDefault*/; +import self as tar2; +import "dart:core" as core; + +static field core::String field = "supported.by.target"; + +library dart._supported.by_target /*isUnsupported,isNonNullableByDefault*/; +import self as by_; + +static method supportedByTarget() → void {} + +library dart._unsupported.by.spec_internal /*isUnsupported,isNonNullableByDefault*/; +import self as spe; + +static method unsupportedBySpecInternal() → void {} + +constants { + #C1 = true + #C2 = false +} diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.outline.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.outline.expect new file mode 100644 index 00000000000..5e500abc406 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.outline.expect @@ -0,0 +1,64 @@ +library /*isNonNullableByDefault*/; +import self as self; + +import "dart:supported.by.spec"; +import "dart:unsupported.by.spec"; +import "dart:unsupported.by.target"; +import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_first; +import "org-dartlang-testcase:///import_supported.by.target_lib.dart" as from_supported_by_target; +import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_last; + +static method main() → dynamic + ; +static method expect(dynamic expected, dynamic actual) → dynamic + ; + +library dart.supported.by.spec /*isNonNullableByDefault*/; +import self as self2; +import "dart:_supported.by.target" as by_; +additionalExports = (by_::supportedByTarget) + +export "dart:_supported.by.target"; + +static method supportedBySpec() → void + ; + +library dart.unsupported.by.spec /*isUnsupported,isNonNullableByDefault*/; +import self as self3; +import "dart:_unsupported.by.spec_internal" as spe; +additionalExports = (spe::unsupportedBySpecInternal) + +export "dart:_unsupported.by.spec_internal"; + +static method unsupportedBySpec() → void + ; + +library dart.unsupported.by.target /*isNonNullableByDefault*/; +import self as self4; + +static method unsupportedByTarget() → void + ; + +library /*isNonNullableByDefault*/; +import self as self5; +import "dart:core" as core; + +static field core::String field; + +library /*isNonNullableByDefault*/; +import self as self6; +import "dart:core" as core; + +static field core::String field; + +library dart._supported.by_target /*isUnsupported,isNonNullableByDefault*/; +import self as by_; + +static method supportedByTarget() → void + ; + +library dart._unsupported.by.spec_internal /*isUnsupported,isNonNullableByDefault*/; +import self as spe; + +static method unsupportedBySpecInternal() → void + ; diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.transformed.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.transformed.expect new file mode 100644 index 00000000000..85a3cb75f71 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.transformed.expect @@ -0,0 +1,87 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "dart:supported.by.spec" as spec; +import "dart:_supported.by.target" as by_; +import "dart:unsupported.by.spec" as spec2; +import "dart:unsupported.by.target" as tar; +import "dart:_unsupported.by.spec_internal" as spe; +import "import_supported.by.spec_lib.dart" as spe2; +import "import_supported.by.target_lib.dart" as tar2; +import "dart:core" as core; + +import "dart:supported.by.spec"; +import "dart:unsupported.by.spec"; +import "dart:unsupported.by.target"; +import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_first; +import "org-dartlang-testcase:///import_supported.by.target_lib.dart" as from_supported_by_target; +import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_last; + +static method main() → dynamic { + spec::supportedBySpec(); + by_::supportedByTarget(); + spec2::unsupportedBySpec(); + tar::unsupportedByTarget(); + spe::unsupportedBySpecInternal(); + self::expect("supported.by.spec", spe2::field); + self::expect("supported.by.target", tar2::field); + self::expect("supported.by.spec", spe2::field); + self::expect(true, #C1); + self::expect(true, #C1); + self::expect(false, #C2); + self::expect(false, #C2); + self::expect(false, #C2); +} +static method expect(dynamic expected, dynamic actual) → dynamic { + if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual)) + throw "Expected ${expected}, actual ${actual}"; +} + +library dart.supported.by.spec /*isNonNullableByDefault*/; +import self as spec; +import "dart:_supported.by.target" as by_; +additionalExports = (by_::supportedByTarget) + +export "dart:_supported.by.target"; + +static method supportedBySpec() → void {} + +library dart.unsupported.by.spec /*isUnsupported,isNonNullableByDefault*/; +import self as spec2; +import "dart:_unsupported.by.spec_internal" as spe; +additionalExports = (spe::unsupportedBySpecInternal) + +export "dart:_unsupported.by.spec_internal"; + +static method unsupportedBySpec() → void {} + +library dart.unsupported.by.target /*isNonNullableByDefault*/; +import self as tar; + +static method unsupportedByTarget() → void {} + +library /*isNonNullableByDefault*/; +import self as spe2; +import "dart:core" as core; + +static field core::String field = "supported.by.spec"; + +library /*isNonNullableByDefault*/; +import self as tar2; +import "dart:core" as core; + +static field core::String field = "supported.by.target"; + +library dart._supported.by_target /*isUnsupported,isNonNullableByDefault*/; +import self as by_; + +static method supportedByTarget() → void {} + +library dart._unsupported.by.spec_internal /*isUnsupported,isNonNullableByDefault*/; +import self as spe; + +static method unsupportedBySpecInternal() → void {} + +constants { + #C1 = true + #C2 = false +} diff --git a/pkg/front_end/testcases/general/supported_libraries/supported.by.spec_lib.dart b/pkg/front_end/testcases/general/supported_libraries/supported.by.spec_lib.dart new file mode 100644 index 00000000000..ea5edc07d89 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/supported.by.spec_lib.dart @@ -0,0 +1,9 @@ +// Copyright (c) 2022, 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. + +library dart.supported.by.spec; + +export 'dart:_supported.by.target'; + +void supportedBySpec() {} diff --git a/pkg/front_end/testcases/general/supported_libraries/supported.by.target_lib.dart b/pkg/front_end/testcases/general/supported_libraries/supported.by.target_lib.dart new file mode 100644 index 00000000000..673f03dc8d6 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/supported.by.target_lib.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2022, 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. + +library dart._supported.by_target; + +void supportedByTarget() {} diff --git a/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_internal_lib.dart b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_internal_lib.dart new file mode 100644 index 00000000000..7171f887735 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_internal_lib.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2022, 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. + +library dart._unsupported.by.spec_internal; + +void unsupportedBySpecInternal() {} diff --git a/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_lib.dart b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_lib.dart new file mode 100644 index 00000000000..ac010bb4ed1 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_lib.dart @@ -0,0 +1,9 @@ +// Copyright (c) 2022, 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. + +library dart.unsupported.by.spec; + +export 'dart:_unsupported.by.spec_internal'; + +void unsupportedBySpec() {} diff --git a/pkg/front_end/testcases/general/supported_libraries/unsupported.by.target_lib.dart b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.target_lib.dart new file mode 100644 index 00000000000..0ef61dca381 --- /dev/null +++ b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.target_lib.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2022, 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. + +library dart.unsupported.by.target; + +void unsupportedByTarget() {} diff --git a/pkg/front_end/testcases/rasta/supports_reflection.dart b/pkg/front_end/testcases/rasta/supports_reflection.dart index 4b53e520ae5..3aaf5eaa220 100644 --- a/pkg/front_end/testcases/rasta/supports_reflection.dart +++ b/pkg/front_end/testcases/rasta/supports_reflection.dart @@ -1,7 +1,9 @@ // Copyright (c) 2016, 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.md file. + // @dart=2.9 + main() { print(const bool.fromEnvironment("dart.library.mirrors")); } diff --git a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.expect b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.expect index d2d46a3dfc5..362665c1467 100644 --- a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.expect +++ b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.expect @@ -7,5 +7,5 @@ static method main() → dynamic { } constants { - #C1 = false + #C1 = true } diff --git a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.modular.expect b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.modular.expect index d2d46a3dfc5..362665c1467 100644 --- a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.modular.expect +++ b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.modular.expect @@ -7,5 +7,5 @@ static method main() → dynamic { } constants { - #C1 = false + #C1 = true } diff --git a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.transformed.expect b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.transformed.expect index d2d46a3dfc5..362665c1467 100644 --- a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.transformed.expect @@ -7,5 +7,5 @@ static method main() → dynamic { } constants { - #C1 = false + #C1 = true } diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status index 577ee4a3424..b66d7f8d262 100644 --- a/pkg/front_end/testcases/text_serialization.status +++ b/pkg/front_end/testcases/text_serialization.status @@ -33,7 +33,6 @@ general/bug30695: TypeCheckError general/bug31124: RuntimeError general/call: RuntimeError general/cascade: RuntimeError -general/conditional_import: RuntimeError # Issue 47814 general/constructor_initializer_invalid: RuntimeError general/covariant_field: TypeCheckError general/covariant_generic: RuntimeError diff --git a/pkg/front_end/testcases/weak.status b/pkg/front_end/testcases/weak.status index 699bd2923d2..8898c1a136c 100644 --- a/pkg/front_end/testcases/weak.status +++ b/pkg/front_end/testcases/weak.status @@ -47,7 +47,6 @@ general/bug30695: TypeCheckError general/bug31124: RuntimeError # Test has no main method (and we shouldn't add one). general/call: RuntimeError general/cascade: RuntimeError -general/conditional_import: RuntimeError # Issue 47814 general/constructor_initializer_invalid: RuntimeError # Fails execution after recovery general/covariant_field: TypeCheckError general/covariant_generic: RuntimeError diff --git a/pkg/front_end/tool/dart_doctest_impl.dart b/pkg/front_end/tool/dart_doctest_impl.dart index b03351a0a7b..c47c27ba17e 100644 --- a/pkg/front_end/tool/dart_doctest_impl.dart +++ b/pkg/front_end/tool/dart_doctest_impl.dart @@ -832,6 +832,7 @@ class DocTestIncrementalCompiler extends IncrementalCompiler { loader: loader, scope: libraryBuilder.scope.createNestedScope("dartdoctest"), nameOrigin: libraryBuilder, + isUnsupported: false, ); if (libraryBuilder is DillLibraryBuilder) { diff --git a/pkg/frontend_server/lib/frontend_server.dart b/pkg/frontend_server/lib/frontend_server.dart index 756373624e7..c1dac119306 100644 --- a/pkg/frontend_server/lib/frontend_server.dart +++ b/pkg/frontend_server/lib/frontend_server.dart @@ -51,6 +51,10 @@ ArgParser argParser = ArgParser(allowTrailingOptions: true) ..addFlag('aot', help: 'Run compiler in AOT mode (enables whole-program transformations)', defaultsTo: false) + ..addFlag('support-mirrors', + help: 'Whether dart:mirrors is supported. By default dart:mirrors is ' + 'supported when --aot and --minimal-kernel are not used.', + defaultsTo: null) ..addFlag('tfa', help: 'Enable global type flow analysis and related transformations in AOT mode.', @@ -487,6 +491,18 @@ class FrontendCompiler implements CompilerInterface { } } + if (options['support-mirrors'] == true) { + if (options['aot']) { + print('Error: --support-mirrors option cannot be used with --aot'); + return false; + } + if (options['minimal-kernel']) { + print('Error: --support-mirrors option cannot be used with ' + '--minimal-kernel'); + return false; + } + } + if (options['incremental']) { if (options['from-dill'] != null) { print('Error: --from-dill option cannot be used with --incremental'); @@ -505,6 +521,8 @@ class FrontendCompiler implements CompilerInterface { options['target'], trackWidgetCreation: options['track-widget-creation'], nullSafety: compilerOptions.nnbdMode == NnbdMode.Strong, + supportMirrors: options['support-mirrors'] ?? + !(options['aot'] || options['minimal-kernel']), ); if (compilerOptions.target == null) { print('Failed to create front-end target ${options['target']}.'); diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md index b75aba6ee21..3df728f7a31 100644 --- a/pkg/kernel/binary.md +++ b/pkg/kernel/binary.md @@ -147,7 +147,7 @@ type CanonicalName { type ComponentFile { UInt32 magic = 0x90ABCDEF; - UInt32 formatVersion = 75; + UInt32 formatVersion = 76; Byte[10] shortSdkHash; List problemsAsJson; // Described in problems.md. Library[] libraries; @@ -237,7 +237,7 @@ type Name { } type Library { - Byte flags (isSynthetic, isNonNullableByDefault, nnbdModeBit1, nnbdModeBit2); + Byte flags (isSynthetic, isNonNullableByDefault, nnbdModeBit1, nnbdModeBit2, isUnsupported); UInt languageVersionMajor; UInt languageVersionMinor; CanonicalNameReference canonicalName; diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart index 99a2f861b27..51270c4c924 100644 --- a/pkg/kernel/lib/ast.dart +++ b/pkg/kernel/lib/ast.dart @@ -273,6 +273,7 @@ class Library extends NamedNode static const int NonNullableByDefaultFlag = 1 << 1; static const int NonNullableByDefaultModeBit1 = 1 << 2; static const int NonNullableByDefaultModeBit2 = 1 << 3; + static const int IsUnsupportedFlag = 1 << 4; int flags = 0; @@ -322,6 +323,13 @@ class Library extends NamedNode } } + /// If true, the library is not supported through the 'dart.library.*' value + /// used in conditional imports and `bool.fromEnvironment` constants. + bool get isUnsupported => flags & IsUnsupportedFlag != 0; + void set isUnsupported(bool value) { + flags = value ? (flags | IsUnsupportedFlag) : (flags & ~IsUnsupportedFlag); + } + String? name; /// Problems in this [Library] encoded as json objects. diff --git a/pkg/kernel/lib/binary/tag.dart b/pkg/kernel/lib/binary/tag.dart index ceaae4afa17..a8a29ff88a6 100644 --- a/pkg/kernel/lib/binary/tag.dart +++ b/pkg/kernel/lib/binary/tag.dart @@ -176,7 +176,7 @@ class Tag { /// Internal version of kernel binary format. /// Bump it when making incompatible changes in kernel binaries. /// Keep in sync with runtime/vm/kernel_binary.h, pkg/kernel/binary.md. - static const int BinaryFormatVersion = 75; + static const int BinaryFormatVersion = 76; } abstract class ConstantTag { diff --git a/pkg/kernel/lib/target/targets.dart b/pkg/kernel/lib/target/targets.dart index 804f26aa3c5..173d367f636 100644 --- a/pkg/kernel/lib/target/targets.dart +++ b/pkg/kernel/lib/target/targets.dart @@ -15,16 +15,20 @@ final List targetNames = targets.keys.toList(); class TargetFlags { final bool trackWidgetCreation; final bool enableNullSafety; + final bool supportMirrors; const TargetFlags( - {this.trackWidgetCreation = false, this.enableNullSafety = false}); + {this.trackWidgetCreation = false, + this.enableNullSafety = false, + this.supportMirrors = true}); @override bool operator ==(other) { if (identical(this, other)) return true; return other is TargetFlags && trackWidgetCreation == other.trackWidgetCreation && - enableNullSafety == other.enableNullSafety; + enableNullSafety == other.enableNullSafety && + supportMirrors == other.supportMirrors; } @override @@ -32,6 +36,7 @@ class TargetFlags { int hash = 485786; hash = 0x3fffffff & (hash * 31 + (hash ^ trackWidgetCreation.hashCode)); hash = 0x3fffffff & (hash * 31 + (hash ^ enableNullSafety.hashCode)); + hash = 0x3fffffff & (hash * 31 + (hash ^ supportMirrors.hashCode)); return hash; } } @@ -151,6 +156,95 @@ class ConstantsBackend { bool get keepLocals => false; } +/// Interface used for determining whether a `dart:*` is considered supported +/// for the current target. +abstract class DartLibrarySupport { + /// Returns `true` if the 'dart:[libraryName]' library is supported. + /// + /// [isSupportedBySpec] is `true` if the dart library was supported by the + /// libraries specification. + /// + /// This is used to allow AOT to consider `dart:mirrors` as unsupported + /// despite it being supported in the platform dill, and dart2js to consider + /// `dart:_dart2js_runtime_metrics` to be supported despite it being an + /// internal library. + bool computeDartLibrarySupport(String libraryName, + {required bool isSupportedBySpec}); + + static const String dartLibraryPrefix = "dart.library."; + + static bool isDartLibraryQualifier(String dottedName) { + return dottedName.startsWith(dartLibraryPrefix); + } + + static String getDartLibraryName(String dottedName) { + assert(isDartLibraryQualifier(dottedName)); + return dottedName.substring(dartLibraryPrefix.length); + } + + /// Returns `"true"` if the "dart:[libraryName]" is supported and `""` + /// otherwise. + /// + /// This is used to determine conditional imports and `bool.fromEnvironment` + /// constant values for "dart.library.[libraryName]" values. + static String getDartLibrarySupportValue(String libraryName, + {required bool libraryExists, + required bool isSynthetic, + required bool isUnsupported, + required DartLibrarySupport dartLibrarySupport}) { + // A `dart:` library can be unsupported for several reasons: + // * If the library doesn't exist from source or from dill, it is not + // supported. + // * If the library has been synthesized, then it doesn't exist, but has + // been synthetically created due to an explicit import or export of it, + // in which case it is also not supported. + // * If the library is marked as not supported in the libraries + // specification, it does exist, but is not supported. + // * If the library is marked as supported in the libraries specification, + // it does exist and is potentially supported. Still the [Target] can + // consider it unsupported. This is for instance used to consider + // `dart:mirrors` as unsupported in AOT. The platform dill is shared with + // JIT, so the library exists and is marked as supported, but for AOT + // compilation it is still unsupported. + bool isSupported = libraryExists && !isSynthetic && !isUnsupported; + isSupported = dartLibrarySupport.computeDartLibrarySupport(libraryName, + isSupportedBySpec: isSupported); + return isSupported ? "true" : ""; + } +} + +/// [DartLibrarySupport] that only relies on the "supported" property of +/// the libraries specification. +class DefaultDartLibrarySupport implements DartLibrarySupport { + const DefaultDartLibrarySupport(); + + @override + bool computeDartLibrarySupport(String libraryName, + {required bool isSupportedBySpec}) => + isSupportedBySpec; +} + +/// [DartLibrarySupport] that supports overriding `dart:*` library support +/// otherwise defined by the libraries specification. +class CustomizedDartLibrarySupport implements DartLibrarySupport { + final Set supported; + final Set unsupported; + + const CustomizedDartLibrarySupport( + {this.supported: const {}, this.unsupported: const {}}); + + @override + bool computeDartLibrarySupport(String libraryName, + {required bool isSupportedBySpec}) { + if (supported.contains(libraryName)) { + return true; + } else if (unsupported.contains(libraryName)) { + return false; + } + return isSupportedBySpec; + } +} + /// A target provides backend-specific options for generating kernel IR. abstract class Target { TargetFlags get flags; @@ -434,7 +528,7 @@ abstract class Target { /// Returns the configured component. Component configureComponent(Component component) => component; - // Configure environment defines in a target-specific way. + /// Configure environment defines in a target-specific way. Map updateEnvironmentDefines(Map map) => map; @override @@ -453,6 +547,16 @@ abstract class Target { Class? concreteStringLiteralClass(CoreTypes coreTypes, String value) => null; ConstantsBackend get constantsBackend; + + /// Returns an [DartLibrarySupport] the defines which, if any, of the + /// `dart:` libraries supported in the platform, that should not be + /// considered supported when queried in conditional imports and + /// `bool.fromEnvironment` constants. + /// + /// This is used treat `dart:mirrors` as unsupported in AOT but supported + /// in JIT. + DartLibrarySupport get dartLibrarySupport => + const DefaultDartLibrarySupport(); } class NoneConstantsBackend extends ConstantsBackend { @@ -657,6 +761,8 @@ class TestTargetFlags extends TargetFlags { final bool? forceStaticFieldLoweringForTesting; final bool? forceNoExplicitGetterCallsForTesting; final int? forceConstructorTearOffLoweringForTesting; + final Set supportedDartLibraries; + final Set unsupportedDartLibraries; const TestTargetFlags( {bool trackWidgetCreation = false, @@ -665,7 +771,9 @@ class TestTargetFlags extends TargetFlags { this.forceStaticFieldLoweringForTesting, this.forceNoExplicitGetterCallsForTesting, this.forceConstructorTearOffLoweringForTesting, - bool enableNullSafety = false}) + bool enableNullSafety = false, + this.supportedDartLibraries: const {}, + this.unsupportedDartLibraries: const {}}) : super( trackWidgetCreation: trackWidgetCreation, enableNullSafety: enableNullSafety); @@ -698,6 +806,29 @@ mixin TestTargetMixin on Target { int get enabledConstructorTearOffLowerings => flags.forceConstructorTearOffLoweringForTesting ?? super.enabledConstructorTearOffLowerings; + + @override + late final DartLibrarySupport dartLibrarySupport = + new TestDartLibrarySupport(super.dartLibrarySupport, flags); +} + +class TestDartLibrarySupport implements DartLibrarySupport { + final DartLibrarySupport delegate; + final TestTargetFlags flags; + + TestDartLibrarySupport(this.delegate, this.flags); + + @override + bool computeDartLibrarySupport(String libraryName, + {required bool isSupportedBySpec}) { + if (flags.supportedDartLibraries.contains(libraryName)) { + return true; + } else if (flags.unsupportedDartLibraries.contains(libraryName)) { + return false; + } + return delegate.computeDartLibrarySupport(libraryName, + isSupportedBySpec: isSupportedBySpec); + } } class TargetWrapper extends Target { diff --git a/pkg/kernel/lib/text/ast_to_text.dart b/pkg/kernel/lib/text/ast_to_text.dart index 4f718b930dd..7f0ce5d494a 100644 --- a/pkg/kernel/lib/text/ast_to_text.dart +++ b/pkg/kernel/lib/text/ast_to_text.dart @@ -454,8 +454,15 @@ class Printer extends Visitor with VisitorVoidMixin { if (name != null) { writeWord(name); } + List flags = []; + if (library.isUnsupported) { + flags.add('isUnsupported'); + } if (library.isNonNullableByDefault) { - writeWord("/*isNonNullableByDefault*/"); + flags.add('isNonNullableByDefault'); + } + if (flags.isNotEmpty) { + writeWord('/*${flags.join(',')}*/'); } endLine(';'); diff --git a/pkg/vm/lib/kernel_front_end.dart b/pkg/vm/lib/kernel_front_end.dart index 871ee7deb17..74c8888b2e6 100644 --- a/pkg/vm/lib/kernel_front_end.dart +++ b/pkg/vm/lib/kernel_front_end.dart @@ -77,6 +77,10 @@ void declareCompilerOptions(ArgParser args) { help: 'Produce kernel file for AOT compilation (enables global transformations).', defaultsTo: false); + args.addFlag('support-mirrors', + help: 'Whether dart:mirrors is supported. By default dart:mirrors is ' + 'supported when --aot and --minimal-kernel are not used.', + defaultsTo: null); args.addOption('depfile', help: 'Path to output Ninja depfile'); args.addOption('from-dill', help: 'Read existing dill file instead of compiling from sources', @@ -193,6 +197,7 @@ Future runCompiler(ArgResults options, String usage) async { final bool splitOutputByPackages = options['split-output-by-packages']; final String? manifestFilename = options['manifest']; final String? dataDir = options['component-name'] ?? options['data-dir']; + final bool? supportMirrors = options['support-mirrors']; final bool minimalKernel = options['minimal-kernel']; final bool treeShakeWriteOnlyFields = options['tree-shake-write-only-fields']; @@ -215,6 +220,18 @@ Future runCompiler(ArgResults options, String usage) async { } } + if (supportMirrors == true) { + if (aot) { + print('Error: --support-mirrors option cannot be used with --aot'); + return badUsageExitCode; + } + if (minimalKernel) { + print('Error: --support-mirrors option cannot be used with ' + '--minimal-kernel'); + return badUsageExitCode; + } + } + final fileSystem = createFrontEndFileSystem(fileSystemScheme, fileSystemRoots); @@ -258,11 +275,10 @@ Future runCompiler(ArgResults options, String usage) async { await autoDetectNullSafetyMode(mainUri, compilerOptions); } - compilerOptions.target = createFrontEndTarget( - targetName, - trackWidgetCreation: options['track-widget-creation'], - nullSafety: compilerOptions.nnbdMode == NnbdMode.Strong, - ); + compilerOptions.target = createFrontEndTarget(targetName, + trackWidgetCreation: options['track-widget-creation'], + nullSafety: compilerOptions.nnbdMode == NnbdMode.Strong, + supportMirrors: supportMirrors ?? !(aot || minimalKernel)); if (compilerOptions.target == null) { print('Failed to create front-end target $targetName.'); return badUsageExitCode; @@ -442,6 +458,7 @@ Future runGlobalTransformations( {bool minimalKernel: false, bool treeShakeWriteOnlyFields: false, bool useRapidTypeAnalysis: true}) async { + assert(!target.flags.supportMirrors); if (errorDetector.hasCompilationErrors) return; final coreTypes = new CoreTypes(component); @@ -585,12 +602,16 @@ Future autoDetectNullSafetyMode( /// Create front-end target with given name. Target? createFrontEndTarget(String targetName, - {bool trackWidgetCreation = false, bool nullSafety = false}) { + {bool trackWidgetCreation = false, + bool nullSafety = false, + bool supportMirrors = true}) { // Make sure VM-specific targets are available. installAdditionalTargets(); final TargetFlags targetFlags = new TargetFlags( - trackWidgetCreation: trackWidgetCreation, enableNullSafety: nullSafety); + trackWidgetCreation: trackWidgetCreation, + enableNullSafety: nullSafety, + supportMirrors: supportMirrors); return getTarget(targetName, targetFlags); } diff --git a/pkg/vm/lib/target/vm.dart b/pkg/vm/lib/target/vm.dart index cb866c85543..da77a9ec48f 100644 --- a/pkg/vm/lib/target/vm.dart +++ b/pkg/vm/lib/target/vm.dart @@ -500,18 +500,11 @@ class VmTarget extends Target { // TODO(alexmarkov): Call this from the front-end in order to have // the same defines when compiling platform. map['dart.isVM'] = 'true'; - // TODO(dartbug.com/36460): Derive dart.library.* definitions from platform. - for (String library in extraRequiredLibraries) { - Uri libraryUri = Uri.parse(library); - if (libraryUri.scheme == 'dart') { - final path = libraryUri.path; - if (!path.startsWith('_')) { - map['dart.library.${path}'] = 'true'; - } - } - } - // dart:core is not mentioned in Target.extraRequiredLibraries. - map['dart.library.core'] = 'true'; return map; } + + @override + DartLibrarySupport get dartLibrarySupport => flags.supportMirrors + ? const DefaultDartLibrarySupport() + : const CustomizedDartLibrarySupport(unsupported: {'mirrors'}); } diff --git a/pkg/vm/test/modular_kernel_plus_aot_test.dart b/pkg/vm/test/modular_kernel_plus_aot_test.dart index 090a08dec68..8e05c6c71db 100644 --- a/pkg/vm/test/modular_kernel_plus_aot_test.dart +++ b/pkg/vm/test/modular_kernel_plus_aot_test.dart @@ -28,7 +28,7 @@ main() async { final Uri packagesFile = sdkRootFile('.packages'); final Uri librariesFile = sdkRootFile('sdk/lib/libraries.json'); - final vmTarget = VmTarget(TargetFlags()); + final vmTarget = VmTarget(TargetFlags(supportMirrors: false)); await withTempDirectory((Uri uri) async { final mixinFilename = uri.resolve('mixin.dart'); diff --git a/pkg/vm/test/transformations/protobuf_aware_treeshaker/treeshaker_test.dart b/pkg/vm/test/transformations/protobuf_aware_treeshaker/treeshaker_test.dart index 4febdf91c0f..cf616edd423 100644 --- a/pkg/vm/test/transformations/protobuf_aware_treeshaker/treeshaker_test.dart +++ b/pkg/vm/test/transformations/protobuf_aware_treeshaker/treeshaker_test.dart @@ -71,7 +71,7 @@ Future shakeAndRun(Uri source) async { } Future compileAOT(Uri source) async { - final target = TestingVmTarget(TargetFlags()); + final target = TestingVmTarget(TargetFlags(supportMirrors: false)); Component component = await compileTestCaseToKernelProgram(source, target: target); diff --git a/runtime/vm/compiler/frontend/kernel_translation_helper.h b/runtime/vm/compiler/frontend/kernel_translation_helper.h index ea30fa5c184..315e4689352 100644 --- a/runtime/vm/compiler/frontend/kernel_translation_helper.h +++ b/runtime/vm/compiler/frontend/kernel_translation_helper.h @@ -817,6 +817,7 @@ class LibraryHelper { kIsNonNullableByDefault = 1 << 1, kNonNullableByDefaultCompiledModeBit1 = 1 << 2, kNonNullableByDefaultCompiledModeBit2 = 1 << 3, + kUnsupported = 1 << 4, }; explicit LibraryHelper(KernelReaderHelper* helper, uint32_t binary_version) diff --git a/runtime/vm/kernel_binary.h b/runtime/vm/kernel_binary.h index 891a2b72841..ff0cfa2be06 100644 --- a/runtime/vm/kernel_binary.h +++ b/runtime/vm/kernel_binary.h @@ -20,8 +20,8 @@ namespace kernel { static const uint32_t kMagicProgramFile = 0x90ABCDEFu; // Both version numbers are inclusive. -static const uint32_t kMinSupportedKernelFormatVersion = 75; -static const uint32_t kMaxSupportedKernelFormatVersion = 75; +static const uint32_t kMinSupportedKernelFormatVersion = 76; +static const uint32_t kMaxSupportedKernelFormatVersion = 76; // Keep in sync with package:kernel/lib/binary/tag.dart #define KERNEL_TAG_LIST(V) \