From c3210c3ec8be5caa74d745bc79775b36d35befc7 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Tue, 12 Dec 2023 21:28:20 +0000 Subject: [PATCH] add optionalPositionalParameters to FunctionTypeAnnotationCode Change-Id: Ic2f8ab432d12f64dfd0028d0931563faafe6a212 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341442 Auto-Submit: Jake Macdonald Commit-Queue: Jake Macdonald Reviewed-by: Konstantin Shcheglov Commit-Queue: Konstantin Shcheglov --- pkg/_fe_analyzer_shared/lib/src/macros/api/code.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/api/code.dart b/pkg/_fe_analyzer_shared/lib/src/macros/api/code.dart index 681c9e4be000..23cac19dcc40 100644 --- a/pkg/_fe_analyzer_shared/lib/src/macros/api/code.dart +++ b/pkg/_fe_analyzer_shared/lib/src/macros/api/code.dart @@ -203,6 +203,8 @@ final class NamedTypeAnnotationCode extends TypeAnnotationCode { final class FunctionTypeAnnotationCode extends TypeAnnotationCode { final List namedParameters; + final List optionalPositionalParameters; + final List positionalParameters; final TypeAnnotationCode? returnType; @@ -226,6 +228,14 @@ final class FunctionTypeAnnotationCode extends TypeAnnotationCode { positional, ', ', ], + if (optionalPositionalParameters.isNotEmpty) ...[ + '[', + for (ParameterCode optional in optionalPositionalParameters) ...[ + optional, + ', ', + ], + ']', + ], if (namedParameters.isNotEmpty) ...[ '{', for (ParameterCode named in namedParameters) ...[ @@ -239,6 +249,7 @@ final class FunctionTypeAnnotationCode extends TypeAnnotationCode { FunctionTypeAnnotationCode({ this.namedParameters = const [], + this.optionalPositionalParameters = const [], this.positionalParameters = const [], this.returnType, this.typeParameters = const [],