From 94efcaf543b305b2305f4ead9c8fa4af29729e78 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 9 Feb 2023 15:09:37 -0800 Subject: [PATCH] Fix classes that shouldn't be extended/instantiated/mixedin (flutter/engine#39517) * Fix classes that shouldn't be extended/instantiated/mixedin * add ignore * fix comment --- engine/src/flutter/lib/ui/isolate_name_server.dart | 6 +++--- engine/src/flutter/lib/ui/natives.dart | 4 ++++ engine/src/flutter/lib/ui/painting.dart | 3 +++ engine/src/flutter/lib/ui/plugins.dart | 6 +++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/engine/src/flutter/lib/ui/isolate_name_server.dart b/engine/src/flutter/lib/ui/isolate_name_server.dart index ba3d53dab6..c220b4ed8f 100644 --- a/engine/src/flutter/lib/ui/isolate_name_server.dart +++ b/engine/src/flutter/lib/ui/isolate_name_server.dart @@ -20,9 +20,9 @@ part of dart.ui; /// recommended to establish a separate communication channel in that first /// message (e.g. by passing a dedicated [SendPort]). class IsolateNameServer { - // This class is only a namespace, and should not be instantiated or - // extended directly. - factory IsolateNameServer._() => throw UnsupportedError('Namespace'); + // This class is not meant to be instantiated or extended; this constructor + // prevents instantiation and extension. + IsolateNameServer._(); /// Looks up the [SendPort] associated with a given name. /// diff --git a/engine/src/flutter/lib/ui/natives.dart b/engine/src/flutter/lib/ui/natives.dart index 6a286fa620..d06f133d0d 100644 --- a/engine/src/flutter/lib/ui/natives.dart +++ b/engine/src/flutter/lib/ui/natives.dart @@ -7,6 +7,10 @@ part of dart.ui; /// Helper functions for Dart Plugin Registrants. class DartPluginRegistrant { + // This class is not meant to be instantiated or extended; this constructor + // prevents instantiation and extension. + DartPluginRegistrant._(); + static bool _wasInitialized = false; /// Makes sure the that the Dart Plugin Registrant has been called for this diff --git a/engine/src/flutter/lib/ui/painting.dart b/engine/src/flutter/lib/ui/painting.dart index 51bd467893..afe0979ed8 100644 --- a/engine/src/flutter/lib/ui/painting.dart +++ b/engine/src/flutter/lib/ui/painting.dart @@ -3501,6 +3501,9 @@ class _ColorFilter extends NativeFieldWrapperClass1 { /// * [SceneBuilder.pushImageFilter], which is the low-level API for using /// this class as a child layer filter. abstract class ImageFilter { + // This class is not meant to be extended; this constructor prevents extension. + ImageFilter._(); // ignore: unused_element + /// Creates an image filter that applies a Gaussian blur. factory ImageFilter.blur({ double sigmaX = 0.0, double sigmaY = 0.0, TileMode tileMode = TileMode.clamp }) { return _GaussianBlurImageFilter(sigmaX: sigmaX, sigmaY: sigmaY, tileMode: tileMode); diff --git a/engine/src/flutter/lib/ui/plugins.dart b/engine/src/flutter/lib/ui/plugins.dart index 7875232aa3..ac38e1c05f 100644 --- a/engine/src/flutter/lib/ui/plugins.dart +++ b/engine/src/flutter/lib/ui/plugins.dart @@ -40,9 +40,9 @@ class CallbackHandle { /// * [IsolateNameServer], which provides utilities for dealing with /// [Isolate]s. class PluginUtilities { - // This class is only a namespace, and should not be instantiated or - // extended directly. - factory PluginUtilities._() => throw UnsupportedError('Namespace'); + // This class is not meant to be instantiated or extended; this constructor + // prevents instantiation and extension. + PluginUtilities._(); static final Map _forwardCache = {};