mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:33:28 +00:00
Support extractTypeArguments() in 1.0 mode on the VM and dart2js.
Without strong mode, a "good enough" implementation is to simply call the generic method with "dynamic" for the type arguments, which is what this does. That should be enough to unblock our internal users. We also need to not report a compile error when dart_internal/extract_type_arguments.dart imports the hidden "dart:_internal" library. This patch does both of those for the VM and dart2js (using its old front end). Note that the test still fails because the test is more particular than most actual user code would be -- it validates that the instantiated type arguments are *exactly* correct, and not that the returned object is merely subtype compatible. Bug: Change-Id: I0343beace4991861b29712b3fd7067ec8dc8f8ba Reviewed-on: https://dart-review.googlesource.com/28020 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Alexander Thomas <athom@google.com> Reviewed-by: Régis Crelier <regis@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
5a44162c97
commit
650c9dcc8e
|
@ -122,7 +122,10 @@ class _ResolvedUriTranslator implements ResolvedUriTranslator {
|
|||
importingLibrary.canonicalUri.path
|
||||
.contains('tests/compiler/dart2js_native') ||
|
||||
importingLibrary.canonicalUri.path
|
||||
.contains('tests/compiler/dart2js_extra'));
|
||||
.contains('tests/compiler/dart2js_extra') ||
|
||||
(importingLibrary.canonicalUri.scheme == 'package' &&
|
||||
importingLibrary.canonicalUri.path
|
||||
.startsWith('dart_internal/')));
|
||||
|
||||
if (!allowInternalLibraryAccess) {
|
||||
if (importingLibrary != null) {
|
||||
|
|
|
@ -129,7 +129,9 @@ abstract class Target {
|
|||
bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) =>
|
||||
imported.scheme != "dart" ||
|
||||
!imported.path.startsWith("_") ||
|
||||
importer.scheme == "dart";
|
||||
importer.scheme == "dart" ||
|
||||
(importer.scheme == "package" &&
|
||||
importer.path.startsWith("dart_internal/"));
|
||||
|
||||
/// Whether the `native` language extension is supported within [library].
|
||||
///
|
||||
|
|
|
@ -26,8 +26,11 @@ List<T> makeFixedListUnmodifiable<T>(List<T> fixedLengthList)
|
|||
|
||||
@patch
|
||||
Object extractTypeArguments<T>(T instance, Function extract) {
|
||||
// TODO(31371): Implement this.
|
||||
throw new UnimplementedError();
|
||||
// TODO(31371): Implement this correctly for Dart 2.0.
|
||||
// In Dart 1.0, instantiating the generic with dynamic (which this does),
|
||||
// gives you an object that can be used anywhere a more specific type is
|
||||
// expected, so this works for now.
|
||||
return extract();
|
||||
}
|
||||
|
||||
class VMLibraryHooks {
|
||||
|
|
|
@ -6342,7 +6342,8 @@ void Parser::ParseLibraryImportExport(const Object& tl_owner,
|
|||
// libraries, including indirectly through exports.
|
||||
const String& lib_url = String::Handle(Z, library_.url());
|
||||
if (canon_url.StartsWith(Symbols::DartSchemePrivate()) &&
|
||||
!lib_url.StartsWith(Symbols::DartScheme())) {
|
||||
!lib_url.StartsWith(Symbols::DartScheme()) &&
|
||||
!lib_url.StartsWith(Symbols::DartInternalPackage())) {
|
||||
ReportError(import_pos, "private library is not accessible");
|
||||
}
|
||||
|
||||
|
|
|
@ -359,6 +359,7 @@ class ObjectPointerVisitor;
|
|||
V(Index, "index") \
|
||||
V(DartScheme, "dart:") \
|
||||
V(DartSchemePrivate, "dart:_") \
|
||||
V(DartInternalPackage, "package:dart_internal/") \
|
||||
V(DartNativeWrappers, "dart:nativewrappers") \
|
||||
V(DartNativeWrappersLibName, "nativewrappers") \
|
||||
V(DartCore, "dart:core") \
|
||||
|
|
|
@ -48,6 +48,9 @@ List<T> makeFixedListUnmodifiable<T>(List<T> fixedLengthList) {
|
|||
|
||||
@patch
|
||||
Object extractTypeArguments<T>(T instance, Function extract) {
|
||||
// TODO(31371): Implement this.
|
||||
throw new UnimplementedError();
|
||||
// TODO(31371): Implement this correctly for Dart 2.0.
|
||||
// In Dart 1.0, instantiating the generic with dynamic (which this does),
|
||||
// gives you an object that can be used anywhere a more specific type is
|
||||
// expected, so this works for now.
|
||||
return extract();
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ error_stacktrace_test/00: MissingCompileTimeError
|
|||
example_constructor_test: RuntimeError
|
||||
external_test/21: CompileTimeError
|
||||
external_test/24: CompileTimeError
|
||||
extract_type_arguments_test: CompileTimeError # Issue 31371
|
||||
extract_type_arguments_test: RuntimeError # Issue 31371
|
||||
f_bounded_quantification_test/01: MissingCompileTimeError
|
||||
f_bounded_quantification_test/02: MissingCompileTimeError
|
||||
factory1_test/00: MissingCompileTimeError
|
||||
|
|
|
@ -288,7 +288,6 @@ emit_const_fields_test: CompileTimeError # Issue 31533
|
|||
export_ambiguous_main_test: MissingCompileTimeError
|
||||
external_test/21: CompileTimeError
|
||||
external_test/24: CompileTimeError
|
||||
extract_type_arguments_test: CompileTimeError # Issue 31371
|
||||
f_bounded_quantification_test/01: MissingCompileTimeError
|
||||
f_bounded_quantification_test/02: MissingCompileTimeError
|
||||
factory2_test/03: MissingCompileTimeError
|
||||
|
|
|
@ -471,7 +471,7 @@ example_constructor_test: Fail, OK
|
|||
external_test/10: MissingRuntimeError # KernelVM bug: Unbound external.
|
||||
external_test/13: MissingRuntimeError # KernelVM bug: Unbound external.
|
||||
external_test/20: MissingRuntimeError # KernelVM bug: Unbound external.
|
||||
extract_type_arguments_test: CompileTimeError # Issue 31371
|
||||
extract_type_arguments_test: RuntimeError # Issue 31371
|
||||
f_bounded_quantification_test/01: MissingCompileTimeError
|
||||
f_bounded_quantification_test/02: MissingCompileTimeError
|
||||
factory2_test/03: MissingCompileTimeError
|
||||
|
|
|
@ -282,7 +282,7 @@ export_ambiguous_main_negative_test: Fail # Issue 14763
|
|||
export_ambiguous_main_negative_test: Skip # Issue 29895
|
||||
export_ambiguous_main_test: Crash
|
||||
export_double_same_main_test: Skip # Issue 29895
|
||||
extract_type_arguments_test: CompileTimeError # Issue 31371
|
||||
extract_type_arguments_test: RuntimeError # Issue 31371
|
||||
f_bounded_quantification_test/01: MissingCompileTimeError
|
||||
f_bounded_quantification_test/02: MissingCompileTimeError
|
||||
factory1_test/00: MissingCompileTimeError
|
||||
|
|
|
@ -311,7 +311,7 @@ empty_block_case_test: MissingCompileTimeError
|
|||
enum_private_test/02: MissingCompileTimeError
|
||||
error_stacktrace_test/00: MissingCompileTimeError
|
||||
export_ambiguous_main_test: MissingCompileTimeError
|
||||
extract_type_arguments_test: CompileTimeError # Issue 31371
|
||||
extract_type_arguments_test: RuntimeError # Issue 31371
|
||||
f_bounded_quantification_test/01: MissingCompileTimeError
|
||||
f_bounded_quantification_test/02: MissingCompileTimeError
|
||||
factory1_test/00: MissingCompileTimeError
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
'tests/',
|
||||
'pkg/async_helper/',
|
||||
'pkg/compiler/',
|
||||
'pkg/dart_internal/',
|
||||
'pkg/expect/',
|
||||
'pkg/front_end/',
|
||||
'pkg/js/',
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
'tests/',
|
||||
'pkg/async_helper/',
|
||||
'pkg/browser/',
|
||||
'pkg/dart_internal/',
|
||||
'pkg/expect/',
|
||||
'pkg/js/',
|
||||
'pkg/meta/',
|
||||
|
|
Loading…
Reference in a new issue