Revert "[vm/ffi] Disallow nullable struct fields"

Revert submission 279511

Reason for revert: Flutter dependencies are using nullable struct
fields and need to be migrated first
https://github.com/flutter/flutter/issues/120260

Reverted changes: /q/submissionid:279510 /q/submissionid:279511

Change-Id: I7ab66ef6c6b5f21303804b2930af4ad6aa000413
Tested: Revert
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281600
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Daco Harkes 2023-02-08 08:51:28 +00:00 committed by Commit Queue
parent c95d1fc1ad
commit 732e4a43d5
2 changed files with 1 additions and 23 deletions

View file

@ -419,9 +419,7 @@ class _FfiDefinitionTransformer extends FfiTransformer {
}
final nativeTypeAnnos = _getNativeTypeAnnotations(f).toList();
final type = _compoundMemberType(f);
if (type is NullType ||
type.declaredNullability == Nullability.nullable ||
type.declaredNullability == Nullability.undetermined) {
if (type is NullType) {
diagnosticReporter.report(
templateFfiFieldNull.withArguments(f.name.text),
f.fileOffset,

View file

@ -1,20 +0,0 @@
// Copyright (c) 2023, 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.
import 'dart:ffi';
import 'package:ffi/ffi.dart';
class Foo extends Struct {
@Int32()
external int // Force `?` to newline.
? //# 1: compile-time error
x;
}
void main() {
final ptr = calloc.allocate<Foo>(sizeOf<Foo>());
print(ptr.ref.x);
calloc.free(ptr);
}