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 8112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8123 | 8123 |
8124 /** | 8124 /** |
8125 * Get the [UnlinkedTypeParam]s representing the type parameters declared by | 8125 * Get the [UnlinkedTypeParam]s representing the type parameters declared by |
8126 * this element. | 8126 * this element. |
8127 * | 8127 * |
8128 * TODO(scheglov) make private after switching linker to Impl | 8128 * TODO(scheglov) make private after switching linker to Impl |
8129 */ | 8129 */ |
8130 List<UnlinkedTypeParam> get unlinkedTypeParams; | 8130 List<UnlinkedTypeParam> get unlinkedTypeParams; |
8131 | 8131 |
8132 /** | 8132 /** |
8133 * Determine the default value of type argument [i]. in most cases this will | |
8134 * be `dynamic`, but sometimes it will be the bound of the ith type parameter. | |
8135 */ | |
8136 DartType computeDefaultTypeArgument(int i) { | |
8137 // If strong mode is off, or we can tell quickly from the summary that there | |
8138 // is no bound, then the default type argument is `dynamic`; we don't have | |
8139 // to call `typeParameters` to find that out. | |
8140 if (!context.analysisOptions.strongMode || | |
8141 (unlinkedTypeParams != null && unlinkedTypeParams[i].bound == null)) { | |
8142 return DynamicTypeImpl.instance; | |
8143 } | |
8144 return typeParameters[i].bound ?? DynamicTypeImpl.instance; | |
8145 } | |
8146 | |
8147 /** | |
8148 * Convert the given [index] into a type parameter type. | 8133 * Convert the given [index] into a type parameter type. |
8149 */ | 8134 */ |
8150 TypeParameterType getTypeParameterType(int index) { | 8135 TypeParameterType getTypeParameterType(int index) { |
8151 List<TypeParameterType> types = typeParameterTypes; | 8136 List<TypeParameterType> types = typeParameterTypes; |
8152 if (index <= types.length) { | 8137 if (index <= types.length) { |
8153 return types[types.length - index]; | 8138 return types[types.length - index]; |
8154 } else if (enclosingTypeParameterContext != null) { | 8139 } else if (enclosingTypeParameterContext != null) { |
8155 return enclosingTypeParameterContext | 8140 return enclosingTypeParameterContext |
8156 .getTypeParameterType(index - types.length); | 8141 .getTypeParameterType(index - types.length); |
8157 } else { | 8142 } else { |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8445 | 8430 |
8446 @override | 8431 @override |
8447 void visitElement(Element element) { | 8432 void visitElement(Element element) { |
8448 int offset = element.nameOffset; | 8433 int offset = element.nameOffset; |
8449 if (offset != -1) { | 8434 if (offset != -1) { |
8450 map[offset] = element; | 8435 map[offset] = element; |
8451 } | 8436 } |
8452 super.visitElement(element); | 8437 super.visitElement(element); |
8453 } | 8438 } |
8454 } | 8439 } |
OLD | NEW |