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

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

Issue 1405143006: improve static type analysis for `await for` (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 engine.resolver.error_verifier; 5 library engine.resolver.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/src/generated/static_type_analyzer.dart'; 10 import 'package:analyzer/src/generated/static_type_analyzer.dart';
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 List<ParameterElement> parameters, 1305 List<ParameterElement> parameters,
1306 List<AstNode> parameterLocations, 1306 List<AstNode> parameterLocations,
1307 SimpleIdentifier errorNameTarget) { 1307 SimpleIdentifier errorNameTarget) {
1308 bool isGetter = false; 1308 bool isGetter = false;
1309 bool isSetter = false; 1309 bool isSetter = false;
1310 if (executableElement is PropertyAccessorElement) { 1310 if (executableElement is PropertyAccessorElement) {
1311 PropertyAccessorElement accessorElement = executableElement; 1311 PropertyAccessorElement accessorElement = executableElement;
1312 isGetter = accessorElement.isGetter; 1312 isGetter = accessorElement.isGetter;
1313 isSetter = accessorElement.isSetter; 1313 isSetter = accessorElement.isSetter;
1314 } 1314 }
1315 String executableElementName = executableElement.name;
1316 FunctionType overridingFT = executableElement.type; 1315 FunctionType overridingFT = executableElement.type;
1317 FunctionType overriddenFT = overriddenExecutable.type; 1316 FunctionType overriddenFT = overriddenExecutable.type;
1318 InterfaceType enclosingType = _enclosingClass.type;
1319 overriddenFT = _inheritanceManager
1320 .substituteTypeArgumentsInMemberFromInheritance(
1321 overriddenFT, executableElementName, enclosingType);
1322 if (overridingFT == null || overriddenFT == null) { 1317 if (overridingFT == null || overriddenFT == null) {
1323 return false; 1318 return false;
1324 } 1319 }
1325 DartType overridingFTReturnType = overridingFT.returnType; 1320 DartType overridingFTReturnType = overridingFT.returnType;
1326 DartType overriddenFTReturnType = overriddenFT.returnType; 1321 DartType overriddenFTReturnType = overriddenFT.returnType;
1327 List<DartType> overridingNormalPT = overridingFT.normalParameterTypes; 1322 List<DartType> overridingNormalPT = overridingFT.normalParameterTypes;
1328 List<DartType> overriddenNormalPT = overriddenFT.normalParameterTypes; 1323 List<DartType> overriddenNormalPT = overriddenFT.normalParameterTypes;
1329 List<DartType> overridingPositionalPT = overridingFT.optionalParameterTypes; 1324 List<DartType> overridingPositionalPT = overridingFT.optionalParameterTypes;
1330 List<DartType> overriddenPositionalPT = overriddenFT.optionalParameterTypes; 1325 List<DartType> overriddenPositionalPT = overriddenFT.optionalParameterTypes;
1331 Map<String, DartType> overridingNamedPT = overridingFT.namedParameterTypes; 1326 Map<String, DartType> overridingNamedPT = overridingFT.namedParameterTypes;
(...skipping 3144 matching lines...) Expand 10 before | Expand all | Expand 10 after
4476 continue; 4471 continue;
4477 } 4472 }
4478 // Some element was found in the superclass chain that matches the name 4473 // Some element was found in the superclass chain that matches the name
4479 // of the required member. 4474 // of the required member.
4480 // If it is not abstract and it is the correct one (types match- the 4475 // If it is not abstract and it is the correct one (types match- the
4481 // version of this method that we have has the correct number of 4476 // version of this method that we have has the correct number of
4482 // parameters, etc), then this class has a valid implementation of this 4477 // parameters, etc), then this class has a valid implementation of this
4483 // method, so skip it. 4478 // method, so skip it.
4484 if ((elt is MethodElement && !elt.isAbstract) || 4479 if ((elt is MethodElement && !elt.isAbstract) ||
4485 (elt is PropertyAccessorElement && !elt.isAbstract)) { 4480 (elt is PropertyAccessorElement && !elt.isAbstract)) {
4486 // Since we are comparing two function types, we need to do the 4481 if (_typeSystem.isSubtypeOf(concreteType, requiredMemberType)) {
4487 // appropriate type substitutions first ().
4488 FunctionType foundConcreteFT = _inheritanceManager
4489 .substituteTypeArgumentsInMemberFromInheritance(
4490 concreteType, memberName, enclosingType);
4491 FunctionType requiredMemberFT = _inheritanceManager
4492 .substituteTypeArgumentsInMemberFromInheritance(
4493 requiredMemberType, memberName, enclosingType);
4494 if (_typeSystem.isSubtypeOf(foundConcreteFT, requiredMemberFT)) {
4495 continue; 4482 continue;
4496 } 4483 }
4497 } 4484 }
4498 } 4485 }
4499 // The not qualifying concrete executable element was found, add it to the 4486 // The not qualifying concrete executable element was found, add it to the
4500 // list. 4487 // list.
4501 missingOverrides.add(executableElt); 4488 missingOverrides.add(executableElt);
4502 } 4489 }
4503 // Now that we have the set of missing overrides, generate a warning on this 4490 // Now that we have the set of missing overrides, generate a warning on this
4504 // class. 4491 // class.
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after
6071 toCheck.add(type.element); 6058 toCheck.add(type.element);
6072 // type arguments 6059 // type arguments
6073 if (type is InterfaceType) { 6060 if (type is InterfaceType) {
6074 InterfaceType interfaceType = type; 6061 InterfaceType interfaceType = type;
6075 for (DartType typeArgument in interfaceType.typeArguments) { 6062 for (DartType typeArgument in interfaceType.typeArguments) {
6076 _addTypeToCheck(typeArgument); 6063 _addTypeToCheck(typeArgument);
6077 } 6064 }
6078 } 6065 }
6079 } 6066 }
6080 } 6067 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698