FE: let targets override whether imports to internal platform

libraries (dart:_foo) are allowed.

Override this in Dart2jsTarget to allow it in the dart2js_native test suite.

R=sra@google.com

Review-Url: https://codereview.chromium.org/2992073002 .
This commit is contained in:
Sigmund Cherem 2017-07-31 15:23:08 -07:00
parent 0c46242023
commit e1bccfc857
4 changed files with 121 additions and 110 deletions

View file

@ -51,6 +51,11 @@ class Dart2jsTarget extends Target {
uri.scheme == 'dart' &&
(uri.path == 'core' || uri.path == '_interceptors');
@override
bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) =>
super.allowPlatformPrivateLibraryAccess(importer, imported) ||
maybeEnableNative(importer);
@override
bool enableNative(Uri uri) => maybeEnableNative(uri);

View file

@ -102,9 +102,8 @@ abstract class Loader<L> {
return library;
});
if (accessor != null &&
uri.scheme == "dart" &&
uri.path.startsWith("_") &&
accessor.uri.scheme != "dart") {
!target.backendTarget
.allowPlatformPrivateLibraryAccess(accessor.uri, uri)) {
accessor.addCompileTimeError(
messagePlatformPrivateLibraryAccess, charOffset, accessor.fileUri);
}

View file

@ -129,6 +129,15 @@ abstract class Target {
bool mayDefineRestrictedType(Uri uri) =>
uri.scheme == 'dart' && uri.path == 'core';
/// Whether a library is allowed to import a platform private library.
///
/// By default only `dart:*` libraries are allowed. May be overriden for
/// testing purposes.
bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) =>
imported.scheme != "dart" ||
!imported.path.startsWith("_") ||
importer.scheme == "dart";
/// Whether the `native` language extension is supported within [library].
///
/// The `native` language extension is not part of the language specification,

View file

