Skip to content

Commit 3b25d6f

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Add DynamicType, NeverType, and VoidType to API.
[email protected] Change-Id: Icf917d999878b3c4d7b1d9425eb8a3c79921ba6b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153401 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 11632ff commit 3b25d6f

File tree

6 files changed

+22
-12
lines changed

6 files changed

+22
-12
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 0.39.13-dev
22
* Added 'dart/sdk/build_sdk_summary.dart' with `buildSdkSummary`.
3+
* Added `DynamicType`, `NeverType`, and `VoidType` interfaces.
34

45
## 0.39.12
56
* Deprecated `canUseSummaries` in `DartSdkManager` constructor.

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ Use ClassElement.instantiate() or FunctionTypeAliasElement.instantiate()
165165
List<DartType> argumentTypes, List<DartType> parameterTypes);
166166
}
167167

168+
/// The type `dynamic` is a type which is a supertype of all other types, just
169+
/// like `Object`, with the difference that the static analysis assumes that
170+
/// every member access has a corresponding member with a signature that
171+
/// admits the given access.
172+
abstract class DynamicType implements DartType {}
173+
168174
/// The type of a function, method, constructor, getter, or setter. Function
169175
/// types come in three variations:
170176
///
@@ -551,6 +557,9 @@ abstract class InterfaceType implements ParameterizedType {
551557
InterfaceTypeImpl.getSmartLeastUpperBound(first, second);
552558
}
553559

560+
/// The type `Never` represents the uninhabited bottom type.
561+
abstract class NeverType implements DartType {}
562+
554563
/// A type that can track substituted type parameters, either for itself after
555564
/// instantiation, or from a surrounding context.
556565
///
@@ -601,3 +610,12 @@ abstract class TypeParameterType implements DartType {
601610
@override
602611
TypeParameterElement get element;
603612
}
613+
614+
/// The special type `void` is used to indicate that the value of an
615+
/// expression is meaningless, and intended to be discarded.
616+
abstract class VoidType implements DartType {
617+
@override
618+
@deprecated
619+
VoidType substitute2(
620+
List<DartType> argumentTypes, List<DartType> parameterTypes);
621+
}

pkg/analyzer/lib/dart/element/type_provider.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:analyzer/dart/element/element.dart';
66
import 'package:analyzer/dart/element/type.dart';
77
import 'package:analyzer/src/dart/constant/value.dart';
8-
import 'package:analyzer/src/dart/element/type.dart';
98

109
/// The interface `TypeProvider` defines the behavior of objects that provide
1110
/// access to types defined by the language.

pkg/analyzer/lib/src/dart/constant/potentially_constant.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'package:analyzer/dart/ast/ast.dart';
66
import 'package:analyzer/dart/ast/token.dart';
77
import 'package:analyzer/dart/element/element.dart';
8+
import 'package:analyzer/dart/element/type.dart';
89
import 'package:analyzer/src/dart/element/type.dart';
910
import 'package:meta/meta.dart';
1011

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ List<T> _transformOrShare<T>(List<T> list, T Function(T) transform) {
4545
}
4646

4747
/// The [Type] representing the type `dynamic`.
48-
class DynamicTypeImpl extends TypeImpl {
48+
class DynamicTypeImpl extends TypeImpl implements DynamicType {
4949
/// The unique instance of this class.
5050
static final DynamicTypeImpl instance = DynamicTypeImpl._();
5151

@@ -1629,7 +1629,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
16291629
}
16301630

16311631
/// The type `Never` represents the uninhabited bottom type.
1632-
class NeverTypeImpl extends TypeImpl {
1632+
class NeverTypeImpl extends TypeImpl implements NeverType {
16331633
/// The unique instance of this class, nullable.
16341634
///
16351635
/// This behaves equivalently to the `Null` type, but we distinguish it for
@@ -2062,14 +2062,6 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType {
20622062
}
20632063
}
20642064

2065-
/// The type `void`.
2066-
abstract class VoidType implements DartType {
2067-
@override
2068-
@deprecated
2069-
VoidType substitute2(
2070-
List<DartType> argumentTypes, List<DartType> parameterTypes);
2071-
}
2072-
20732065
/// A concrete implementation of a [VoidType].
20742066
class VoidTypeImpl extends TypeImpl implements VoidType {
20752067
/// The unique instance of this class, with indeterminate nullability.

pkg/analyzer/lib/src/summary2/linking_bundle_context.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:analyzer/dart/element/nullability_suffix.dart';
77
import 'package:analyzer/dart/element/type.dart';
88
import 'package:analyzer/src/dart/element/element.dart';
99
import 'package:analyzer/src/dart/element/member.dart';
10-
import 'package:analyzer/src/dart/element/type.dart';
1110
import 'package:analyzer/src/dart/element/type_algebra.dart';
1211
import 'package:analyzer/src/summary/format.dart';
1312
import 'package:analyzer/src/summary/idl.dart';

0 commit comments

Comments
 (0)