[CP] [vm/ffi] Support late
Finalizable
variables
#49024
Labels
cherry-pick-approved
Label for approved cherrypick request
cherry-pick-review
Issue that need cherry pick triage to approve
Commit(s) to merge
e418026
Target
stable 2.17.1
Issue Description
late
variables with (sub)typeFinalizable
throwLateInitializationError
s when initialized by assignment instead of immediately on the variable declaration.Finalizable
s are kept alive by insertingreachabilityFence
s, and the argument to the fence causes a field-load which get checked for being initailized.What is the fix
Don't check field-loads for the sentinel value (the value representing that a late field is not initialized) when the field load is an argument to the
reachabilityFence
method.Why cherry-pick
We have released
NativeFinalizer
s in Dart 2.17, and any native resource should implement theFinalizable
interface.None of these native resources can then be used in
late
variables.(Concrete use case: automatic reference counting for Objective C objects in
package:ffigen
. cc @liamappelbe @brianquinlan)Risk
low
Issue link(s)
#49005
Extra Info
cc @mkustermann @mraleph Thanks for your input on the fix!
The text was updated successfully, but these errors were encountered: