Add a flag to Procedures indicating that it's a redirecting factory

Fixes #32282

Bug: http://dartbug.com/32282
Change-Id: Iee8535b053ced415e3047e990a0940d859faa86a
Reviewed-on: https://dart-review.googlesource.com/43440
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
This commit is contained in:
Dmitry Stefantsov
2018-02-27 10:42:07 +00:00
committed by commit-bot@chromium.org
parent df92e14975
commit e7830a9f7b
9 changed files with 54 additions and 21 deletions
@@ -615,6 +615,7 @@ class KernelRedirectingFactoryBuilder extends KernelProcedureBuilder {
@override
Procedure build(SourceLibraryBuilder library) {
Procedure result = super.build(library);
result.isRedirectingFactoryConstructor = true;
if (redirectionTarget.typeArguments != null) {
typeArguments =
new List<DartType>(redirectionTarget.typeArguments.length);
+2 -1
View File
@@ -349,7 +349,8 @@ type Procedure extends Member {
FileOffset fileEndOffset;
Byte kind; // Index into the ProcedureKind enum above.
Byte flags (isStatic, isAbstract, isExternal, isConst, isForwardingStub,
isGenericContravariant, isForwardingSemiStub);
isGenericContravariant, isForwardingSemiStub,
isRedirectingFactoryConstructor);
Name name;
// An absolute path URI to the .dart file from which the class was created.
UriReference fileUri;
+14
View File
@@ -1546,6 +1546,8 @@ class Procedure extends Member implements FileUriNode {
static const int FlagForwardingStub = 1 << 4;
static const int FlagGenericContravariant = 1 << 5;
static const int FlagForwardingSemiStub = 1 << 6;
// TODO(29841): Remove this flag after the issue is resolved.
static const int FlagRedirectingFactoryConstructor = 1 << 7;
bool get isStatic => flags & FlagStatic != 0;
bool get isAbstract => flags & FlagAbstract != 0;
@@ -1577,6 +1579,12 @@ class Procedure extends Member implements FileUriNode {
/// stub, it was present in the original source as an abstract method.
bool get isForwardingSemiStub => flags & FlagForwardingSemiStub != 0;
// Indicates if this [Procedure] represents a redirecting factory constructor
// and doesn't have a runnable body.
bool get isRedirectingFactoryConstructor {
return flags & FlagRedirectingFactoryConstructor != 0;
}
/// If set, this flag indicates that this function was not present in the
/// source, and it exists solely for the purpose of type checking arguments
/// and forwarding to [forwardingStubSuperTarget].
@@ -1615,6 +1623,12 @@ class Procedure extends Member implements FileUriNode {
: (flags & ~FlagForwardingSemiStub);
}
void set isRedirectingFactoryConstructor(bool value) {
flags = value
? (flags | FlagRedirectingFactoryConstructor)
: (flags & ~FlagRedirectingFactoryConstructor);
}
bool get isInstanceMember => !isStatic;
bool get isGetter => kind == ProcedureKind.Getter;
bool get isSetter => kind == ProcedureKind.Setter;
@@ -119,6 +119,16 @@ var tests = <IsolateTest>[
expect(coverage['ranges'].length, greaterThan(1));
expect(coverage['scripts'].length, greaterThan(1));
// Full isolate
params = {
'reports': ['Coverage'],
'forceCompile': true
};
coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
expect(coverage['type'], equals('SourceReport'));
expect(coverage['ranges'].length, greaterThan(1));
expect(coverage['scripts'].length, greaterThan(1));
// Multiple reports (make sure enum list parameter parsing works).
params = {
'reports': ['_CallSites', 'Coverage', 'PossibleBreakpoints'],
+4 -6
View File
@@ -62,10 +62,10 @@ dart/truncating_ints_test: Skip # dart2js doesn't know about --limit-ints-to-64-
dart/wrap_around_in_range_analysis_test: SkipByDesign # The test requires int64.
[ $compiler == dartk ]
cc/DartAPI_New: Crash
cc/DartAPI_New: Fail
cc/DartAPI_TypeGetParameterizedTypes: Crash
dart/redirection_type_shuffling_test/00: Crash
dart/redirection_type_shuffling_test/none: Crash
dart/redirection_type_shuffling_test/00: RuntimeError
dart/redirection_type_shuffling_test/none: RuntimeError
[ $compiler != dartk ]
cc/IsolateReload_KernelIncrementalCompile: Skip
@@ -164,8 +164,6 @@ cc/Service_TokenStream: Fail
[ $compiler == dartk && $runtime == vm ]
cc/CanonicalizationInScriptSnapshots: Fail
cc/Class_ComputeEndTokenPos: Crash
cc/CorelibCompileAll: Crash
cc/CorelibCompilerStats: Crash
cc/DartAPI_CurrentStackTraceInfo: Fail
cc/DartAPI_InjectNativeFields1: Skip
cc/DartAPI_InvokeNoSuchMethod: Fail
@@ -234,7 +232,7 @@ cc/SourcePosition_WhileContinueBreak: Crash
cc/SourceReport_CallSites_PolymorphicCall: Fail
cc/SourceReport_CallSites_SimpleCall: Fail
cc/SourceReport_Coverage_AllFunctions: Fail
cc/SourceReport_Coverage_AllFunctions_ForceCompile: Crash
cc/SourceReport_Coverage_AllFunctions_ForceCompile: Fail
cc/SourceReport_Coverage_ForceCompile: Fail
cc/SourceReport_Coverage_NestedFunctions: Fail
cc/SourceReport_Coverage_NoCalls: Fail
@@ -271,6 +271,9 @@ class ProcedureHelper {
kExternal = 1 << 2,
kConst = 1 << 3, // Only for external const factories.
kForwardingStub = 1 << 4,
// TODO(29841): Remove this line after the issue is resolved.
kRedirectingFactoryConstructor = 1 << 7,
};
explicit ProcedureHelper(StreamingFlowGraphBuilder* builder) {
@@ -292,6 +295,9 @@ class ProcedureHelper {
bool IsExternal() { return (flags_ & kExternal) != 0; }
bool IsConst() { return (flags_ & kConst) != 0; }
bool IsForwardingStub() { return (flags_ & kForwardingStub) != 0; }
bool IsRedirectingFactoryConstructor() {
return (flags_ & kRedirectingFactoryConstructor) != 0;
}
NameIndex canonical_name_;
TokenPosition position_;
+4
View File
@@ -1228,6 +1228,10 @@ void KernelLoader::LoadProcedure(const Library& library,
ProcedureHelper procedure_helper(&builder_);
procedure_helper.ReadUntilExcluding(ProcedureHelper::kAnnotations);
if (procedure_helper.IsRedirectingFactoryConstructor()) {
builder_.SetOffset(procedure_end);
return;
}
const String& name = H.DartProcedureName(procedure_helper.canonical_name_);
bool is_method = in_class && !procedure_helper.IsStatic();
bool is_abstract = procedure_helper.IsAbstract();
+1 -2
View File
@@ -753,9 +753,8 @@ assertion_initializer_const_error2_test/cc08: MissingCompileTimeError # Not repo
assertion_initializer_const_error2_test/cc09: MissingCompileTimeError # Not reporting failed assert() at compile time.
assertion_initializer_const_error2_test/cc10: MissingCompileTimeError # Not reporting failed assert() at compile time.
assertion_initializer_const_error2_test/cc11: MissingCompileTimeError # Not reporting failed assert() at compile time.
hello_dart_test: Crash
recursive_mixin_test: Crash
redirecting_factory_reflection_test: Crash
redirecting_factory_reflection_test: RuntimeError
# Enabling of dartk for sim{arm,arm64,dbc64} revelaed these test failures, which
# are to be triaged. Isolate tests are skipped on purpose due to the usage of
+12 -12
View File
@@ -62,8 +62,8 @@ mirrors/load_library_test: Crash
mirrors/variable_is_const_test/01: Crash # Please triage.
[ $compiler == dartk && $runtime == vm && $checked && $strong ]
mirrors/redirecting_factory_different_type_test/01: Crash # Issue 28424
mirrors/redirecting_factory_different_type_test/none: Crash # Issue 28424
mirrors/redirecting_factory_different_type_test/01: MissingCompileTimeError # Issue 28424
mirrors/redirecting_factory_different_type_test/none: RuntimeError # Issue 28424
mirrors/reflected_type_generics_test/02: Pass
# ===== dartk + vm status lines =====
@@ -94,7 +94,7 @@ mirrors/constructor_kinds_test/01: RuntimeError
mirrors/constructor_kinds_test/none: RuntimeError
mirrors/constructor_private_name_test: RuntimeError
mirrors/constructors_test: CompileTimeError # Issue 31402 (Invocation arguments)
mirrors/dart2js_mirrors_test: Crash # 31916
mirrors/dart2js_mirrors_test: RuntimeError # 31916
mirrors/deferred_mirrors_metadata_test: RuntimeError, CompileTimeError # Deferred loading kernel issue 28335.
mirrors/deferred_mirrors_test: Crash # 31916
mirrors/deferred_type_test: CompileTimeError, RuntimeError
@@ -143,7 +143,7 @@ mirrors/mirrors_nsm_mismatch_test: CompileTimeError # Issue 31533
mirrors/mirrors_nsm_test/dart2js: CompileTimeError # Issue 31533
mirrors/mirrors_nsm_test/none: CompileTimeError # Issue 31533
mirrors/mirrors_reader_test: Crash
mirrors/mirrors_test: Crash
mirrors/mirrors_test: RuntimeError
mirrors/mirrors_used*: SkipByDesign # Invalid tests. MirrorsUsed does not have a specification, and dart:mirrors is not required to hide declarations that are not covered by any MirrorsUsed annotation.
mirrors/mirrors_used_inheritance_test: RuntimeError
mirrors/mirrors_used_typedef_declaration_test/01: RuntimeError
@@ -165,10 +165,10 @@ mirrors/private_class_field_test: RuntimeError
mirrors/private_field_test: RuntimeError
mirrors/private_symbol_test: RuntimeError
mirrors/private_types_test: RuntimeError
mirrors/redirecting_factory_different_type_test/01: Crash
mirrors/redirecting_factory_test/01: Crash
mirrors/redirecting_factory_test/02: Crash
mirrors/redirecting_factory_test/none: Crash
mirrors/redirecting_factory_different_type_test/01: MissingCompileTimeError
mirrors/redirecting_factory_test/01: RuntimeError
mirrors/redirecting_factory_test/02: RuntimeError
mirrors/redirecting_factory_test/none: RuntimeError
mirrors/reflect_class_test/none: RuntimeError
mirrors/reflected_type_classes_test/01: RuntimeError
mirrors/reflected_type_function_type_test: RuntimeError
@@ -218,7 +218,7 @@ isolate/ping_pause_test: RuntimeError
isolate/request_reply_test: Pass, Timeout
isolate/stacktrace_message_test: RuntimeError
mirrors/class_mirror_type_variables_test: RuntimeError
mirrors/constructor_optional_args_test: Crash
mirrors/constructor_optional_args_test: RuntimeError
mirrors/constructors_test: RuntimeError
mirrors/fake_function_with_call_test: RuntimeError
mirrors/generic_bounded_by_type_parameter_test/none: RuntimeError
@@ -240,7 +240,7 @@ mirrors/instance_members_unimplemented_interface_test: RuntimeError
mirrors/instance_members_with_override_test: RuntimeError
mirrors/instantiate_abstract_class_test: RuntimeError
mirrors/invoke_closurization2_test: RuntimeError
mirrors/invoke_throws_test: Crash
mirrors/invoke_throws_test: RuntimeError
mirrors/library_imports_bad_metadata_test/none: RuntimeError
mirrors/metadata_const_map_test: Crash
mirrors/mixin_members_test: RuntimeError
@@ -249,8 +249,8 @@ mirrors/operator_test: RuntimeError
mirrors/parameter_is_const_test/none: RuntimeError
mirrors/parameter_test/01: RuntimeError
mirrors/parameter_test/none: RuntimeError
mirrors/redirecting_factory_different_type_test/02: Crash
mirrors/redirecting_factory_different_type_test/none: Crash
mirrors/redirecting_factory_different_type_test/02: MissingCompileTimeError
mirrors/redirecting_factory_different_type_test/none: RuntimeError
mirrors/regress_16321_test/none: Crash
mirrors/top_level_accessors_test/01: MissingCompileTimeError
mirrors/type_argument_is_type_variable_test: RuntimeError