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

Unified Diff: pkg/compiler/lib/src/elements/resolution_types.dart

Issue 2707933002: Tests for `void`.
Patch Set: More tests. Created 3 years, 10 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
Index: pkg/compiler/lib/src/elements/resolution_types.dart
diff --git a/pkg/compiler/lib/src/elements/resolution_types.dart b/pkg/compiler/lib/src/elements/resolution_types.dart
index b8ed4fb8c1b169a802d0f2ee00bcee4cae82245f..07850b6985bda6925158d1165b0daa79bd1af90f 100644
--- a/pkg/compiler/lib/src/elements/resolution_types.dart
+++ b/pkg/compiler/lib/src/elements/resolution_types.dart
@@ -25,7 +25,6 @@ enum ResolutionTypeKind {
TYPE_VARIABLE,
MALFORMED_TYPE,
DYNAMIC,
- VOID,
}
abstract class ResolutionDartType implements DartType {
@@ -110,7 +109,7 @@ abstract class ResolutionDartType implements DartType {
bool get isDynamic => kind == ResolutionTypeKind.DYNAMIC;
/// Is [: true :] if this type is the void type.
- bool get isVoid => kind == ResolutionTypeKind.VOID;
+ bool get isVoid => false;
/// Is [: true :] if this is the type of `Object` from dart:core.
bool get isObject => false;
@@ -272,10 +271,9 @@ class MethodTypeVariableType extends ResolutionTypeVariableType {
get containsMethodTypeVariableType => true;
}
-class ResolutionVoidType extends ResolutionDartType implements VoidType {
- const ResolutionVoidType();
-
- ResolutionTypeKind get kind => ResolutionTypeKind.VOID;
+class ResolutionVoidType extends ResolutionInterfaceType implements VoidType {
+ ResolutionVoidType(ClassElement objectElement)
+ : super(objectElement);
String get name => 'void';
@@ -291,6 +289,9 @@ class ResolutionVoidType extends ResolutionDartType implements VoidType {
return visitor.visitVoidType(this, argument);
}
+ @override
+ bool get isVoid => true;
+
String toString() => name;
int get hashCode => 6007;
@@ -642,6 +643,16 @@ class ResolutionFunctionType extends ResolutionDartType
optionalParameterTypes, namedParameters, namedParameterTypes);
}
+ factory ResolutionFunctionType.generalized(
+ ResolutionDartType returnType,
+ List<ResolutionDartType> parameterTypes,
+ List<ResolutionDartType> optionalParameterTypes,
+ List<String> namedParameters,
+ List<ResolutionDartType> namedParameterTypes) {
+ return new ResolutionFunctionType.internal(null, returnType, parameterTypes,
+ optionalParameterTypes, namedParameters, namedParameterTypes);
+ }
+
ResolutionFunctionType.internal(FunctionTypedElement this.element,
[ResolutionDartType returnType = const ResolutionDynamicType(),
List<ResolutionDartType> parameterTypes = const <ResolutionDartType>[],
@@ -989,7 +1000,7 @@ abstract class BaseDartTypeVisitor<R, A> extends DartTypeVisitor<R, A> {
@override
R visitVoidType(ResolutionVoidType type, A argument) =>
- visitType(type, argument);
+ visitInterfaceType(type, argument);
@override
R visitTypeVariableType(ResolutionTypeVariableType type, A argument) =>
@@ -1033,11 +1044,6 @@ abstract class AbstractTypeRelation
throw 'internal error: unknown type kind ${t.kind}';
}
- bool visitVoidType(ResolutionVoidType t, ResolutionDartType s) {
- assert(s is! ResolutionVoidType);
- return false;
- }
-
bool invalidTypeArguments(ResolutionDartType t, ResolutionDartType s);
bool invalidFunctionReturnTypes(ResolutionDartType t, ResolutionDartType s);
@@ -1743,7 +1749,7 @@ class Types implements DartTypes {
if (a.treatAsDynamic || b.treatAsDynamic)
return const ResolutionDynamicType();
- if (a.isVoid || b.isVoid) return const ResolutionVoidType();
+ if (a.isVoid || b.isVoid) return new ResolutionVoidType(a.element);
if (a.isFunctionType && b.isFunctionType) {
return computeLeastUpperBoundFunctionTypes(a, b);

Powered by Google App Engine
This is Rietveld 408576698