mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:19:49 +00:00
[VM/nnbd] Field initializers may allocate a context storing 'this' when needed.
This fixes these co19 tests in strong mode: LanguageFeatures/nnbd/late_A05_t01 LanguageFeatures/nnbd/late_A05_t02 Change-Id: I90e9f91eec120d82992e835f79396c2a7770fcbc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144814 Commit-Queue: Régis Crelier <regis@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
parent
78907e46db
commit
c99da6857f
|
@ -54,6 +54,7 @@ FlowGraph* StreamingFlowGraphBuilder::BuildGraphOfFieldInitializer() {
|
|||
body += Constant(
|
||||
Instance::ZoneHandle(Z, constant_reader_.ReadConstantExpression()));
|
||||
} else {
|
||||
body += SetupCapturedParameters(parsed_function()->function());
|
||||
body += BuildExpression(); // read initializer.
|
||||
}
|
||||
body += Return(TokenPosition::kNoSource);
|
||||
|
|
|
@ -2779,7 +2779,7 @@ class Function : public Object {
|
|||
|
||||
bool HasThisParameter() const {
|
||||
return IsDynamicFunction(/*allow_abstract=*/true) ||
|
||||
IsGenerativeConstructor();
|
||||
IsGenerativeConstructor() || (IsFieldInitializer() && !is_static());
|
||||
}
|
||||
|
||||
bool IsDynamicFunction(bool allow_abstract = false) const {
|
||||
|
@ -3245,7 +3245,7 @@ class Function : public Object {
|
|||
return kind() == RawFunction::kImplicitSetter;
|
||||
}
|
||||
|
||||
// Returns true if this function represents an the initializer for a static or
|
||||
// Returns true if this function represents an initializer for a static or
|
||||
// instance field. The function returns the initial value and the caller is
|
||||
// responsible for setting the field.
|
||||
bool IsFieldInitializer() const {
|
||||
|
|
Loading…
Reference in a new issue