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

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

Issue 2207473004: fixes #26993, constant evaluation gets wrong type (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rebase and sort Created 4 years, 4 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.static_type_analyzer; 5 library analyzer.src.generated.static_type_analyzer;
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/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 2004
2005 ArgumentList arguments = node.argumentList; 2005 ArgumentList arguments = node.argumentList;
2006 FunctionType inferred = _inferGenericInvoke( 2006 FunctionType inferred = _inferGenericInvoke(
2007 node, constructorType, constructor.type.typeArguments, arguments); 2007 node, constructorType, constructor.type.typeArguments, arguments);
2008 2008
2009 if (inferred != null && inferred != originalElement.type) { 2009 if (inferred != null && inferred != originalElement.type) {
2010 // Fix up the parameter elements based on inferred method. 2010 // Fix up the parameter elements based on inferred method.
2011 arguments.correspondingStaticParameters = ResolverVisitor 2011 arguments.correspondingStaticParameters = ResolverVisitor
2012 .resolveArgumentsToParameters(arguments, inferred.parameters, null); 2012 .resolveArgumentsToParameters(arguments, inferred.parameters, null);
2013 inferConstructorName(constructor, inferred.returnType); 2013 inferConstructorName(constructor, inferred.returnType);
2014 // TODO(jmesserly): should we fix up the staticElement as well? 2014 // Update the static element as well. This is used in some cases, such as
2015 // computing constant values. It is stored in two places.
2016 constructor.staticElement =
2017 ConstructorMember.from(rawElement, inferred.returnType);
2018 node.staticElement = constructor.staticElement;
2015 } 2019 }
2016 } 2020 }
2017 2021
2018 /** 2022 /**
2019 * Given a local variable declaration and its initializer, attempt to infer 2023 * Given a local variable declaration and its initializer, attempt to infer
2020 * a type for the local variable declaration based on the initializer. 2024 * a type for the local variable declaration based on the initializer.
2021 * Inference is only done if an explicit type is not present, and if 2025 * Inference is only done if an explicit type is not present, and if
2022 * inferring a type improves the type. 2026 * inferring a type improves the type.
2023 */ 2027 */
2024 void _inferLocalVariableType( 2028 void _inferLocalVariableType(
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 } 2342 }
2339 // merge types 2343 // merge types
2340 if (result == null) { 2344 if (result == null) {
2341 result = type; 2345 result = type;
2342 } else { 2346 } else {
2343 result = _typeSystem.getLeastUpperBound(_typeProvider, result, type); 2347 result = _typeSystem.getLeastUpperBound(_typeProvider, result, type);
2344 } 2348 }
2345 return null; 2349 return null;
2346 } 2350 }
2347 } 2351 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698