| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |