-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Description
Implementing subtypes of NativeWrapperClass
es can lead to issues when passing such native wrapper to a native call, as it will try to unwrap a native field that doesn't exist (likely leading to a segfault).
The NativeWrapperClass
es should be marked base
so that none of their subtypes can be implemented:
Flutter has classes which extend NativeWrapperClass
es and are mocked in tests, and Flutter has already opted in to 3.0, so adding the class modifiers to dart:nativewrappers
is a breaking change for Flutter.
org-dartlang-sdk:///flutter/lib/ui/compositing.dart:13:7: Error: The type 'Scene' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:2537:7: Error: The type 'EngineLayer' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/compositing.dart:231:7: Error: The type 'SceneBuilder' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:1941:7: Error: The type '_Image' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:2071:7: Error: The type 'Codec' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:2580:7: Error: The type 'Path' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:3193:7: Error: The type '_PathMeasure' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:3535:7: Error: The type '_ColorFilter' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:3809:7: Error: The type '_ImageFilter' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:3891:7: Error: The type 'Shader' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:4322:7: Error: The type 'FragmentProgram' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:4573:7: Error: The type 'Vertices' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:4831:7: Error: The type 'Canvas' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:5991:7: Error: The type 'Picture' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:6111:7: Error: The type 'PictureRecorder' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:6359:7: Error: The type 'ImmutableBuffer' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/painting.dart:6461:7: Error: The type 'ImageDescriptor' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/semantics.dart:680:16: Error: The type 'StringAttribute' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/semantics.dart:771:7: Error: The type 'SemanticsUpdateBuilder' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/semantics.dart:1052:7: Error: The type 'SemanticsUpdate' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/text.dart:2681:7: Error: The type 'Paragraph' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
org-dartlang-sdk:///flutter/lib/ui/text.dart:2958:7: Error: The type 'ParagraphBuilder' must be 'base', 'final' or 'sealed' because the supertype 'NativeFieldWrapperClass1' is 'base'.
A possible migration path would be to define APIs like Path
as abstract classes that do not extend NativeFieldWrapperClass1
. Apps would then call a factory to construct an instance of the engine's implementation that can be passed to native. cc @jason-simmons @dnfield
If possible, we should get these class modifiers into Dart 3.0. FYI @leafpetersen