Closed
Description
Because the FFI transformation changes the interface, and the way the CFE works, using FFI together with the incremental compiler doesn't work, and crashes.
This is an overview of what happens (example):
- We have 2 files, main.dart and lib.dart:
main.dart
:
import 'lib.dart';
main() {
Coordinate coordinate = new Coordinate.allocate(42.0, 42.0, null);
print(coordinate.x);
print(coordinate.y);
print(coordinate.next);
}
lib.dart
import 'dart:ffi';
class Coordinate extends Struct {
@Double()
double x;
@Double()
double y;
Pointer<Coordinate> next;
factory Coordinate.allocate(double x, double y, Pointer<Coordinate> next) {
return null;
}
}
- We first compile and everything is basically fine. The fields in
lib.dart
has been replaced though, and internally the CFE builder representing it / that initially build it, now has an inconsistent view of the world. - We update
main.dart
and thus recompile it. Nothing importsmain.dart
so onlymain.dart
needs to be rebuild. When doing that, type inference looks at "x", finds (via the builder in CFE) the now-removed field, tries to get the class it's in (via the field itself, namely the parent pointer), gets a null value and crashes when it tries to use it.
Even if it hadn't crashed, it would have pointed to something wrong (the basically non-existing field).
I will create a test and point to and from this issue.