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

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 2675963004: fix #28630, instance method tear-offs are treated as strict arrows (Closed)
Patch Set: fix 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.generated.error_verifier; 5 library analyzer.src.generated.error_verifier;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 15 matching lines...) Expand all
26 import 'package:analyzer/src/generated/element_resolver.dart'; 26 import 'package:analyzer/src/generated/element_resolver.dart';
27 import 'package:analyzer/src/generated/engine.dart'; 27 import 'package:analyzer/src/generated/engine.dart';
28 import 'package:analyzer/src/generated/java_engine.dart'; 28 import 'package:analyzer/src/generated/java_engine.dart';
29 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; 29 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
30 import 'package:analyzer/src/generated/resolver.dart'; 30 import 'package:analyzer/src/generated/resolver.dart';
31 import 'package:analyzer/src/generated/sdk.dart' show DartSdk, SdkLibrary; 31 import 'package:analyzer/src/generated/sdk.dart' show DartSdk, SdkLibrary;
32 import 'package:analyzer/src/generated/source.dart'; 32 import 'package:analyzer/src/generated/source.dart';
33 import 'package:analyzer/src/generated/utilities_dart.dart'; 33 import 'package:analyzer/src/generated/utilities_dart.dart';
34 import 'package:analyzer/src/task/dart.dart'; 34 import 'package:analyzer/src/task/dart.dart';
35 import 'package:analyzer/src/task/strong/checker.dart' as checker 35 import 'package:analyzer/src/task/strong/checker.dart' as checker
36 show isKnownFunction; 36 show hasStrictArrow;
37 37
38 /** 38 /**
39 * A visitor used to traverse an AST structure looking for additional errors and 39 * A visitor used to traverse an AST structure looking for additional errors and
40 * warnings not covered by the parser and resolver. 40 * warnings not covered by the parser and resolver.
41 */ 41 */
42 class ErrorVerifier extends RecursiveAstVisitor<Object> { 42 class ErrorVerifier extends RecursiveAstVisitor<Object> {
43 /** 43 /**
44 * Static final string with value `"getter "` used in the construction of the 44 * Static final string with value `"getter "` used in the construction of the
45 * [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE], and 45 * [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE], and
46 * similar, error code messages. 46 * similar, error code messages.
(...skipping 6190 matching lines...) Expand 10 before | Expand all | Expand 10 after
6237 DartType staticReturnType = getStaticType(returnExpression); 6237 DartType staticReturnType = getStaticType(returnExpression);
6238 if (staticReturnType != null && _enclosingFunction.isAsynchronous) { 6238 if (staticReturnType != null && _enclosingFunction.isAsynchronous) {
6239 return _typeProvider.futureType.instantiate( 6239 return _typeProvider.futureType.instantiate(
6240 <DartType>[staticReturnType.flattenFutures(_typeSystem)]); 6240 <DartType>[staticReturnType.flattenFutures(_typeSystem)]);
6241 } 6241 }
6242 return staticReturnType; 6242 return staticReturnType;
6243 } 6243 }
6244 6244
6245 bool _expressionIsAssignableAtType(Expression expression, 6245 bool _expressionIsAssignableAtType(Expression expression,
6246 DartType actualStaticType, DartType expectedStaticType) { 6246 DartType actualStaticType, DartType expectedStaticType) {
6247 bool concrete = _options.strongMode && checker.isKnownFunction(expression); 6247 bool concrete = _options.strongMode && checker.hasStrictArrow(expression);
6248 if (concrete && actualStaticType is FunctionType) { 6248 if (concrete && actualStaticType is FunctionType) {
6249 actualStaticType = 6249 actualStaticType =
6250 _typeSystem.functionTypeToConcreteType(actualStaticType); 6250 _typeSystem.functionTypeToConcreteType(actualStaticType);
6251 // TODO(leafp): Move the Downcast functionality here. 6251 // TODO(leafp): Move the Downcast functionality here.
6252 } 6252 }
6253 return _typeSystem.isAssignableTo(actualStaticType, expectedStaticType); 6253 return _typeSystem.isAssignableTo(actualStaticType, expectedStaticType);
6254 } 6254 }
6255 6255
6256 MethodElement _findOverriddenMemberThatMustCallSuper(MethodDeclaration node) { 6256 MethodElement _findOverriddenMemberThatMustCallSuper(MethodDeclaration node) {
6257 ExecutableElement overriddenMember = _getOverriddenMember(node.element); 6257 ExecutableElement overriddenMember = _getOverriddenMember(node.element);
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
7073 class _InvocationCollector extends RecursiveAstVisitor { 7073 class _InvocationCollector extends RecursiveAstVisitor {
7074 final List<String> superCalls = <String>[]; 7074 final List<String> superCalls = <String>[];
7075 7075
7076 @override 7076 @override
7077 visitMethodInvocation(MethodInvocation node) { 7077 visitMethodInvocation(MethodInvocation node) {
7078 if (node.target is SuperExpression) { 7078 if (node.target is SuperExpression) {
7079 superCalls.add(node.methodName.name); 7079 superCalls.add(node.methodName.name);
7080 } 7080 }
7081 } 7081 }
7082 } 7082 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/strong/checker.dart » ('j') | pkg/analyzer/lib/src/task/strong/checker.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698