[cfe] Provide a helper for computing interface member signature type

Change-Id: Iefad05b1a5e9b6f93f821ad29635af31e6c8926e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381642
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
This commit is contained in:
Chloe Stefantsova
2024-08-22 15:55:39 +00:00
committed by Commit Queue
parent 337ad11aca
commit 531e4ca0ec
+13 -1
View File
@@ -2979,7 +2979,10 @@ class Procedure extends Member implements GenericFunction {
/// this, it is stored explicitly as the [signatureType] on the procedure.
///
/// When [signatureType] is null, you can compute the function type with
/// `function.computeFunctionType(Nullability.nonNullable)`.
/// `function.computeFunctionType(Nullability.nonNullable)`. Alternatively,
/// you can use [computeSignatureOrFunctionType] that computes the interface
/// member signature type accounting for the possibility of [signatureType]
/// being null.
FunctionType? signatureType;
Procedure(Name name, ProcedureKind kind, FunctionNode function,
@@ -3234,6 +3237,15 @@ class Procedure extends Member implements GenericFunction {
: (flags & ~FlagHasWeakTearoffReferencePragma);
}
/// Computes the interface member signature type of the procedure.
///
/// In case [signatureType] is set, returns [signatureType]. Otherwise,
/// computes the function type of the function node.
FunctionType computeSignatureOrFunctionType() {
return signatureType ??
function.computeFunctionType(Nullability.nonNullable);
}
@override
R accept<R>(MemberVisitor<R> v) => v.visitProcedure(this);