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

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

Issue 2375373002: fix #27040, promote the upper bound of a type parameter (Closed)
Patch Set: guard Created 4 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 analyzer.src.generated.resolver; 5 library analyzer.src.generated.resolver;
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 6869 matching lines...) Expand 10 before | Expand all | Expand 10 after
6880 return; 6880 return;
6881 } 6881 }
6882 // prepare current variable type 6882 // prepare current variable type
6883 DartType type = _promoteManager.getType(element) ?? 6883 DartType type = _promoteManager.getType(element) ??
6884 expression.staticType ?? 6884 expression.staticType ??
6885 DynamicTypeImpl.instance; 6885 DynamicTypeImpl.instance;
6886 6886
6887 potentialType ??= DynamicTypeImpl.instance; 6887 potentialType ??= DynamicTypeImpl.instance;
6888 6888
6889 // Check if we can promote to potentialType from type. 6889 // Check if we can promote to potentialType from type.
6890 if (typeSystem.canPromoteToType(potentialType, type)) { 6890 DartType promoteType = typeSystem.tryPromoteToType(potentialType, type);
6891 if (promoteType != null) {
6891 // Do promote type of variable. 6892 // Do promote type of variable.
6892 _promoteManager.setType(element, potentialType); 6893 _promoteManager.setType(element, promoteType);
6893 } 6894 }
6894 } 6895 }
6895 } 6896 }
6896 6897
6897 /** 6898 /**
6898 * Promotes type information using given condition. 6899 * Promotes type information using given condition.
6899 */ 6900 */
6900 void _promoteTypes(Expression condition) { 6901 void _promoteTypes(Expression condition) {
6901 if (condition is BinaryExpression) { 6902 if (condition is BinaryExpression) {
6902 if (condition.operator.type == TokenType.AMPERSAND_AMPERSAND) { 6903 if (condition.operator.type == TokenType.AMPERSAND_AMPERSAND) {
(...skipping 3817 matching lines...) Expand 10 before | Expand all | Expand 10 after
10720 return null; 10721 return null;
10721 } 10722 }
10722 if (identical(node.staticElement, variable)) { 10723 if (identical(node.staticElement, variable)) {
10723 if (node.inSetterContext()) { 10724 if (node.inSetterContext()) {
10724 result = true; 10725 result = true;
10725 } 10726 }
10726 } 10727 }
10727 return null; 10728 return null;
10728 } 10729 }
10729 } 10730 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698