-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tfa] Fix crash when building field guard summary with captured receiver
When building a field guard summary, field initializer is not included into the body. So field initializer AST should not be visited to calculate captured variables and field guard summary should not have a captured reveiver. TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter147239.dart Issue: flutter/flutter#147239 Change-Id: I717e942c0174294fda68a8c1ce946f73095e7a17 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364203 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
- Loading branch information
1 parent
c04da2f
commit 778a413
Showing
3 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter147239.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// Regression test for https://github.com/flutter/flutter/issues/147239. | ||
// Verifies that TFA doesn't crash when creating a field guard summary | ||
// for a field which has initializer with closure and captured receiver. | ||
|
||
class Foo<T> { | ||
late final aField = () { | ||
return <T>[]; | ||
}; | ||
} | ||
|
||
main() { | ||
print(Foo<String>().aField); | ||
} |
19 changes: 19 additions & 0 deletions
19
pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter147239.dart.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
library #lib; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class Foo<T extends core::Object? = dynamic> extends core::Object { | ||
|
||
[@vm.inferred-type.metadata=dart.core::_Closure (closure 1 in #lib::Foo.aField)] | ||
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] | ||
[@vm.closure-id=1] | ||
late covariant-by-class final field () → core::List<self::Foo::T%> aField = [@vm.closure-id=1]() → core::List<self::Foo::T%> { | ||
return [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::String>] core::_GrowableList::•<self::Foo::T%>(0); | ||
}; | ||
synthetic constructor •() → self::Foo<self::Foo::T%> | ||
: super core::Object::•() | ||
; | ||
} | ||
static method main() → dynamic { | ||
core::print([@vm.direct-call.metadata=#lib::Foo.aField] [@vm.inferred-type.metadata=dart.core::_Closure (closure 1 in #lib::Foo.aField)] new self::Foo::•<core::String>().{self::Foo::aField}{() → core::List<core::String>}); | ||
} |