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

Unified Diff: pkg/analyzer/lib/src/task/strong_mode.dart

Issue 2782533002: Report errors for the new top-level inference rules. (Closed)
Patch Set: Update language_strong status for analyzer. Created 3 years, 9 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/analyzer/lib/src/task/strong_mode.dart
diff --git a/pkg/analyzer/lib/src/task/strong_mode.dart b/pkg/analyzer/lib/src/task/strong_mode.dart
index dcc55f1840e7ebb86320a533767f669030ae27f6..9208b991d3f082168a6397ad4d265a1ed727379c 100644
--- a/pkg/analyzer/lib/src/task/strong_mode.dart
+++ b/pkg/analyzer/lib/src/task/strong_mode.dart
@@ -606,6 +606,65 @@ class _IsValidForTypeInferenceVisitor extends RecursiveAstVisitor {
}
@override
+ void visitFunctionExpression(FunctionExpression node) {
+ FunctionBody body = node.body;
+ if (body is ExpressionFunctionBody) {
+ body.accept(this);
+ } else {
+ isValid = false;
+ }
+ }
+
+ @override
+ void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
+ node.function?.accept(this);
+ }
+
+ @override
+ void visitIndexExpression(IndexExpression node) {
+ isValid = false;
+ }
+
+ @override
+ void visitInstanceCreationExpression(InstanceCreationExpression node) {
+ ConstructorElement constructor = node.staticElement;
+ if (constructor != null) {
+ ClassElement clazz = constructor?.enclosingElement;
+ if (clazz.typeParameters.isNotEmpty &&
+ node.constructorName.type.typeArguments == null) {
+ isValid = false;
+ return;
+ }
+ }
+ }
+
+ @override
+ void visitListLiteral(ListLiteral node) {
+ if (node.typeArguments == null) {
+ super.visitListLiteral(node);
+ }
+ }
+
+ @override
+ void visitMapLiteral(MapLiteral node) {
+ if (node.typeArguments == null) {
+ super.visitMapLiteral(node);
+ }
+ }
+
+ @override
+ void visitMethodInvocation(MethodInvocation node) {
+ Element element = node.methodName.staticElement;
+ if (element is ExecutableElement) {
+ if (element.type.typeFormals.isNotEmpty && node.typeArguments == null) {
+ isValid = false;
+ return;
+ }
+ }
+ node.target?.accept(this);
+ }
+
+ @override
void visitSimpleIdentifier(SimpleIdentifier node) {
Element element = node.staticElement;
if (element == null) {
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698