Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: pkg/analyzer/lib/src/dart/element/type.dart

Issue 1897713002: Make analyzer more strong mode compliant (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/type.dart
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index 475383e265eda736671e515c18df98257dbe19d7..897b23344b2615c4ecb31ec0e1c7a5eea38c204b 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -68,6 +68,137 @@ class BottomTypeImpl extends TypeImpl {
}
/**
+ * The type created internally if a circular reference is ever detected in a
+ * function type.
+ */
+class CircularFunctionTypeImpl extends DynamicTypeImpl
+ implements FunctionTypeImpl {
+ CircularFunctionTypeImpl() : super._circular();
+
+ @override
+ List<ParameterElement> get baseParameters => ParameterElement.EMPTY_LIST;
+
+ @override
+ DartType get baseReturnType => DynamicTypeImpl.instance;
+
+ @override
+ List<TypeParameterElement> get boundTypeParameters =>
+ TypeParameterElement.EMPTY_LIST;
+
+ @override
+ FunctionTypedElement get element => super.element;
+
+ @override
+ bool get isInstantiated => false;
+
+ @override
+ Map<String, DartType> get namedParameterTypes => <String, DartType>{};
+
+ @override
+ List<FunctionTypeAliasElement> get newPrune =>
+ FunctionTypeAliasElement.EMPTY_LIST;
+
+ @override
+ List<String> get normalParameterNames => <String>[];
+
+ @override
+ List<DartType> get normalParameterTypes => DartType.EMPTY_LIST;
+
+ @override
+ List<String> get optionalParameterNames => <String>[];
+
+ @override
+ List<DartType> get optionalParameterTypes => DartType.EMPTY_LIST;
+
+ @override
+ List<ParameterElement> get parameters => ParameterElement.EMPTY_LIST;
+
+ @override
+ List<FunctionTypeAliasElement> get prunedTypedefs =>
+ FunctionTypeAliasElement.EMPTY_LIST;
+
+ @override
+ DartType get returnType => DynamicTypeImpl.instance;
+
+ @override
+ List<DartType> get typeArguments => DartType.EMPTY_LIST;
+
+ @override
+ List<TypeParameterElement> get typeFormals => TypeParameterElement.EMPTY_LIST;
+
+ @override
+ List<TypeParameterElement> get typeParameters =>
+ TypeParameterElement.EMPTY_LIST;
+
+ @override
+ bool get _isInstantiated => false;
+
+ @override
+ List<DartType> get _typeArguments => DartType.EMPTY_LIST;
+
+ @override
+ void set _typeArguments(List<DartType> arguments) {
+ throw new UnsupportedError('Cannot have type arguments');
+ }
+
+ @override
+ List<TypeParameterElement> get _typeParameters =>
+ TypeParameterElement.EMPTY_LIST;
+
+ @override
+ void set _typeParameters(List<TypeParameterElement> parameters) {
+ throw new UnsupportedError('Cannot have type parameters');
+ }
+
+ @override
+ bool operator ==(Object object) => object is CircularFunctionTypeImpl;
+
+ @override
+ void appendTo(StringBuffer buffer) {
+ buffer.write('...');
+ }
+
+ @override
+ FunctionTypeImpl instantiate(List<DartType> argumentTypes) => this;
+
+ @override
+ FunctionTypeImpl pruned(List<FunctionTypeAliasElement> prune) => this;
+
+ @override
+ FunctionType substitute2(
+ List<DartType> argumentTypes, List<DartType> parameterTypes,
+ [List<FunctionTypeAliasElement> prune]) {
+ return this;
+ }
+
+ @override
+ FunctionTypeImpl substitute3(List<DartType> argumentTypes) => this;
+
+ @override
+ void _forEachParameterType(
+ ParameterKind kind, callback(String name, DartType type)) {
+ // There are no parameters.
+ }
+
+ @override
+ void _freeVariablesInFunctionType(
+ FunctionType type, Set<TypeParameterType> free) {
+ // There are no free variables
+ }
+
+ @override
+ void _freeVariablesInInterfaceType(
+ InterfaceType type, Set<TypeParameterType> free) {
+ // There are no free variables
+ }
+
+ @override
+ void _freeVariablesInType(DartType type, Set<TypeParameterType> free) {
+ // There are no free variables
+ }
+}
+
+/**
* Type created internally if a circular reference is ever detected. Behaves
* like `dynamic`, except that when converted to a string it is displayed as
* `...`.
@@ -76,9 +207,6 @@ class CircularTypeImpl extends DynamicTypeImpl {
CircularTypeImpl() : super._circular();
@override
- int get hashCode => 1;
-
- @override
bool operator ==(Object object) => object is CircularTypeImpl;
@override
@@ -675,12 +803,12 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
}
@override
- TypeImpl pruned(List<FunctionTypeAliasElement> prune) {
+ FunctionTypeImpl pruned(List<FunctionTypeAliasElement> prune) {
if (prune == null) {
return this;
} else if (prune.contains(element)) {
// Circularity found. Prune the type declaration.
- return new CircularTypeImpl();
+ return new CircularFunctionTypeImpl();
} else {
// There should never be a reason to prune a type that has already been
// pruned, since pruning is only done when expanding a function type
@@ -696,7 +824,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
}
@override
- DartType substitute2(
+ FunctionType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes,
[List<FunctionTypeAliasElement> prune]) {
// Pruned types should only ever result from performing type variable
@@ -710,7 +838,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
Element element = this.element;
if (prune != null && prune.contains(element)) {
// Circularity found. Prune the type declaration.
- return new CircularTypeImpl();
+ return new CircularFunctionTypeImpl();
}
if (argumentTypes.length == 0) {
return this.pruned(prune);
@@ -804,7 +932,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
FunctionType t,
DartType other,
bool parameterRelation(DartType t, DartType s),
- FunctionType instantiateToBounds(FunctionType t),
+ DartType instantiateToBounds(DartType t),
{bool returnRelation(DartType t, DartType s)}) {
returnRelation ??= parameterRelation;
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698