 Chromium Code Reviews
 Chromium Code Reviews Issue 2336503003:
  fix #25578, implement @covariant parameter overrides  (Closed)
    
  
    Issue 2336503003:
  fix #25578, implement @covariant parameter overrides  (Closed) 
  | OLD | NEW | 
|---|---|
| 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 5020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5031 if ((elt is MethodElement && !elt.isAbstract) || | 5031 if ((elt is MethodElement && !elt.isAbstract) || | 
| 5032 (elt is PropertyAccessorElement && !elt.isAbstract)) { | 5032 (elt is PropertyAccessorElement && !elt.isAbstract)) { | 
| 5033 // Since we are comparing two function types, we need to do the | 5033 // Since we are comparing two function types, we need to do the | 
| 5034 // appropriate type substitutions first (). | 5034 // appropriate type substitutions first (). | 
| 5035 FunctionType foundConcreteFT = _inheritanceManager | 5035 FunctionType foundConcreteFT = _inheritanceManager | 
| 5036 .substituteTypeArgumentsInMemberFromInheritance( | 5036 .substituteTypeArgumentsInMemberFromInheritance( | 
| 5037 concreteType, memberName, enclosingType); | 5037 concreteType, memberName, enclosingType); | 
| 5038 FunctionType requiredMemberFT = _inheritanceManager | 5038 FunctionType requiredMemberFT = _inheritanceManager | 
| 5039 .substituteTypeArgumentsInMemberFromInheritance( | 5039 .substituteTypeArgumentsInMemberFromInheritance( | 
| 5040 requiredMemberType, memberName, enclosingType); | 5040 requiredMemberType, memberName, enclosingType); | 
| 5041 foundConcreteFT = | 5041 foundConcreteFT = _typeSystem.functionTypeToConcreteType( | 
| 5042 _typeSystem.typeToConcreteType(_typeProvider, foundConcreteFT); | 5042 _typeProvider, foundConcreteFT); | 
| 5043 requiredMemberFT = | 5043 requiredMemberFT = _typeSystem.functionTypeToConcreteType( | 
| 5044 _typeSystem.typeToConcreteType(_typeProvider, requiredMemberFT); | 5044 _typeProvider, requiredMemberFT); | 
| 5045 if (_typeSystem.isSubtypeOf(foundConcreteFT, requiredMemberFT)) { | 5045 if (_typeSystem.isSubtypeOf(foundConcreteFT, requiredMemberFT)) { | 
| 5046 continue; | 5046 continue; | 
| 5047 } | 5047 } | 
| 5048 } | 5048 } | 
| 5049 } | 5049 } | 
| 5050 // The not qualifying concrete executable element was found, add it to the | 5050 // The not qualifying concrete executable element was found, add it to the | 
| 5051 // list. | 5051 // list. | 
| 5052 missingOverrides.add(executableElt); | 5052 missingOverrides.add(executableElt); | 
| 5053 } | 5053 } | 
| 5054 // Now that we have the set of missing overrides, generate a warning on this | 5054 // Now that we have the set of missing overrides, generate a warning on this | 
| (...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6222 if (staticReturnType != null && _enclosingFunction.isAsynchronous) { | 6222 if (staticReturnType != null && _enclosingFunction.isAsynchronous) { | 
| 6223 return _typeProvider.futureType.instantiate( | 6223 return _typeProvider.futureType.instantiate( | 
| 6224 <DartType>[staticReturnType.flattenFutures(_typeSystem)]); | 6224 <DartType>[staticReturnType.flattenFutures(_typeSystem)]); | 
| 6225 } | 6225 } | 
| 6226 return staticReturnType; | 6226 return staticReturnType; | 
| 6227 } | 6227 } | 
| 6228 | 6228 | 
| 6229 bool _expressionIsAssignableAtType(Expression expression, | 6229 bool _expressionIsAssignableAtType(Expression expression, | 
| 6230 DartType actualStaticType, DartType expectedStaticType) { | 6230 DartType actualStaticType, DartType expectedStaticType) { | 
| 6231 bool concrete = _options.strongMode && checker.isKnownFunction(expression); | 6231 bool concrete = _options.strongMode && checker.isKnownFunction(expression); | 
| 6232 if (concrete) { | 6232 if (concrete && actualStaticType is FunctionType) { | 
| 6233 actualStaticType = | 6233 actualStaticType = _typeSystem.functionTypeToConcreteType( | 
| 6234 _typeSystem.typeToConcreteType(_typeProvider, actualStaticType); | 6234 _typeProvider, actualStaticType); | 
| 6235 // TODO(leafp): Move the Downcast functionality here. | 6235 // TODO(leafp): Move the Downcast functionality here. | 
| 6236 // TODO(leafp): Support strict downcasts | 6236 // TODO(leafp): Support strict downcasts | 
| 
Leaf
2016/09/12 23:42:37
At least the second of these TODOs is dead, you've
 
Jennifer Messerly
2016/09/13 00:16:21
Good catch, done!
 | |
| 6237 } | 6237 } | 
| 6238 return _typeSystem.isAssignableTo(actualStaticType, expectedStaticType); | 6238 return _typeSystem.isAssignableTo(actualStaticType, expectedStaticType); | 
| 6239 } | 6239 } | 
| 6240 | 6240 | 
| 6241 MethodElement _findOverriddenMemberThatMustCallSuper(MethodDeclaration node) { | 6241 MethodElement _findOverriddenMemberThatMustCallSuper(MethodDeclaration node) { | 
| 6242 ExecutableElement overriddenMember = _getOverriddenMember(node.element); | 6242 ExecutableElement overriddenMember = _getOverriddenMember(node.element); | 
| 6243 List<ExecutableElement> seen = <ExecutableElement>[]; | 6243 List<ExecutableElement> seen = <ExecutableElement>[]; | 
| 6244 while ( | 6244 while ( | 
| 6245 overriddenMember is MethodElement && !seen.contains(overriddenMember)) { | 6245 overriddenMember is MethodElement && !seen.contains(overriddenMember)) { | 
| 6246 for (ElementAnnotation annotation in overriddenMember.metadata) { | 6246 for (ElementAnnotation annotation in overriddenMember.metadata) { | 
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6895 class _InvocationCollector extends RecursiveAstVisitor { | 6895 class _InvocationCollector extends RecursiveAstVisitor { | 
| 6896 final List<String> superCalls = <String>[]; | 6896 final List<String> superCalls = <String>[]; | 
| 6897 | 6897 | 
| 6898 @override | 6898 @override | 
| 6899 visitMethodInvocation(MethodInvocation node) { | 6899 visitMethodInvocation(MethodInvocation node) { | 
| 6900 if (node.target is SuperExpression) { | 6900 if (node.target is SuperExpression) { | 
| 6901 superCalls.add(node.methodName.name); | 6901 superCalls.add(node.methodName.name); | 
| 6902 } | 6902 } | 
| 6903 } | 6903 } | 
| 6904 } | 6904 } | 
| OLD | NEW |