Skip to content

Commit

Permalink
Add DynamicType, NeverType, and VoidType to API.
Browse files Browse the repository at this point in the history
R=brianwilkerson@google.com

Change-Id: Icf917d999878b3c4d7b1d9425eb8a3c79921ba6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Jul 7, 2020
1 parent 11632ff commit 3b25d6f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions pkg/analyzer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.39.13-dev
* Added 'dart/sdk/build_sdk_summary.dart' with `buildSdkSummary`.
* Added `DynamicType`, `NeverType`, and `VoidType` interfaces.

## 0.39.12
* Deprecated `canUseSummaries` in `DartSdkManager` constructor.
Expand Down
18 changes: 18 additions & 0 deletions pkg/analyzer/lib/dart/element/type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ Use ClassElement.instantiate() or FunctionTypeAliasElement.instantiate()
List<DartType> argumentTypes, List<DartType> parameterTypes);
}

/// The type `dynamic` is a type which is a supertype of all other types, just
/// like `Object`, with the difference that the static analysis assumes that
/// every member access has a corresponding member with a signature that
/// admits the given access.
abstract class DynamicType implements DartType {}

/// The type of a function, method, constructor, getter, or setter. Function
/// types come in three variations:
///
Expand Down Expand Up @@ -551,6 +557,9 @@ abstract class InterfaceType implements ParameterizedType {
InterfaceTypeImpl.getSmartLeastUpperBound(first, second);
}

/// The type `Never` represents the uninhabited bottom type.
abstract class NeverType implements DartType {}

/// A type that can track substituted type parameters, either for itself after
/// instantiation, or from a surrounding context.
///
Expand Down Expand Up @@ -601,3 +610,12 @@ abstract class TypeParameterType implements DartType {
@override
TypeParameterElement get element;
}

/// The special type `void` is used to indicate that the value of an
/// expression is meaningless, and intended to be discarded.
abstract class VoidType implements DartType {
@override
@deprecated
VoidType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes);
}
1 change: 0 additions & 1 deletion pkg/analyzer/lib/dart/element/type_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/constant/value.dart';
import 'package:analyzer/src/dart/element/type.dart';

/// The interface `TypeProvider` defines the behavior of objects that provide
/// access to types defined by the language.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:meta/meta.dart';

Expand Down
12 changes: 2 additions & 10 deletions pkg/analyzer/lib/src/dart/element/type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ List<T> _transformOrShare<T>(List<T> list, T Function(T) transform) {
}

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

Expand Down Expand Up @@ -1629,7 +1629,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
}

/// The type `Never` represents the uninhabited bottom type.
class NeverTypeImpl extends TypeImpl {
class NeverTypeImpl extends TypeImpl implements NeverType {
/// The unique instance of this class, nullable.
///
/// This behaves equivalently to the `Null` type, but we distinguish it for
Expand Down Expand Up @@ -2062,14 +2062,6 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType {
}
}

/// The type `void`.
abstract class VoidType implements DartType {
@override
@deprecated
VoidType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes);
}

/// A concrete implementation of a [VoidType].
class VoidTypeImpl extends TypeImpl implements VoidType {
/// The unique instance of this class, with indeterminate nullability.
Expand Down
1 change: 0 additions & 1 deletion pkg/analyzer/lib/src/summary2/linking_bundle_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/member.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/dart/element/type_algebra.dart';
import 'package:analyzer/src/summary/format.dart';
import 'package:analyzer/src/summary/idl.dart';
Expand Down

0 comments on commit 3b25d6f

Please sign in to comment.