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

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2002353006: Fix some corner cases of inferring type parameters from bounds. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/lib/src/summary/link.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.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 6613 matching lines...) Expand 10 before | Expand all | Expand 10 after
6624 6624
6625 /** 6625 /**
6626 * Get the [UnlinkedTypeParam]s representing the type parameters declared by 6626 * Get the [UnlinkedTypeParam]s representing the type parameters declared by
6627 * this element. 6627 * this element.
6628 * 6628 *
6629 * TODO(scheglov) make private after switching linker to Impl 6629 * TODO(scheglov) make private after switching linker to Impl
6630 */ 6630 */
6631 List<UnlinkedTypeParam> get unlinkedTypeParams; 6631 List<UnlinkedTypeParam> get unlinkedTypeParams;
6632 6632
6633 /** 6633 /**
6634 * Determine the default value of type argument [i]. in most cases this will
6635 * be `dynamic`, but sometimes it will be the bound of the ith type parameter.
6636 */
6637 DartType computeDefaultTypeArgument(int i) {
6638 // If strong mode is off, or we can tell quickly from the summary that there
6639 // is no bound, then the default type argument is `dynamic`; we don't have
6640 // to call `typeParameters` to find that out.
6641 if (!context.analysisOptions.strongMode ||
6642 (unlinkedTypeParams != null && unlinkedTypeParams[i].bound == null)) {
6643 return DynamicTypeImpl.instance;
6644 }
6645 return typeParameters[i].bound ?? DynamicTypeImpl.instance;
6646 }
6647
6648 /**
6634 * Convert the given [index] into a type parameter type. 6649 * Convert the given [index] into a type parameter type.
6635 */ 6650 */
6636 TypeParameterType getTypeParameterType(int index) { 6651 TypeParameterType getTypeParameterType(int index) {
6637 List<TypeParameterType> types = typeParameterTypes; 6652 List<TypeParameterType> types = typeParameterTypes;
6638 if (index <= types.length) { 6653 if (index <= types.length) {
6639 return types[types.length - index]; 6654 return types[types.length - index];
6640 } else if (enclosingTypeParameterContext != null) { 6655 } else if (enclosingTypeParameterContext != null) {
6641 return enclosingTypeParameterContext 6656 return enclosingTypeParameterContext
6642 .getTypeParameterType(index - types.length); 6657 .getTypeParameterType(index - types.length);
6643 } else { 6658 } else {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
6875 6890
6876 @override 6891 @override
6877 void visitElement(Element element) { 6892 void visitElement(Element element) {
6878 int offset = element.nameOffset; 6893 int offset = element.nameOffset;
6879 if (offset != -1) { 6894 if (offset != -1) {
6880 map[offset] = element; 6895 map[offset] = element;
6881 } 6896 }
6882 super.visitElement(element); 6897 super.visitElement(element);
6883 } 6898 }
6884 } 6899 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/link.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698