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

Unified Diff: pkg/analyzer/lib/src/dart/constant/evaluation.dart

Issue 2613383003: Add support for generic function type syntax, part 1 (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
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | pkg/analyzer/lib/src/generated/element_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/constant/evaluation.dart
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index 8659dfea7e32437c0077b9f9a655d5275c05b427..4ac8ead1a536c984ded5f22d7a35232c48cfbda5 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -8,6 +8,7 @@ import 'dart:collection';
import 'package:analyzer/context/declared_variables.dart';
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/standard_ast_factory.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/constant/value.dart';
@@ -29,7 +30,6 @@ import 'package:analyzer/src/generated/type_system.dart'
import 'package:analyzer/src/generated/utilities_collection.dart';
import 'package:analyzer/src/generated/utilities_dart.dart' show ParameterKind;
import 'package:analyzer/src/task/dart.dart';
-import 'package:analyzer/dart/ast/standard_ast_factory.dart';
/**
* Helper class encapsulating the methods for evaluating constants and
@@ -1294,7 +1294,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
ParameterizedType elseType = elseResult.type;
return new DartObjectImpl.validWithUnknownValue(
_typeSystem.getLeastUpperBound(_typeProvider, thenType, elseType)
- as InterfaceType);
+ as InterfaceType);
}
@override
@@ -1359,9 +1359,9 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
return null;
}
DartType elementType = _typeProvider.dynamicType;
- NodeList<TypeName> typeArgs = node.typeArguments?.arguments;
+ NodeList<TypeAnnotation> typeArgs = node.typeArguments?.arguments;
if (typeArgs?.length == 1) {
- DartType type = visitTypeName(typeArgs[0])?.toTypeValue();
+ DartType type = visitTypeAnnotation(typeArgs[0])?.toTypeValue();
if (type != null) {
elementType = type;
}
@@ -1394,13 +1394,15 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
}
DartType keyType = _typeProvider.dynamicType;
DartType valueType = _typeProvider.dynamicType;
- NodeList<TypeName> typeArgs = node.typeArguments?.arguments;
+ NodeList<TypeAnnotation> typeArgs = node.typeArguments?.arguments;
if (typeArgs?.length == 2) {
- DartType keyTypeCandidate = visitTypeName(typeArgs[0])?.toTypeValue();
+ DartType keyTypeCandidate =
+ visitTypeAnnotation(typeArgs[0])?.toTypeValue();
if (keyTypeCandidate != null) {
keyType = keyTypeCandidate;
}
- DartType valueTypeCandidate = visitTypeName(typeArgs[1])?.toTypeValue();
+ DartType valueTypeCandidate =
+ visitTypeAnnotation(typeArgs[1])?.toTypeValue();
if (valueTypeCandidate != null) {
valueType = valueTypeCandidate;
}
@@ -1550,8 +1552,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
_typeProvider.symbolType, new SymbolState(buffer.toString()));
}
- @override
- DartObjectImpl visitTypeName(TypeName node) {
+ DartObjectImpl visitTypeAnnotation(TypeAnnotation node) {
DartType type = evaluateType(node.type);
if (type == null) {
return super.visitTypeName(node);
@@ -1559,6 +1560,9 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
return typeConstant(type);
}
+ @override
+ DartObjectImpl visitTypeName(TypeName node) => visitTypeAnnotation(node);
+
/**
* Create an error associated with the given [node]. The error will have the
* given error [code].
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | pkg/analyzer/lib/src/generated/element_resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698