@ -133,122 +133,120 @@ native_class_inheritance3_frog_test: Crash # Issue 27394
native_wrapping_function3_frog_test: Crash # Issue 27394
[ $compiler == dart2js && $dart2js_with_kernel ]
# TODO(sigmund): currently the FE disallows imports to dart:_* from the unit
# test files.
native_no_such_method_exception4_frog_test: CompileTimeError
abstract_class_test: CompileTimeError
bound_closure_super_test: CompileTimeError
bound_closure_test: CompileTimeError
browser_compat_1_prepatched_test: CompileTimeError
browser_compat_1_unpatched_test: CompileTimeError
browser_compat_2_test: CompileTimeError
catch_javascript_null_stack_trace_test: CompileTimeError
compute_this_script_test: CompileTimeError
core_type_check_native_test: CompileTimeError
dispatch_property_initialization_test: CompileTimeError
downcast_test: CompileTimeError
error_safeToString_test: CompileTimeError
event_loop_test: CompileTimeError
fake_thing_2_test: CompileTimeError
fake_thing_test: CompileTimeError
field_type2_test: CompileTimeError
field_type_test: CompileTimeError
fixup_get_tag_test: CompileTimeError
foreign_test: CompileTimeError
hash_code_test: CompileTimeError
inference_of_helper_methods_test: CompileTimeError
internal_library_test: CompileTimeError
abstract_class_test: Crash
bound_closure_super_test: Crash
bound_closure_test: Crash
browser_compat_1_prepatched_test: Crash
browser_compat_1_unpatched_test: Crash
browser_compat_2_test: Crash
catch_javascript_null_stack_trace_test: Crash
compute_this_script_test: Crash
core_type_check_native_test: Crash
dispatch_property_initialization_test: Crash
downcast_test: Crash
error_safeToString_test: Crash
event_loop_test: Crash
fake_thing_2_test: Crash
fake_thing_test: Crash
field_type2_test: Crash
field_type_test: Crash
fixup_get_tag_test: Crash
foreign_test: Crash
hash_code_test: Crash
inference_of_helper_methods_test: Crash
internal_library_test: Crash
is_check_test: CompileTimeError
issue9182_test: CompileTimeError
js_const_test: CompileTimeError
js_constant_test: CompileTimeError
jsobject_test: CompileTimeError
issue9182_test: Crash
js_const_test: Crash
js_constant_test: Crash
jsobject_test: Crash
load_elim_refinement_test: CompileTimeError
mirror_intercepted_field_test: CompileTimeError
native_call_arity1_frog_test: CompileTimeError
native_call_arity2_frog_test: CompileTimeError
native_call_arity3_frog_test: CompileTimeError
native_checked_arguments1_frog_test: CompileTimeError
native_checked_fields_frog_test: CompileTimeError
native_class_avoids_hidden_name_frog_test: CompileTimeError
native_class_fields_2_test: CompileTimeError
native_class_fields_3_test: CompileTimeError
native_class_fields_test: CompileTimeError
native_class_inheritance1_frog_test: CompileTimeError
native_class_inheritance2_frog_test: CompileTimeError
native_class_inheritance3_frog_test: CompileTimeError
native_class_inheritance4_frog_test: CompileTimeError
native_class_is_check1_frog_test: CompileTimeError
native_class_is_check3_frog_test: CompileTimeError
native_class_with_dart_methods_frog_test: CompileTimeError
native_closure_identity_frog_test: CompileTimeError
native_constructor_name_test: CompileTimeError
native_equals_frog_test: CompileTimeError
native_exception2_test: CompileTimeError
native_exception_test: CompileTimeError
native_call_arity1_frog_test: Crash
native_call_arity2_frog_test: Crash
native_call_arity3_frog_test: Crash
native_checked_arguments1_frog_test: Crash
native_checked_fields_frog_test: Crash
native_class_avoids_hidden_name_frog_test: Crash
native_class_fields_2_test: Crash
native_class_fields_3_test: Crash
native_class_fields_test: Crash
native_class_inheritance1_frog_test: Crash
native_class_inheritance2_frog_test: Crash
native_class_inheritance3_frog_test: Crash
native_class_inheritance4_frog_test: Crash
native_class_is_check1_frog_test: Crash
native_class_is_check3_frog_test: Crash
native_class_with_dart_methods_frog_test: Crash
native_closure_identity_frog_test: Crash
native_constructor_name_test: Crash
native_equals_frog_test: Crash
native_exception2_test: Crash
native_exception_test: Crash
native_exceptions1_frog_test: CompileTimeError
native_field_invocation2_test: CompileTimeError
native_field_invocation3_test: CompileTimeError
native_field_invocation4_test: CompileTimeError
native_field_invocation5_test: CompileTimeError
native_field_invocation6_test: CompileTimeError
native_field_invocation_test: CompileTimeError
native_field_name_test: CompileTimeError
native_field_optimization_test: CompileTimeError
native_field_rename_1_frog_test: CompileTimeError
native_field_rename_2_frog_test: CompileTimeError
native_field_invocation2_test: Crash
native_field_invocation3_test: Crash
native_field_invocation4_test: Crash
native_field_invocation5_test: Crash
native_field_invocation6_test: Crash
native_field_invocation_test: Crash
native_field_name_test: Crash
native_field_optimization_test: Crash
native_field_rename_1_frog_test: Crash
native_field_rename_2_frog_test: Crash
native_library_same_name_used_frog_test: CompileTimeError
native_method_inlining_test: CompileTimeError
native_method_rename1_frog_test: CompileTimeError
native_method_rename2_frog_test: CompileTimeError
native_method_rename3_frog_test: CompileTimeError
native_method_with_keyword_name_test: CompileTimeError
native_mirror_test: CompileTimeError
native_missing_method1_frog_test: CompileTimeError
native_missing_method2_frog_test: CompileTimeError
native_mixin_field_test: CompileTimeError
native_mixin_multiple2_test: CompileTimeError
native_mixin_multiple3_test: CompileTimeError
native_mixin_multiple_test: CompileTimeError
native_mixin_test: CompileTimeError
native_mixin_with_plain_test: CompileTimeError
native_method_inlining_test: Crash
native_method_rename1_frog_test: Crash
native_method_rename2_frog_test: Crash
native_method_rename3_frog_test: Crash
native_method_with_keyword_name_test: Crash
native_mirror_test: Crash
native_missing_method1_frog_test: Crash
native_missing_method2_frog_test: Crash
native_mixin_field_test: Crash
native_mixin_multiple2_test: Crash
native_mixin_multiple3_test: Crash
native_mixin_multiple_test: Crash
native_mixin_test: Crash
native_mixin_with_plain_test: Crash
native_named_constructors2_frog_test: CompileTimeError
native_named_constructors3_frog_test: CompileTimeError
native_no_such_method_exception2_frog_test: CompileTimeError
native_no_such_method_exception3_frog_test: CompileTimeError
native_no_such_method_exception5_frog_test: CompileTimeError
native_no_such_method_exception_frog_test: CompileTimeError
native_novel_html_test: CompileTimeError
native_null_closure_frog_test: CompileTimeError
native_null_frog_test: CompileTimeError
native_no_such_method_exception2_frog_test: Crash
native_no_such_method_exception3_frog_test: Crash
native_no_such_method_exception4_frog_test: Crash
native_no_such_method_exception5_frog_test: Crash
native_no_such_method_exception_frog_test: Crash
native_novel_html_test: Crash
native_null_closure_frog_test: Crash
native_null_frog_test: Crash
native_property_frog_test: CompileTimeError
native_to_string_frog_test: CompileTimeError
native_use_native_name_in_table_frog_test: CompileTimeError
native_window1_frog_test: CompileTimeError
native_window2_frog_test: CompileTimeError
native_wrapping_function3_frog_test: CompileTimeError
native_wrapping_function_frog_test: CompileTimeError
oddly_named_fields_test: CompileTimeError
optimization_hints_test: CompileTimeError
rti_only_native_test: CompileTimeError
native_to_string_frog_test: Crash
native_use_native_name_in_table_frog_test: Crash
native_window1_frog_test: Crash
native_window2_frog_test: Crash
native_wrapping_function3_frog_test: Crash
native_wrapping_function_frog_test: Crash
oddly_named_fields_test: Crash
optimization_hints_test: Crash
rti_only_native_test: Crash
runtimetype_test: CompileTimeError
static_methods_test: CompileTimeError
subclassing_1_test: CompileTimeError
subclassing_2_test: CompileTimeError
subclassing_3_test: CompileTimeError
subclassing_4_test: CompileTimeError
subclassing_5_test: CompileTimeError
subclassing_constructor_1_test: CompileTimeError
subclassing_constructor_2_test: CompileTimeError
subclassing_super_call_test: CompileTimeError
subclassing_super_field_1_test: CompileTimeError
subclassing_super_field_2_test: CompileTimeError
subclassing_type_test: CompileTimeError
super_call_test: CompileTimeError
super_property_test: CompileTimeError
type_error_decode_test: CompileTimeError
undefined_bailout_test: CompileTimeError
uninstantiated_type_parameter_test: CompileTimeError
static_methods_test: Crash
subclassing_1_test: Crash
subclassing_2_test: Crash
subclassing_3_test: Crash
subclassing_4_test: Crash
subclassing_5_test: Crash
subclassing_constructor_1_test: Crash
subclassing_constructor_2_test: Crash
subclassing_super_call_test: Crash
subclassing_super_field_1_test: Crash
subclassing_super_field_2_test: Crash
subclassing_type_test: Crash
super_call_test: Crash
super_property_test: Crash
type_error_decode_test: Crash
undefined_bailout_test: Crash
uninstantiated_type_parameter_test: Crash
[ $compiler == dart2js && $dart2js_with_kernel && $host_checked ]
native_exceptions1_frog_test: Crash