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

Unified Diff: pkg/analyzer/lib/src/generated/static_type_analyzer.dart

Issue 1918923003: Remove unnecessary casts and general code clean-up (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: clean-up Created 4 years, 8 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/static_type_analyzer.dart
diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
index de346c55c615cdcfb46a5594b5b25840e27791a0..7eb4a8b67662448779d2aef9da7683a18964a28d 100644
--- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
+++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
@@ -1517,8 +1517,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
*/
DartType _computePropagatedReturnTypeOfFunction(FunctionBody body) {
if (body is ExpressionFunctionBody) {
- ExpressionFunctionBody expressionBody = body;
- return expressionBody.expression.bestType;
+ return body.expression.bestType;
}
if (body is BlockFunctionBody) {
_StaticTypeAnalyzer_computePropagatedReturnTypeOfFunction visitor =
@@ -1758,16 +1757,13 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
* Return the propagated type of the given [Element], or `null`.
*/
DartType _getPropertyPropagatedType(Element element, DartType currentType) {
- if (element is PropertyAccessorElement) {
- PropertyAccessorElement accessor = element;
- if (accessor.isGetter) {
- PropertyInducingElement variable = accessor.variable;
- DartType propagatedType = variable.propagatedType;
- if (currentType == null ||
- propagatedType != null &&
- propagatedType.isMoreSpecificThan(currentType)) {
- return propagatedType;
- }
+ if (element is PropertyAccessorElement && element.isGetter) {
+ PropertyInducingElement variable = element.variable;
+ DartType propagatedType = variable.propagatedType;
+ if (currentType == null ||
+ propagatedType != null &&
+ propagatedType.isMoreSpecificThan(currentType)) {
+ return propagatedType;
}
}
return currentType;
@@ -1924,12 +1920,13 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
VariableDeclaration node, Expression initializer) {
if (initializer != null &&
(node.parent as VariableDeclarationList).type == null &&
- (node.element is LocalVariableElementImpl) &&
(initializer.staticType != null) &&
(!initializer.staticType.isBottom)) {
- LocalVariableElementImpl element = node.element;
- element.type = initializer.staticType;
- node.name.staticType = initializer.staticType;
+ VariableElement element = node.element;
+ if (element is LocalVariableElementImpl) {
+ element.type = initializer.staticType;
+ node.name.staticType = initializer.staticType;
+ }
}
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698