| Index: runtime/vm/parser.cc
|
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
|
| index 6f639387c126ac232945dfea4ccc80cac1915855..1c44a6e490606951d98ae2a1da0239a1e75f6fa1 100644
|
| --- a/runtime/vm/parser.cc
|
| +++ b/runtime/vm/parser.cc
|
| @@ -1803,6 +1803,17 @@ void Parser::BuildDispatcherScope(const Function& func,
|
| // Build local scope for function and populate with the formal parameters.
|
| OpenFunctionBlock(func);
|
| AddFormalParamsToScope(¶ms, current_block_->scope);
|
| +
|
| + if (desc.TypeArgsLen() > 0) {
|
| + ASSERT(func.IsGeneric() && !func.HasGenericParent());
|
| + // Insert function type arguments variable to scope.
|
| + LocalVariable* type_args_var = new (Z) LocalVariable(
|
| + TokenPosition::kNoSource, TokenPosition::kNoSource,
|
| + Symbols::FunctionTypeArgumentsVar(), Object::dynamic_type());
|
| + current_block_->scope->AddVariable(type_args_var);
|
| + ASSERT(FunctionLevel() == 0);
|
| + parsed_function_->set_function_type_arguments(type_args_var);
|
| + }
|
| }
|
|
|
|
|
| @@ -1822,7 +1833,9 @@ SequenceNode* Parser::ParseNoSuchMethodDispatcher(const Function& func) {
|
|
|
| // Receiver is local 0.
|
| LocalScope* scope = current_block_->scope;
|
| - ArgumentListNode* func_args = new ArgumentListNode(token_pos);
|
| + ArgumentListNode* func_args = new ArgumentListNode(
|
| + token_pos, parsed_function_->function_type_arguments(),
|
| + desc.TypeArgsLen());
|
| for (intptr_t i = 0; i < desc.Count(); ++i) {
|
| func_args->Add(new LoadLocalNode(token_pos, scope->VariableAt(i)));
|
| }
|
| @@ -1898,9 +1911,12 @@ SequenceNode* Parser::ParseInvokeFieldDispatcher(const Function& func) {
|
| }
|
|
|
| // Pass arguments 1..n to the closure call.
|
| - ArgumentListNode* args = new (Z) ArgumentListNode(token_pos);
|
| + ArgumentListNode* args = new (Z)
|
| + ArgumentListNode(token_pos, parsed_function_->function_type_arguments(),
|
| + desc.TypeArgsLen());
|
| const Array& names =
|
| Array::Handle(Z, Array::New(desc.NamedCount(), Heap::kOld));
|
| +
|
| // Positional parameters.
|
| intptr_t i = 1;
|
| for (; i < desc.PositionalCount(); ++i) {
|
| @@ -5698,7 +5714,11 @@ RawTypeArguments* Parser::ParseTypeArguments(
|
| ReportError("right angle bracket expected");
|
| }
|
| if (finalization != ClassFinalizer::kIgnore) {
|
| - return NewTypeArguments(types);
|
| + TypeArguments& type_args = TypeArguments::Handle(NewTypeArguments(types));
|
| + if (finalization == ClassFinalizer::kCanonicalize) {
|
| + type_args = type_args.Canonicalize();
|
| + }
|
| + return type_args.raw();
|
| }
|
| }
|
| return TypeArguments::null();
|
| @@ -12565,12 +12585,15 @@ void Parser::ResolveType(AbstractType* type) {
|
| if (type->arguments() != TypeArguments::null()) {
|
| const TypeArguments& arguments =
|
| TypeArguments::Handle(Z, type->arguments());
|
| - const intptr_t num_arguments = arguments.Length();
|
| - AbstractType& type_argument = AbstractType::Handle(Z);
|
| - for (intptr_t i = 0; i < num_arguments; i++) {
|
| - type_argument = arguments.TypeAt(i);
|
| - ResolveType(&type_argument);
|
| - arguments.SetTypeAt(i, type_argument);
|
| + // Already resolved if canonical.
|
| + if (!arguments.IsCanonical()) {
|
| + const intptr_t num_arguments = arguments.Length();
|
| + AbstractType& type_argument = AbstractType::Handle(Z);
|
| + for (intptr_t i = 0; i < num_arguments; i++) {
|
| + type_argument = arguments.TypeAt(i);
|
| + ResolveType(&type_argument);
|
| + arguments.SetTypeAt(i, type_argument);
|
| + }
|
| }
|
| }
|
| if (type->IsFunctionType()) {
|
|
|