Fix how we pass the type-parameter to StreamIterator in for-in
Change-Id: If2b33bc9bbee93e67f6da621db0287730b61b223
Reviewed-on: https://dart-review.googlesource.com/54311
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
diff --git a/pkg/compiler/lib/src/common_elements.dart b/pkg/compiler/lib/src/common_elements.dart
index 055d40e..d0a95e6 100644
--- a/pkg/compiler/lib/src/common_elements.dart
+++ b/pkg/compiler/lib/src/common_elements.dart
@@ -576,8 +576,10 @@
ClassEntity get controllerStream =>
_findAsyncHelperClass("_ControllerStream");
+ ClassEntity get streamIterator => _findAsyncHelperClass("StreamIterator");
+
ConstructorEntity get streamIteratorConstructor =>
- _env.lookupConstructor(_findAsyncHelperClass("StreamIterator"), "");
+ _env.lookupConstructor(streamIterator, "");
FunctionEntity _syncStarIterableFactory;
FunctionEntity get syncStarIterableFactory => _syncStarIterableFactory ??=
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 7f0236d..b22a63e 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -1575,12 +1575,25 @@
HInstruction streamIterator;
node.iterable.accept(this);
- _pushStaticInvocation(
- _commonElements.streamIteratorConstructor,
- [pop(), graph.addConstantNull(closedWorld)],
- _typeInferenceMap
- .getReturnTypeOf(_commonElements.streamIteratorConstructor),
- const <DartType>[]);
+
+ List<HInstruction> arguments = [pop()];
+ ClassEntity cls = _commonElements.streamIterator;
+ DartType typeArg = _elementMap.getDartType(node.variable.type);
+ InterfaceType instanceType =
+ localsHandler.substInContext(new InterfaceType(cls, [typeArg]));
+ addImplicitInstantiation(instanceType);
+ SourceInformation sourceInformation =
+ _sourceInformationBuilder.buildForInIterator(node);
+ // TODO(johnniwinther): Pass type arguments to constructors like calling
+ // a generic method.
+ if (rtiNeed.classNeedsTypeArguments(cls)) {
+ _addTypeArguments(arguments, [typeArg], sourceInformation);
+ }
+ ConstructorEntity constructor = _commonElements.streamIteratorConstructor;
+ _pushStaticInvocation(constructor, arguments,
+ _typeInferenceMap.getReturnTypeOf(constructor), const <DartType>[],
+ instanceType: instanceType, sourceInformation: sourceInformation);
+
streamIterator = pop();
void buildInitializer() {}
diff --git a/tests/corelib_2/corelib_2.status b/tests/corelib_2/corelib_2.status
index 74c74dd..485d97c 100644
--- a/tests/corelib_2/corelib_2.status
+++ b/tests/corelib_2/corelib_2.status
@@ -225,9 +225,7 @@
map_entry_test: RuntimeError
[ $compiler == dart2js && $fasta && $host_checked && $strong ]
-apply3_test: RuntimeError
cast_test: RuntimeError
-dynamic_nosuchmethod_test: RuntimeError
error_stack_trace1_test: RuntimeError # Issue 12399
growable_list_test: RuntimeError # Concurrent modifications test always runs
int_parse_radix_test/01: RuntimeError
diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status
index e9f48f6..4b7d3be 100644
--- a/tests/language_2/language_2_dart2js.status
+++ b/tests/language_2/language_2_dart2js.status
@@ -1057,6 +1057,7 @@
function_subtype_setter0_test: RuntimeError
function_type_alias2_test: RuntimeError
function_type_alias4_test: RuntimeError
+generic_async_star_test: RuntimeError
generic_closure_test/01: RuntimeError
generic_closure_test/none: RuntimeError
generic_function_bounds_test: RuntimeError
@@ -1108,7 +1109,6 @@
int64_literal_test/none: RuntimeError
integer_division_by_zero_test: RuntimeError # Issue 8301
internal_library_test/02: Crash # type 'DillLibraryBuilder' is not a subtype of type 'SourceLibraryBuilder<KernelTypeBuilder, Library>' of 'value' where
-invocation_mirror2_test: RuntimeError # mirrors not supported
invocation_mirror_invoke_on2_test: RuntimeError
invocation_mirror_invoke_on_test: RuntimeError
issue18628_2_test/01: MissingCompileTimeError
@@ -1142,7 +1142,6 @@
malbounded_type_test_test/00: MissingCompileTimeError
malbounded_type_test_test/01: MissingCompileTimeError
malbounded_type_test_test/02: MissingCompileTimeError
-many_overridden_no_such_method_test: RuntimeError
map_literal3_test/01: MissingCompileTimeError
map_literal3_test/02: MissingCompileTimeError
map_literal3_test/03: MissingCompileTimeError
@@ -1262,7 +1261,6 @@
nested_generic_closure_test: RuntimeError
no_main_test/01: CompileTimeError
no_such_method_mock_test: RuntimeError
-no_such_method_test: RuntimeError
nosuchmethod_forwarding/nosuchmethod_forwarding_arguments_test: RuntimeError
nosuchmethod_forwarding/nosuchmethod_forwarding_test/05: RuntimeError
nosuchmethod_forwarding/nosuchmethod_forwarding_test/06: RuntimeError
@@ -1270,7 +1268,6 @@
number_identity2_test: RuntimeError
numbers_test: RuntimeError, OK # non JS number semantics
operator2_negative_test: Crash # 'file:*/pkg/compiler/lib/src/kernel/env.dart': Failed assertion: line 322 pos 16: '!name.contains('#')': is not true.
-overridden_no_such_method_test: RuntimeError
override_field_test/01: MissingCompileTimeError
override_field_test/02: MissingCompileTimeError
override_field_test/03: MissingCompileTimeError
@@ -1613,6 +1610,7 @@
function_subtype_setter0_test: RuntimeError
function_type_alias2_test: RuntimeError
function_type_alias4_test: RuntimeError
+generic_async_star_test: RuntimeError
generic_function_bounds_test: RuntimeError
generic_function_dcall_test: RuntimeError
generic_function_type_as_type_argument_test/01: MissingCompileTimeError