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 825e1c2d902..f6866239eb1 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 @@ -202,6 +202,18 @@ abstract class SourceLibraryBuilder 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); + + LibraryBuilder coreLibrary = + loader.read(resolve(this.uri, "dart:core", -1), -1); + LibraryBuilder imported = coreLibrary + .loader.builders[new Uri(scheme: 'dart', path: dottedName)]; + return imported != null ? "true" : ""; + } + void addImport( List metadata, String uri, @@ -214,9 +226,7 @@ abstract class SourceLibraryBuilder int uriOffset) { if (configurations != null) { for (Configuration config in configurations) { - if (loader.target.backendTarget - .lookupImportCondition(config.dottedName) == - config.condition) { + if (_lookupImportCondition(config.dottedName) == config.condition) { uri = config.importUri; break; } diff --git a/pkg/kernel/lib/target/targets.dart b/pkg/kernel/lib/target/targets.dart index a571982cca3..342757e2456 100644 --- a/pkg/kernel/lib/target/targets.dart +++ b/pkg/kernel/lib/target/targets.dart @@ -152,10 +152,6 @@ abstract class Target { /// extensions, but targets like dart2js only enable it on the core libraries. bool enableNative(Uri uri) => false; - /// Returns whether the given condition Uri should evaluate to true for the - /// purposes of resolving conditional imports. - String lookupImportCondition(String condition) => ""; - /// There are two variants of the `native` language extension. The VM expects /// the native token to be followed by string, whereas dart2js and DDC do not. // TODO(sigmund, ahe): ideally we should remove the `native` syntax, if not, diff --git a/tests/language_2/language_2_dartdevc.status b/tests/language_2/language_2_dartdevc.status index ab507cd5074..2e88f06b930 100644 --- a/tests/language_2/language_2_dartdevc.status +++ b/tests/language_2/language_2_dartdevc.status @@ -714,8 +714,8 @@ truncdiv_test: RuntimeError # Issue 29920 [ $compiler == dartdevk && $runtime != none ] callable_test/none: RuntimeError # Expect.throws(TypeError) fails: Did not throw -conditional_import_string_test: RuntimeError # Unsupported operation: String.fromEnvironment can only be used as a const constructor -conditional_import_test: RuntimeError # Unsupported operation: bool.fromEnvironment can only be used as a const constructor +conditional_import_string_test: CompileTimeError # Test is broken +conditional_import_test: CompileTimeError # Test is broken cyclic_type_test/00: RuntimeError # Expect.equals(expected: , actual: ) fails. cyclic_type_test/01: RuntimeError # Expect.equals(at index 0: Expected >...>, Found: ) fails. enum_duplicate_test/01: RuntimeError # NoSuchMethodError: method not found: ''