Closed
Description
In some cases, a late Finalizable will incorrectly report that it's uninitialized:
import 'dart:ffi';
import 'package:test/test.dart';
class Foo implements Finalizable {
final int x;
Foo(this.x);
}
void main() {
late Foo foo;
setUpAll(() {
foo = Foo(123);
});
test('check foo', () {
expect(foo.x, 123);
});
}
Unhandled exception:
LateInitializationError: Local 'foo' has not been initialized.
#0 LateError._throwLocalNotInitialized (dart:_internal-patch/internal_patch.dart:199:5)
#1 main (late_finalizable.dart)
#2 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
This test passes if you remove implements Finalizable
, or change the variable to Foo? foo;
.
cc @dcharkes