Skip to content

Commit 800b734

Browse files
committed
Add DartType.isDartCoreNum getter.
[email protected], [email protected] Change-Id: Iac0cfb3e3d97a0402fc52b041bac137adcc6b505 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110548 Reviewed-by: Brian Wilkerson <[email protected]>
1 parent dcc7e03 commit 800b734

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 0.37.1 (Not yet published)
2-
* Added the getters `isDartCoreList`, `isDartCoreMap`, `isDartCoreSet`, and
3-
`isDartCoreSymbol` to `DartType`.
2+
* Added the getters `isDartCoreList`, `isDartCoreMap`, `isDartCoreNum`,
3+
`isDartCoreSet`, and `isDartCoreSymbol` to `DartType`.
44
* Added the method `DartObject.toFunctionValue`.
55

66
## 0.37.0

pkg/analyzer/lib/dart/element/type.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ abstract class DartType {
7979
/// dart:core library.
8080
bool get isDartCoreNull;
8181

82+
/// Return `true` if this type represents the type 'num' defined in the
83+
/// dart:core library.
84+
bool get isDartCoreNum;
85+
8286
/// Returns `true` if this type represents the type 'Set' defined in the
8387
/// dart:core library.
8488
bool get isDartCoreSet;

pkg/analyzer/lib/src/dart/element/type.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,15 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
15471547
return element.name == "Null" && element.library.isDartCore;
15481548
}
15491549

1550+
@override
1551+
bool get isDartCoreNum {
1552+
ClassElement element = this.element;
1553+
if (element == null) {
1554+
return false;
1555+
}
1556+
return element.name == "num" && element.library.isDartCore;
1557+
}
1558+
15501559
@override
15511560
bool get isDartCoreSet {
15521561
ClassElement element = this.element;
@@ -2703,6 +2712,9 @@ abstract class TypeImpl implements DartType {
27032712
@override
27042713
bool get isDartCoreNull => false;
27052714

2715+
@override
2716+
bool get isDartCoreNum => false;
2717+
27062718
@override
27072719
bool get isDartCoreSet => false;
27082720

0 commit comments

Comments
 (0)