@@ -9351,9 +9351,9 @@ FunctionPtr Function::ImplicitClosureFunction() const {
9351
9351
closure_signature.FinalizeNameArray();
9352
9352
closure_function.InheritKernelOffsetFrom(*this);
9353
9353
9354
- // Change covariant parameter types to either Object? for an opted-in implicit
9355
- // closure or to Object* for a legacy implicit closure.
9356
9354
if (!is_static() && !IsConstructor()) {
9355
+ // Change covariant parameter types to either Object? for an opted-in
9356
+ // implicit closure or to Object* for a legacy implicit closure.
9357
9357
BitVector is_covariant(zone, NumParameters());
9358
9358
BitVector is_generic_covariant_impl(zone, NumParameters());
9359
9359
kernel::ReadParameterCovariance(*this, &is_covariant,
@@ -9372,6 +9372,22 @@ FunctionPtr Function::ImplicitClosureFunction() const {
9372
9372
closure_signature.SetParameterTypeAt(i, object_type);
9373
9373
}
9374
9374
}
9375
+ } else if (IsConstructor() && closure_signature.IsGeneric()) {
9376
+ // Instantiate types of parameters as they may reference
9377
+ // class type parameters.
9378
+ const auto& instantiator_type_args = TypeArguments::Handle(
9379
+ zone, AbstractType::Handle(zone, closure_signature.result_type())
9380
+ .arguments());
9381
+ auto& param_type = AbstractType::Handle(zone);
9382
+ for (intptr_t i = kClosure; i < num_params; ++i) {
9383
+ param_type = closure_signature.ParameterTypeAt(i);
9384
+ if (!param_type.IsInstantiated()) {
9385
+ param_type = param_type.InstantiateFrom(instantiator_type_args,
9386
+ Object::null_type_arguments(),
9387
+ kAllFree, Heap::kOld);
9388
+ closure_signature.SetParameterTypeAt(i, param_type);
9389
+ }
9390
+ }
9375
9391
}
9376
9392
ASSERT(!closure_signature.IsFinalized());
9377
9393
closure_signature ^= ClassFinalizer::FinalizeType(closure_signature);
0 commit comments