[vm/ffi] update `FfiNative` nullptr receiver error message
TEST=pkg/vm/testcases/transformations/ffi/ffinative.dart
Bug: https://github.com/flutter/flutter/issues/109180
Change-Id: I53785c654f4699f4af5b4b686b76c621c2ddd778
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255680
Reviewed-by: Dan Field <dnfield@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
diff --git a/pkg/vm/lib/transformations/ffi/native.dart b/pkg/vm/lib/transformations/ffi/native.dart
index 6ddd65c..aba0edf 100644
--- a/pkg/vm/lib/transformations/ffi/native.dart
+++ b/pkg/vm/lib/transformations/ffi/native.dart
@@ -258,7 +258,13 @@
ExpressionStatement(StaticInvocation(
stateErrorThrowNewFunction,
Arguments([
- ConstantExpression(StringConstant('Native field is nullptr.'))
+ ConstantExpression(StringConstant(
+ 'A Dart object attempted to access a native peer, '
+ 'but the native peer has been collected (nullptr). '
+ 'This is usually the result of calling methods on a '
+ 'native-backed object when the native resources have '
+ 'already been disposed.',
+ ))
]),
)),
EmptyStatement(),
diff --git a/pkg/vm/testcases/transformations/ffi/ffinative.dart.aot.expect b/pkg/vm/testcases/transformations/ffi/ffinative.dart.aot.expect
index b4e558d..2981e17f 100644
--- a/pkg/vm/testcases/transformations/ffi/ffinative.dart.aot.expect
+++ b/pkg/vm/testcases/transformations/ffi/ffinative.dart.aot.expect
@@ -114,7 +114,7 @@
#C6 = 2
#C7 = 175
#C8 = 0
- #C9 = "Native field is nullptr."
+ #C9 = "A Dart object attempted to access a native peer, but the native peer has been collected (nullptr). This is usually the result of calling methods on a native-backed object when the native resources have already been disposed."
#C10 = true
#C11 = 13
#C12 = 37
diff --git a/pkg/vm/testcases/transformations/ffi/ffinative.dart.expect b/pkg/vm/testcases/transformations/ffi/ffinative.dart.expect
index e347f97..de7b429 100644
--- a/pkg/vm/testcases/transformations/ffi/ffinative.dart.expect
+++ b/pkg/vm/testcases/transformations/ffi/ffinative.dart.expect
@@ -115,5 +115,5 @@
#C4 = "doesntmatter"
#C5 = 2
#C6 = 0
- #C7 = "Native field is nullptr."
+ #C7 = "A Dart object attempted to access a native peer, but the native peer has been collected (nullptr). This is usually the result of calling methods on a native-backed object when the native resources have already been disposed."
}