| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.task.strong_mode; | 5 library analyzer.src.task.strong_mode; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 classElement.constructors.forEach(_inferConstructorFieldFormals); | 232 classElement.constructors.forEach(_inferConstructorFieldFormals); |
| 233 classElement.hasBeenInferred = true; | 233 classElement.hasBeenInferred = true; |
| 234 } finally { | 234 } finally { |
| 235 elementsBeingInferred.remove(classElement); | 235 elementsBeingInferred.remove(classElement); |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 void _inferConstructorFieldFormals(ConstructorElement element) { | 240 void _inferConstructorFieldFormals(ConstructorElement element) { |
| 241 for (ParameterElement p in element.parameters) { | 241 for (ParameterElement p in element.parameters) { |
| 242 if (p is FieldFormalParameterElement) { | 242 if (p is FieldFormalParameterElementImpl) { |
| 243 _inferFieldFormalParameter(p); | 243 _inferFieldFormalParameter(p); |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 /** | 248 /** |
| 249 * If the given [element] represents a non-synthetic instance method, | 249 * If the given [element] represents a non-synthetic instance method, |
| 250 * getter or setter, infer the return type and any parameter type(s) where | 250 * getter or setter, infer the return type and any parameter type(s) where |
| 251 * they were not provided. | 251 * they were not provided. |
| 252 */ | 252 */ |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 newType = fieldElement.initializer.returnType; | 368 newType = fieldElement.initializer.returnType; |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 if (newType == null || newType.isBottom || newType.isDartCoreNull) { | 371 if (newType == null || newType.isBottom || newType.isDartCoreNull) { |
| 372 newType = typeProvider.dynamicType; | 372 newType = typeProvider.dynamicType; |
| 373 } | 373 } |
| 374 setFieldType(fieldElement, newType); | 374 setFieldType(fieldElement, newType); |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 | 377 |
| 378 void _inferFieldFormalParameter(FieldFormalParameterElement element) { | 378 void _inferFieldFormalParameter(FieldFormalParameterElementImpl element) { |
| 379 FieldElement field = element.field; | 379 FieldElement field = element.field; |
| 380 if (field != null && element.hasImplicitType) { | 380 if (field != null && element.hasImplicitType) { |
| 381 (element as FieldFormalParameterElementImpl).type = field.type; | 381 element.type = field.type; |
| 382 } | 382 } |
| 383 } | 383 } |
| 384 | 384 |
| 385 /** | 385 /** |
| 386 * If a parameter is covariant, any parameters that override it are too. | 386 * If a parameter is covariant, any parameters that override it are too. |
| 387 */ | 387 */ |
| 388 void _inferParameterCovariance(ParameterElementImpl parameter, int index, | 388 void _inferParameterCovariance(ParameterElementImpl parameter, int index, |
| 389 Iterable<FunctionType> overriddenTypes) { | 389 Iterable<FunctionType> overriddenTypes) { |
| 390 parameter.inheritsCovariant = overriddenTypes.any((f) { | 390 parameter.inheritsCovariant = overriddenTypes.any((f) { |
| 391 var param = _getCorrespondingParameter(parameter, index, f.parameters); | 391 var param = _getCorrespondingParameter(parameter, index, f.parameters); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 results.add(element); | 498 results.add(element); |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 } | 501 } |
| 502 } | 502 } |
| 503 | 503 |
| 504 /** | 504 /** |
| 505 * A class of exception that is not used anywhere else. | 505 * A class of exception that is not used anywhere else. |
| 506 */ | 506 */ |
| 507 class _CycleException implements Exception {} | 507 class _CycleException implements Exception {} |
| OLD | NEW |