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

Unified Diff: pkg/compiler/lib/src/typechecker.dart

Issue 2653203002: Use entities in CommonElements interface. (Closed)
Patch Set: Created 3 years, 11 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/typechecker.dart
diff --git a/pkg/compiler/lib/src/typechecker.dart b/pkg/compiler/lib/src/typechecker.dart
index 14da1cd11ef44358de91ebdfa05965b77208b9af..e7d66cef0e0d71b7a5edee1523b749060058a5af 100644
--- a/pkg/compiler/lib/src/typechecker.dart
+++ b/pkg/compiler/lib/src/typechecker.dart
@@ -111,8 +111,9 @@ abstract class ElementAccess {
return false;
}
}
- return compiler.types.isAssignable(
- computeType(compiler.resolution), compiler.commonElements.functionType);
+ ResolutionInterfaceType functionType = compiler.commonElements.functionType;
+ return compiler.types
+ .isAssignable(computeType(compiler.resolution), functionType);
}
}
@@ -230,7 +231,7 @@ class TypeLiteralAccess extends ElementAccess {
String get name => type.name;
- ResolutionDartType computeType(Resolution resolution) =>
+ ResolutionInterfaceType computeType(Resolution resolution) =>
resolution.commonElements.typeType;
String toString() => 'TypeLiteralAccess($type)';
@@ -756,7 +757,8 @@ class TypeCheckerVisitor extends Visitor<ResolutionDartType> {
// This is an access the implicit 'call' method of a function type.
return new FunctionCallAccess(receiverElement, unaliasedBound);
}
- if (types.isSubtype(interface, commonElements.functionType)) {
+ ResolutionInterfaceType functionType = commonElements.functionType;
+ if (types.isSubtype(interface, functionType)) {
// This is an access of the special 'call' method implicitly defined
// on 'Function'. This method can be called with any arguments, which
// we ensure by giving it the type 'dynamic'.
@@ -1612,7 +1614,7 @@ class TypeCheckerVisitor extends Visitor<ResolutionDartType> {
return const ResolutionDynamicType();
}
- ResolutionDartType visitLiteralSymbol(LiteralSymbol node) {
+ ResolutionInterfaceType visitLiteralSymbol(LiteralSymbol node) {
return commonElements.symbolType;
}
@@ -1700,8 +1702,9 @@ class TypeCheckerVisitor extends Visitor<ResolutionDartType> {
// The resolver already emitted an error for this expression.
} else {
if (currentAsyncMarker == AsyncMarker.ASYNC) {
- expressionType =
+ ResolutionInterfaceType futureOfFlattenedType =
commonElements.futureType(types.flatten(expressionType));
+ expressionType = futureOfFlattenedType;
}
if (expectedReturnType.isVoid &&
!types.isAssignable(expressionType, const ResolutionVoidType())) {
@@ -1739,21 +1742,27 @@ class TypeCheckerVisitor extends Visitor<ResolutionDartType> {
}
}
- ResolutionDartType visitYield(Yield node) {
+ visitYield(Yield node) {
ResolutionDartType resultType = analyze(node.expression);
if (!node.hasStar) {
if (currentAsyncMarker.isAsync) {
- resultType = commonElements.streamType(resultType);
+ ResolutionInterfaceType streamOfResultType =
+ commonElements.streamType(resultType);
+ resultType = streamOfResultType;
} else {
- resultType = commonElements.iterableType(resultType);
+ ResolutionInterfaceType iterableOfResultType =
+ commonElements.iterableType(resultType);
+ resultType = iterableOfResultType;
}
} else {
if (currentAsyncMarker.isAsync) {
// The static type of expression must be assignable to Stream.
- checkAssignable(node, resultType, commonElements.streamType());
+ ResolutionInterfaceType streamType = commonElements.streamType();
+ checkAssignable(node, resultType, streamType);
} else {
// The static type of expression must be assignable to Iterable.
- checkAssignable(node, resultType, commonElements.iterableType());
+ ResolutionInterfaceType iterableType = commonElements.iterableType();
+ checkAssignable(node, resultType, iterableType);
}
}
// The static type of the result must be assignable to the declared type.
@@ -1874,7 +1883,7 @@ class TypeCheckerVisitor extends Visitor<ResolutionDartType> {
ResolutionDartType elementType = computeForInElementType(node);
ResolutionDartType expressionType = analyze(node.expression);
if (resolution.target.supportsAsyncAwait) {
- ResolutionDartType streamOfDynamic = commonElements.streamType();
+ ResolutionInterfaceType streamOfDynamic = commonElements.streamType();
if (!types.isAssignable(expressionType, streamOfDynamic)) {
reportMessage(node.expression, MessageKind.NOT_ASSIGNABLE,
{'fromType': expressionType, 'toType': streamOfDynamic},
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | tests/compiler/dart2js/minimal_resolution_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698