Skip to content

Commit a17bd9e

Browse files
stereotype441Commit Bot
authored and
Commit Bot
committed
Add a FormalParameter.isExplicitlyTyped getter.
This is needed for my work on dart-lang/language#731 (improved inference for fold etc.) because I want to use slightly different heuristics when the closure passed to `fold` has explicitly parameter types. Change-Id: I7567df620e22bb53fcdb0f5cd8ceadf0c58c2126 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240504 Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent a125754 commit a17bd9e

File tree

3 files changed

+430
-0
lines changed

3 files changed

+430
-0
lines changed

pkg/analyzer/lib/dart/ast/ast.dart

+3
Original file line numberDiff line numberDiff line change
@@ -2070,6 +2070,9 @@ abstract class FormalParameter implements AstNode {
20702070
/// Return `true` if this parameter was declared with the 'const' modifier.
20712071
bool get isConst;
20722072

2073+
/// Indicates whether the parameter has an explicit type.
2074+
bool get isExplicitlyTyped;
2075+
20732076
/// Return `true` if this parameter was declared with the 'final' modifier.
20742077
///
20752078
/// Parameters that are declared with the 'const' modifier will return

pkg/analyzer/lib/src/dart/ast/ast.dart

+15
Original file line numberDiff line numberDiff line change
@@ -3126,6 +3126,9 @@ class DefaultFormalParameterImpl extends FormalParameterImpl
31263126
@override
31273127
bool get isConst => _parameter.isConst;
31283128

3129+
@override
3130+
bool get isExplicitlyTyped => _parameter.isExplicitlyTyped;
3131+
31293132
@override
31303133
bool get isFinal => _parameter.isFinal;
31313134

@@ -4437,6 +4440,9 @@ class FieldFormalParameterImpl extends NormalFormalParameterImpl
44374440
@override
44384441
bool get isConst => keyword?.keyword == Keyword.CONST;
44394442

4443+
@override
4444+
bool get isExplicitlyTyped => _parameters != null || _type != null;
4445+
44404446
@override
44414447
bool get isFinal => keyword?.keyword == Keyword.FINAL;
44424448

@@ -5633,6 +5639,9 @@ class FunctionTypedFormalParameterImpl extends NormalFormalParameterImpl
56335639
@override
56345640
bool get isConst => false;
56355641

5642+
@override
5643+
bool get isExplicitlyTyped => true;
5644+
56365645
@override
56375646
bool get isFinal => false;
56385647

@@ -9523,6 +9532,9 @@ class SimpleFormalParameterImpl extends NormalFormalParameterImpl
95239532
@override
95249533
bool get isConst => keyword?.keyword == Keyword.CONST;
95259534

9535+
@override
9536+
bool get isExplicitlyTyped => _type != null;
9537+
95269538
@override
95279539
bool get isFinal => keyword?.keyword == Keyword.FINAL;
95289540

@@ -10348,6 +10360,9 @@ class SuperFormalParameterImpl extends NormalFormalParameterImpl
1034810360
@override
1034910361
bool get isConst => keyword?.keyword == Keyword.CONST;
1035010362

10363+
@override
10364+
bool get isExplicitlyTyped => _parameters != null || _type != null;
10365+
1035110366
@override
1035210367
bool get isFinal => keyword?.keyword == Keyword.FINAL;
1035310368

0 commit comments

Comments
 (0)