Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /** | 5 /** |
| 6 * This library is capable of producing linked summaries from unlinked | 6 * This library is capable of producing linked summaries from unlinked |
| 7 * ones (or prelinked ones). It functions by building a miniature | 7 * ones (or prelinked ones). It functions by building a miniature |
| 8 * element model to represent the contents of the summaries, and then | 8 * element model to represent the contents of the summaries, and then |
| 9 * scanning the element model to gather linked information and adding | 9 * scanning the element model to gather linked information and adding |
| 10 * it to the summary data structures. | 10 * it to the summary data structures. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 | 153 |
| 154 /** | 154 /** |
| 155 * Create an [EntityRefBuilder] representing the given [type], in a form | 155 * Create an [EntityRefBuilder] representing the given [type], in a form |
| 156 * suitable for inclusion in [LinkedUnit.types]. [compilationUnit] is the | 156 * suitable for inclusion in [LinkedUnit.types]. [compilationUnit] is the |
| 157 * compilation unit in which the type will be used. If [slot] is provided, it | 157 * compilation unit in which the type will be used. If [slot] is provided, it |
| 158 * is stored in [EntityRefBuilder.slot]. | 158 * is stored in [EntityRefBuilder.slot]. |
| 159 */ | 159 */ |
| 160 EntityRefBuilder _createLinkedType( | 160 EntityRefBuilder _createLinkedType( |
| 161 DartType type, | 161 DartType type, |
| 162 CompilationUnitElementInBuildUnit compilationUnit, | 162 CompilationUnitElementInBuildUnit compilationUnit, |
| 163 TypeParameterizedElementForLink typeParameterContext, | 163 TypeParameterizedElementMixin typeParameterContext, |
| 164 {int slot}) { | 164 {int slot}) { |
| 165 EntityRefBuilder result = new EntityRefBuilder(slot: slot); | 165 EntityRefBuilder result = new EntityRefBuilder(slot: slot); |
| 166 if (type is InterfaceType) { | 166 if (type is InterfaceType) { |
| 167 ClassElementForLink element = type.element; | 167 ClassElementForLink element = type.element; |
| 168 result.reference = compilationUnit.addReference(element); | 168 result.reference = compilationUnit.addReference(element); |
| 169 _storeTypeArguments( | 169 _storeTypeArguments( |
| 170 type.typeArguments, result, compilationUnit, typeParameterContext); | 170 type.typeArguments, result, compilationUnit, typeParameterContext); |
| 171 return result; | 171 return result; |
| 172 } else if (type is DynamicTypeImpl) { | 172 } else if (type is DynamicTypeImpl) { |
| 173 result.reference = compilationUnit.addRawReference('dynamic'); | 173 result.reference = compilationUnit.addRawReference('dynamic'); |
| 174 return result; | 174 return result; |
| 175 } else if (type is VoidTypeImpl) { | 175 } else if (type is VoidTypeImpl) { |
| 176 result.reference = compilationUnit.addRawReference('void'); | 176 result.reference = compilationUnit.addRawReference('void'); |
| 177 return result; | 177 return result; |
| 178 } else if (type is BottomTypeImpl) { | 178 } else if (type is BottomTypeImpl) { |
| 179 result.reference = compilationUnit.addRawReference('*bottom*'); | 179 result.reference = compilationUnit.addRawReference('*bottom*'); |
| 180 return result; | 180 return result; |
| 181 } else if (type is TypeParameterType) { | 181 } else if (type is TypeParameterType) { |
| 182 TypeParameterElementForLink element = type.element; | 182 TypeParameterElementImpl element = type.element; |
| 183 if (typeParameterContext.isTypeParameterInScope(element)) { | 183 if (typeParameterContext.isTypeParameterInScope(element)) { |
| 184 result.paramReference = | 184 result.paramReference = |
| 185 typeParameterContext.typeParameterNestingLevel - element.nestingLevel; | 185 typeParameterContext.typeParameterNestingLevel - element.nestingLevel; |
| 186 } else { | 186 } else { |
| 187 // Out-of-scope type parameters only occur in circumstances where they | 187 // Out-of-scope type parameters only occur in circumstances where they |
| 188 // are irrelevant (i.e. when a type parameter is unused). So we can | 188 // are irrelevant (i.e. when a type parameter is unused). So we can |
| 189 // safely convert them to `dynamic`. | 189 // safely convert them to `dynamic`. |
| 190 result.reference = compilationUnit.addRawReference('dynamic'); | 190 result.reference = compilationUnit.addRawReference('dynamic'); |
| 191 } | 191 } |
| 192 return result; | 192 return result; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 | 244 |
| 245 /** | 245 /** |
| 246 * Create an [UnlinkedParam] representing the given [parameter], which should be | 246 * Create an [UnlinkedParam] representing the given [parameter], which should be |
| 247 * a parameter of a synthetic function type (e.g. one produced during type | 247 * a parameter of a synthetic function type (e.g. one produced during type |
| 248 * inference as a result of computing the least upper bound of two function | 248 * inference as a result of computing the least upper bound of two function |
| 249 * types). | 249 * types). |
| 250 */ | 250 */ |
| 251 UnlinkedParamBuilder _serializeSyntheticParam( | 251 UnlinkedParamBuilder _serializeSyntheticParam( |
| 252 ParameterElement parameter, | 252 ParameterElement parameter, |
| 253 CompilationUnitElementInBuildUnit compilationUnit, | 253 CompilationUnitElementInBuildUnit compilationUnit, |
| 254 TypeParameterizedElementForLink typeParameterContext) { | 254 TypeParameterizedElementMixin typeParameterContext) { |
| 255 UnlinkedParamBuilder b = new UnlinkedParamBuilder(); | 255 UnlinkedParamBuilder b = new UnlinkedParamBuilder(); |
| 256 b.name = parameter.name; | 256 b.name = parameter.name; |
| 257 switch (parameter.parameterKind) { | 257 switch (parameter.parameterKind) { |
| 258 case ParameterKind.REQUIRED: | 258 case ParameterKind.REQUIRED: |
| 259 b.kind = UnlinkedParamKind.required; | 259 b.kind = UnlinkedParamKind.required; |
| 260 break; | 260 break; |
| 261 case ParameterKind.POSITIONAL: | 261 case ParameterKind.POSITIONAL: |
| 262 b.kind = UnlinkedParamKind.positional; | 262 b.kind = UnlinkedParamKind.positional; |
| 263 break; | 263 break; |
| 264 case ParameterKind.NAMED: | 264 case ParameterKind.NAMED: |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 283 } | 283 } |
| 284 | 284 |
| 285 /** | 285 /** |
| 286 * Store the given [typeArguments] in [encodedType], using [compilationUnit] and | 286 * Store the given [typeArguments] in [encodedType], using [compilationUnit] and |
| 287 * [typeParameterContext] to serialize them. | 287 * [typeParameterContext] to serialize them. |
| 288 */ | 288 */ |
| 289 void _storeTypeArguments( | 289 void _storeTypeArguments( |
| 290 List<DartType> typeArguments, | 290 List<DartType> typeArguments, |
| 291 EntityRefBuilder encodedType, | 291 EntityRefBuilder encodedType, |
| 292 CompilationUnitElementInBuildUnit compilationUnit, | 292 CompilationUnitElementInBuildUnit compilationUnit, |
| 293 TypeParameterizedElementForLink typeParameterContext) { | 293 TypeParameterizedElementMixin typeParameterContext) { |
| 294 int count = typeArguments.length; | 294 int count = typeArguments.length; |
| 295 List<EntityRefBuilder> encodedTypeArguments = | 295 List<EntityRefBuilder> encodedTypeArguments = |
| 296 new List<EntityRefBuilder>(count); | 296 new List<EntityRefBuilder>(count); |
| 297 for (int i = 0; i < count; i++) { | 297 for (int i = 0; i < count; i++) { |
| 298 encodedTypeArguments[i] = _createLinkedType( | 298 encodedTypeArguments[i] = _createLinkedType( |
| 299 typeArguments[i], compilationUnit, typeParameterContext); | 299 typeArguments[i], compilationUnit, typeParameterContext); |
| 300 } | 300 } |
| 301 encodedType.typeArguments = encodedTypeArguments; | 301 encodedType.typeArguments = encodedTypeArguments; |
| 302 } | 302 } |
| 303 | 303 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 @override | 356 @override |
| 357 LibraryElementForLink get library => enclosingElement.library; | 357 LibraryElementForLink get library => enclosingElement.library; |
| 358 | 358 |
| 359 @override | 359 @override |
| 360 List<MethodElementForLink> get methods; | 360 List<MethodElementForLink> get methods; |
| 361 | 361 |
| 362 @override | 362 @override |
| 363 String get name; | 363 String get name; |
| 364 | 364 |
| 365 @override | 365 @override |
| 366 ResynthesizerContext get resynthesizerContext => enclosingElement; | |
| 367 | |
| 368 @override | |
| 366 ConstructorElementForLink get unnamedConstructor; | 369 ConstructorElementForLink get unnamedConstructor; |
| 367 | 370 |
| 368 @override | 371 @override |
| 369 ReferenceableElementForLink getContainedName(String name) { | 372 ReferenceableElementForLink getContainedName(String name) { |
| 370 if (_containedNames == null) { | 373 if (_containedNames == null) { |
| 371 _containedNames = <String, ReferenceableElementForLink>{}; | 374 _containedNames = <String, ReferenceableElementForLink>{}; |
| 372 // TODO(paulberry): what's the correct way to handle name conflicts? | 375 // TODO(paulberry): what's the correct way to handle name conflicts? |
| 373 for (ConstructorElementForLink constructor in constructors) { | 376 for (ConstructorElementForLink constructor in constructors) { |
| 374 _containedNames[constructor.name] = constructor; | 377 _containedNames[constructor.name] = constructor; |
| 375 } | 378 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 396 | 399 |
| 397 @override | 400 @override |
| 398 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 401 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 399 } | 402 } |
| 400 | 403 |
| 401 /** | 404 /** |
| 402 * Element representing a class resynthesized from a summary during | 405 * Element representing a class resynthesized from a summary during |
| 403 * linking. | 406 * linking. |
| 404 */ | 407 */ |
| 405 class ClassElementForLink_Class extends ClassElementForLink | 408 class ClassElementForLink_Class extends ClassElementForLink |
| 406 with TypeParameterizedElementForLink { | 409 with TypeParameterizedElementMixin { |
| 407 /** | 410 /** |
| 408 * The unlinked representation of the class in the summary. | 411 * The unlinked representation of the class in the summary. |
| 409 */ | 412 */ |
| 410 final UnlinkedClass _unlinkedClass; | 413 final UnlinkedClass _unlinkedClass; |
| 411 | 414 |
| 412 List<ConstructorElementForLink> _constructors; | 415 List<ConstructorElementForLink> _constructors; |
| 413 ConstructorElementForLink _unnamedConstructor; | 416 ConstructorElementForLink _unnamedConstructor; |
| 414 bool _unnamedConstructorComputed = false; | 417 bool _unnamedConstructorComputed = false; |
| 415 List<FieldElementForLink_ClassField> _fields; | 418 List<FieldElementForLink_ClassField> _fields; |
| 416 InterfaceType _supertype; | 419 InterfaceType _supertype; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 _constructors.add(_unnamedConstructor); | 485 _constructors.add(_unnamedConstructor); |
| 483 } | 486 } |
| 484 } | 487 } |
| 485 return _constructors; | 488 return _constructors; |
| 486 } | 489 } |
| 487 | 490 |
| 488 @override | 491 @override |
| 489 String get displayName => _unlinkedClass.name; | 492 String get displayName => _unlinkedClass.name; |
| 490 | 493 |
| 491 @override | 494 @override |
| 492 TypeParameterizedElementForLink get enclosingTypeParameterContext => null; | 495 TypeParameterizedElementMixin get enclosingTypeParameterContext => null; |
| 493 | 496 |
| 494 @override | 497 @override |
| 495 List<FieldElementForLink_ClassField> get fields { | 498 List<FieldElementForLink_ClassField> get fields { |
| 496 if (_fields == null) { | 499 if (_fields == null) { |
| 497 _fields = <FieldElementForLink_ClassField>[]; | 500 _fields = <FieldElementForLink_ClassField>[]; |
| 498 for (UnlinkedVariable field in _unlinkedClass.fields) { | 501 for (UnlinkedVariable field in _unlinkedClass.fields) { |
| 499 _fields.add(new FieldElementForLink_ClassField(this, field)); | 502 _fields.add(new FieldElementForLink_ClassField(this, field)); |
| 500 } | 503 } |
| 501 } | 504 } |
| 502 return _fields; | 505 return _fields; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 return null; | 549 return null; |
| 547 } | 550 } |
| 548 return _supertype ??= _computeInterfaceType(_unlinkedClass.supertype); | 551 return _supertype ??= _computeInterfaceType(_unlinkedClass.supertype); |
| 549 } | 552 } |
| 550 | 553 |
| 551 @override | 554 @override |
| 552 DartType get type => | 555 DartType get type => |
| 553 _type ??= buildType((int i) => typeParameterTypes[i], null); | 556 _type ??= buildType((int i) => typeParameterTypes[i], null); |
| 554 | 557 |
| 555 @override | 558 @override |
| 559 List<UnlinkedTypeParam> get unlinkedTypeParams => | |
| 560 _unlinkedClass.typeParameters; | |
| 561 | |
| 562 @override | |
| 556 ConstructorElementForLink get unnamedConstructor { | 563 ConstructorElementForLink get unnamedConstructor { |
| 557 if (!_unnamedConstructorComputed) { | 564 if (!_unnamedConstructorComputed) { |
| 558 for (ConstructorElementForLink constructor in constructors) { | 565 for (ConstructorElementForLink constructor in constructors) { |
| 559 if (constructor.name.isEmpty) { | 566 if (constructor.name.isEmpty) { |
| 560 _unnamedConstructor = constructor; | 567 _unnamedConstructor = constructor; |
| 561 break; | 568 break; |
| 562 } | 569 } |
| 563 } | 570 } |
| 564 _unnamedConstructorComputed = true; | 571 _unnamedConstructorComputed = true; |
| 565 } | 572 } |
| 566 return _unnamedConstructor; | 573 return _unnamedConstructor; |
| 567 } | 574 } |
| 568 | 575 |
| 569 @override | 576 @override |
| 570 List<UnlinkedTypeParam> get _unlinkedTypeParams => | |
| 571 _unlinkedClass.typeParameters; | |
| 572 | |
| 573 @override | |
| 574 DartType buildType( | 577 DartType buildType( |
| 575 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { | 578 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { |
| 576 int numTypeParameters = _unlinkedClass.typeParameters.length; | 579 int numTypeParameters = _unlinkedClass.typeParameters.length; |
| 577 if (numTypeParameters != 0) { | 580 if (numTypeParameters != 0) { |
| 578 return new InterfaceTypeImpl.elementWithNameAndArgs(this, name, () { | 581 return new InterfaceTypeImpl.elementWithNameAndArgs(this, name, () { |
| 579 List<DartType> typeArguments = new List<DartType>(numTypeParameters); | 582 List<DartType> typeArguments = new List<DartType>(numTypeParameters); |
| 580 for (int i = 0; i < numTypeParameters; i++) { | 583 for (int i = 0; i < numTypeParameters; i++) { |
| 581 typeArguments[i] = getTypeArgument(i); | 584 typeArguments[i] = getTypeArgument(i); |
| 582 } | 585 } |
| 583 return typeArguments; | 586 return typeArguments; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 627 } | 630 } |
| 628 | 631 |
| 629 @override | 632 @override |
| 630 String toString() => '$enclosingElement.$name'; | 633 String toString() => '$enclosingElement.$name'; |
| 631 | 634 |
| 632 /** | 635 /** |
| 633 * Convert [typeRef] into an [InterfaceType]. | 636 * Convert [typeRef] into an [InterfaceType]. |
| 634 */ | 637 */ |
| 635 InterfaceType _computeInterfaceType(EntityRef typeRef) { | 638 InterfaceType _computeInterfaceType(EntityRef typeRef) { |
| 636 if (typeRef != null) { | 639 if (typeRef != null) { |
| 637 DartType type = enclosingElement._resolveTypeRef(typeRef, this); | 640 DartType type = enclosingElement.resolveTypeRef(typeRef, this); |
| 638 if (type is InterfaceType) { | 641 if (type is InterfaceType) { |
| 639 return type; | 642 return type; |
| 640 } | 643 } |
| 641 // In the event that the `typeRef` isn't an interface type (which may | 644 // In the event that the `typeRef` isn't an interface type (which may |
| 642 // happen in the event of erroneous code) just fall through and pretend | 645 // happen in the event of erroneous code) just fall through and pretend |
| 643 // the supertype is `Object`. | 646 // the supertype is `Object`. |
| 644 } | 647 } |
| 645 return enclosingElement.enclosingElement._linker.typeProvider.objectType; | 648 return enclosingElement.enclosingElement._linker.typeProvider.objectType; |
| 646 } | 649 } |
| 647 } | 650 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 737 | 740 |
| 738 @override | 741 @override |
| 739 String toString() => '$enclosingElement.$name'; | 742 String toString() => '$enclosingElement.$name'; |
| 740 } | 743 } |
| 741 | 744 |
| 742 /** | 745 /** |
| 743 * Element representing a compilation unit resynthesized from a | 746 * Element representing a compilation unit resynthesized from a |
| 744 * summary during linking. | 747 * summary during linking. |
| 745 */ | 748 */ |
| 746 abstract class CompilationUnitElementForLink | 749 abstract class CompilationUnitElementForLink |
| 747 implements CompilationUnitElementImpl { | 750 implements CompilationUnitElementImpl, ResynthesizerContext { |
| 748 /** | 751 /** |
| 749 * The unlinked representation of the compilation unit in the | 752 * The unlinked representation of the compilation unit in the |
| 750 * summary. | 753 * summary. |
| 751 */ | 754 */ |
| 752 final UnlinkedUnit _unlinkedUnit; | 755 final UnlinkedUnit _unlinkedUnit; |
| 753 | 756 |
| 754 /** | 757 /** |
| 755 * For each entry in [UnlinkedUnit.references], the element referred | 758 * For each entry in [UnlinkedUnit.references], the element referred |
| 756 * to by the reference, or `null` if it hasn't been located yet. | 759 * to by the reference, or `null` if it hasn't been located yet. |
| 757 */ | 760 */ |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 return _containedNames.putIfAbsent( | 937 return _containedNames.putIfAbsent( |
| 935 name, () => UndefinedElementForLink.instance); | 938 name, () => UndefinedElementForLink.instance); |
| 936 } | 939 } |
| 937 | 940 |
| 938 /** | 941 /** |
| 939 * Compute the type referred to by the given linked type [slot] (interpreted | 942 * Compute the type referred to by the given linked type [slot] (interpreted |
| 940 * relative to [typeParameterContext]). If there is no inferred type in the | 943 * relative to [typeParameterContext]). If there is no inferred type in the |
| 941 * given slot, `dynamic` is returned. | 944 * given slot, `dynamic` is returned. |
| 942 */ | 945 */ |
| 943 DartType getLinkedType( | 946 DartType getLinkedType( |
| 944 int slot, TypeParameterizedElementForLink typeParameterContext); | 947 int slot, TypeParameterizedElementMixin typeParameterContext); |
| 945 | 948 |
| 946 @override | 949 @override |
| 947 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 950 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 948 | 951 |
| 952 /** | |
| 953 * Resolve an [EntityRef] into a type. If the reference is | |
| 954 * unresolved, return [DynamicTypeImpl.instance]. | |
| 955 * | |
| 956 * TODO(paulberry): or should we have a class representing an | |
| 957 * unresolved type, for consistency with the full element model? | |
| 958 */ | |
|
Paul Berry
2016/05/17 19:28:02
Nit: remove this comment and add an "@override" an
scheglov
2016/05/17 19:42:21
Done.
| |
| 959 DartType resolveTypeRef( | |
| 960 EntityRef type, TypeParameterizedElementMixin typeParameterContext, | |
| 961 {bool defaultVoid: false, bool instantiateToBoundsAllowed: true}) { | |
| 962 if (type == null) { | |
| 963 if (defaultVoid) { | |
| 964 return VoidTypeImpl.instance; | |
| 965 } else { | |
| 966 return DynamicTypeImpl.instance; | |
| 967 } | |
| 968 } | |
| 969 if (type.paramReference != 0) { | |
| 970 return typeParameterContext.getTypeParameterType(type.paramReference); | |
| 971 } else if (type.syntheticReturnType != null) { | |
| 972 // TODO(paulberry): implement. | |
| 973 throw new UnimplementedError(); | |
| 974 } else if (type.implicitFunctionTypeIndices.isNotEmpty) { | |
| 975 // TODO(paulberry): implement. | |
| 976 throw new UnimplementedError(); | |
| 977 } else { | |
| 978 DartType getTypeArgument(int i) { | |
| 979 if (i < type.typeArguments.length) { | |
| 980 return resolveTypeRef(type.typeArguments[i], typeParameterContext); | |
| 981 } else { | |
| 982 return DynamicTypeImpl.instance; | |
| 983 } | |
| 984 } | |
| 985 ReferenceableElementForLink element = _resolveRef(type.reference); | |
| 986 return element.buildType( | |
| 987 getTypeArgument, type.implicitFunctionTypeIndices); | |
| 988 } | |
| 989 } | |
| 990 | |
| 949 @override | 991 @override |
| 950 String toString() => enclosingElement.toString(); | 992 String toString() => enclosingElement.toString(); |
| 951 | 993 |
| 952 /** | 994 /** |
| 953 * Return the element referred to by the given [index] in | 995 * Return the element referred to by the given [index] in |
| 954 * [UnlinkedUnit.references]. If the reference is unresolved, | 996 * [UnlinkedUnit.references]. If the reference is unresolved, |
| 955 * return [UndefinedElementForLink.instance]. | 997 * return [UndefinedElementForLink.instance]. |
| 956 */ | 998 */ |
| 957 ReferenceableElementForLink _resolveRef(int index) { | 999 ReferenceableElementForLink _resolveRef(int index) { |
| 958 if (_references[index] == null) { | 1000 if (_references[index] == null) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 983 _references[index] = enclosingElement.getContainedName(name); | 1025 _references[index] = enclosingElement.getContainedName(name); |
| 984 } | 1026 } |
| 985 } else { | 1027 } else { |
| 986 LibraryElementForLink dependency = | 1028 LibraryElementForLink dependency = |
| 987 enclosingElement._getDependency(linkedReference.dependency); | 1029 enclosingElement._getDependency(linkedReference.dependency); |
| 988 _references[index] = dependency.getContainedName(name); | 1030 _references[index] = dependency.getContainedName(name); |
| 989 } | 1031 } |
| 990 } | 1032 } |
| 991 return _references[index]; | 1033 return _references[index]; |
| 992 } | 1034 } |
| 993 | |
| 994 /** | |
| 995 * Resolve an [EntityRef] into a type. If the reference is | |
| 996 * unresolved, return [DynamicTypeImpl.instance]. | |
| 997 * | |
| 998 * TODO(paulberry): or should we have a class representing an | |
| 999 * unresolved type, for consistency with the full element model? | |
| 1000 */ | |
| 1001 DartType _resolveTypeRef( | |
| 1002 EntityRef type, TypeParameterizedElementForLink typeParameterContext, | |
| 1003 {bool defaultVoid: false}) { | |
| 1004 if (type == null) { | |
| 1005 if (defaultVoid) { | |
| 1006 return VoidTypeImpl.instance; | |
| 1007 } else { | |
| 1008 return DynamicTypeImpl.instance; | |
| 1009 } | |
| 1010 } | |
| 1011 if (type.paramReference != 0) { | |
| 1012 return typeParameterContext.getTypeParameterType(type.paramReference); | |
| 1013 } else if (type.syntheticReturnType != null) { | |
| 1014 // TODO(paulberry): implement. | |
| 1015 throw new UnimplementedError(); | |
| 1016 } else if (type.implicitFunctionTypeIndices.isNotEmpty) { | |
| 1017 // TODO(paulberry): implement. | |
| 1018 throw new UnimplementedError(); | |
| 1019 } else { | |
| 1020 DartType getTypeArgument(int i) { | |
| 1021 if (i < type.typeArguments.length) { | |
| 1022 return _resolveTypeRef(type.typeArguments[i], typeParameterContext); | |
| 1023 } else { | |
| 1024 return DynamicTypeImpl.instance; | |
| 1025 } | |
| 1026 } | |
| 1027 ReferenceableElementForLink element = _resolveRef(type.reference); | |
| 1028 return element.buildType( | |
| 1029 getTypeArgument, type.implicitFunctionTypeIndices); | |
| 1030 } | |
| 1031 } | |
| 1032 } | 1035 } |
| 1033 | 1036 |
| 1034 /** | 1037 /** |
| 1035 * Element representing a compilation unit which is part of the build | 1038 * Element representing a compilation unit which is part of the build |
| 1036 * unit being linked. | 1039 * unit being linked. |
| 1037 */ | 1040 */ |
| 1038 class CompilationUnitElementInBuildUnit extends CompilationUnitElementForLink { | 1041 class CompilationUnitElementInBuildUnit extends CompilationUnitElementForLink { |
| 1039 @override | 1042 @override |
| 1040 final LinkedUnitBuilder _linkedUnit; | 1043 final LinkedUnitBuilder _linkedUnit; |
| 1041 | 1044 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1173 return addRawReference(element.name, | 1176 return addRawReference(element.name, |
| 1174 containingReference: addReference(enclosingClass), | 1177 containingReference: addReference(enclosingClass), |
| 1175 kind: ReferenceKind.propertyAccessor); | 1178 kind: ReferenceKind.propertyAccessor); |
| 1176 } | 1179 } |
| 1177 // TODO(paulberry): implement other cases | 1180 // TODO(paulberry): implement other cases |
| 1178 throw new UnimplementedError('${element.runtimeType}'); | 1181 throw new UnimplementedError('${element.runtimeType}'); |
| 1179 } | 1182 } |
| 1180 | 1183 |
| 1181 @override | 1184 @override |
| 1182 DartType getLinkedType( | 1185 DartType getLinkedType( |
| 1183 int slot, TypeParameterizedElementForLink typeParameterContext) { | 1186 int slot, TypeParameterizedElementMixin typeParameterContext) { |
| 1184 // This method should only be called on compilation units that come from | 1187 // This method should only be called on compilation units that come from |
| 1185 // dependencies, never on compilation units that are part of the current | 1188 // dependencies, never on compilation units that are part of the current |
| 1186 // build unit. | 1189 // build unit. |
| 1187 throw new StateError( | 1190 throw new StateError( |
| 1188 'Linker tried to access linked type from current build unit'); | 1191 'Linker tried to access linked type from current build unit'); |
| 1189 } | 1192 } |
| 1190 | 1193 |
| 1191 /** | 1194 /** |
| 1192 * Perform type inference and const cycle detection on this | 1195 * Perform type inference and const cycle detection on this |
| 1193 * compilation unit. | 1196 * compilation unit. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1222 */ | 1225 */ |
| 1223 void _storeConstCycle(int slot) { | 1226 void _storeConstCycle(int slot) { |
| 1224 _linkedUnit.constCycles.add(slot); | 1227 _linkedUnit.constCycles.add(slot); |
| 1225 } | 1228 } |
| 1226 | 1229 |
| 1227 /** | 1230 /** |
| 1228 * Store the given [linkedType] in the given [slot] of the this compilation | 1231 * Store the given [linkedType] in the given [slot] of the this compilation |
| 1229 * unit's linked type list. | 1232 * unit's linked type list. |
| 1230 */ | 1233 */ |
| 1231 void _storeLinkedType(int slot, DartType linkedType, | 1234 void _storeLinkedType(int slot, DartType linkedType, |
| 1232 TypeParameterizedElementForLink typeParameterContext) { | 1235 TypeParameterizedElementMixin typeParameterContext) { |
| 1233 if (slot != 0) { | 1236 if (slot != 0) { |
| 1234 if (linkedType != null && !linkedType.isDynamic) { | 1237 if (linkedType != null && !linkedType.isDynamic) { |
| 1235 _linkedUnit.types.add(_createLinkedType( | 1238 _linkedUnit.types.add(_createLinkedType( |
| 1236 linkedType, this, typeParameterContext, | 1239 linkedType, this, typeParameterContext, |
| 1237 slot: slot)); | 1240 slot: slot)); |
| 1238 } | 1241 } |
| 1239 } | 1242 } |
| 1240 } | 1243 } |
| 1241 } | 1244 } |
| 1242 | 1245 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1279 for (EntityRef ref in _linkedUnit.types) { | 1282 for (EntityRef ref in _linkedUnit.types) { |
| 1280 _linkedTypeRefs[ref.slot] = ref; | 1283 _linkedTypeRefs[ref.slot] = ref; |
| 1281 } | 1284 } |
| 1282 } | 1285 } |
| 1283 | 1286 |
| 1284 @override | 1287 @override |
| 1285 bool get isInBuildUnit => false; | 1288 bool get isInBuildUnit => false; |
| 1286 | 1289 |
| 1287 @override | 1290 @override |
| 1288 DartType getLinkedType( | 1291 DartType getLinkedType( |
| 1289 int slot, TypeParameterizedElementForLink typeParameterContext) { | 1292 int slot, TypeParameterizedElementMixin typeParameterContext) { |
| 1290 if (slot < _linkedTypeRefs.length) { | 1293 if (slot < _linkedTypeRefs.length) { |
| 1291 return _resolveTypeRef(_linkedTypeRefs[slot], typeParameterContext); | 1294 return resolveTypeRef(_linkedTypeRefs[slot], typeParameterContext); |
| 1292 } else { | 1295 } else { |
| 1293 return DynamicTypeImpl.instance; | 1296 return DynamicTypeImpl.instance; |
| 1294 } | 1297 } |
| 1295 } | 1298 } |
| 1296 } | 1299 } |
| 1297 | 1300 |
| 1298 /** | 1301 /** |
| 1299 * Instance of [ConstNode] representing a constant constructor. | 1302 * Instance of [ConstNode] representing a constant constructor. |
| 1300 */ | 1303 */ |
| 1301 class ConstConstructorNode extends ConstNode { | 1304 class ConstConstructorNode extends ConstNode { |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1741 // Kick off the algorithm starting with the starting point. | 1744 // Kick off the algorithm starting with the starting point. |
| 1742 strongConnect(startingPoint); | 1745 strongConnect(startingPoint); |
| 1743 } | 1746 } |
| 1744 } | 1747 } |
| 1745 | 1748 |
| 1746 /** | 1749 /** |
| 1747 * Base class for executable elements resynthesized from a summary during | 1750 * Base class for executable elements resynthesized from a summary during |
| 1748 * linking. | 1751 * linking. |
| 1749 */ | 1752 */ |
| 1750 abstract class ExecutableElementForLink extends Object | 1753 abstract class ExecutableElementForLink extends Object |
| 1751 with TypeParameterizedElementForLink, ParameterParentElementForLink | 1754 with TypeParameterizedElementMixin, ParameterParentElementForLink |
| 1752 implements ExecutableElementImpl { | 1755 implements ExecutableElementImpl { |
| 1753 /** | 1756 /** |
| 1754 * The unlinked representation of the method in the summary. | 1757 * The unlinked representation of the method in the summary. |
| 1755 */ | 1758 */ |
| 1756 final UnlinkedExecutable _unlinkedExecutable; | 1759 final UnlinkedExecutable _unlinkedExecutable; |
| 1757 | 1760 |
| 1758 DartType _declaredReturnType; | 1761 DartType _declaredReturnType; |
| 1759 DartType _inferredReturnType; | 1762 DartType _inferredReturnType; |
| 1760 FunctionTypeImpl _type; | 1763 FunctionTypeImpl _type; |
| 1761 String _name; | 1764 String _name; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1775 | 1778 |
| 1776 /** | 1779 /** |
| 1777 * If the executable element had an explicitly declared return type, return | 1780 * If the executable element had an explicitly declared return type, return |
| 1778 * it. Otherwise return `null`. | 1781 * it. Otherwise return `null`. |
| 1779 */ | 1782 */ |
| 1780 DartType get declaredReturnType { | 1783 DartType get declaredReturnType { |
| 1781 if (_unlinkedExecutable.returnType == null) { | 1784 if (_unlinkedExecutable.returnType == null) { |
| 1782 return null; | 1785 return null; |
| 1783 } else { | 1786 } else { |
| 1784 return _declaredReturnType ??= | 1787 return _declaredReturnType ??= |
| 1785 compilationUnit._resolveTypeRef(_unlinkedExecutable.returnType, this); | 1788 compilationUnit.resolveTypeRef(_unlinkedExecutable.returnType, this); |
| 1786 } | 1789 } |
| 1787 } | 1790 } |
| 1788 | 1791 |
| 1789 @override | 1792 @override |
| 1790 String get displayName { | 1793 String get displayName { |
| 1791 if (_displayName == null) { | 1794 if (_displayName == null) { |
| 1792 _displayName = _unlinkedExecutable.name; | 1795 _displayName = _unlinkedExecutable.name; |
| 1793 if (_unlinkedExecutable.kind == UnlinkedExecutableKind.setter) { | 1796 if (_unlinkedExecutable.kind == UnlinkedExecutableKind.setter) { |
| 1794 _displayName = _displayName.substring(0, _displayName.length - 1); | 1797 _displayName = _displayName.substring(0, _displayName.length - 1); |
| 1795 } | 1798 } |
| 1796 } | 1799 } |
| 1797 return _displayName; | 1800 return _displayName; |
| 1798 } | 1801 } |
| 1799 | 1802 |
| 1800 @override | 1803 @override |
| 1801 Element get enclosingElement => enclosingClass ?? compilationUnit; | 1804 Element get enclosingElement => enclosingClass ?? compilationUnit; |
| 1802 | 1805 |
| 1803 @override | 1806 @override |
| 1804 TypeParameterizedElementForLink get enclosingTypeParameterContext => | 1807 TypeParameterizedElementMixin get enclosingTypeParameterContext => |
| 1805 enclosingClass; | 1808 enclosingClass; |
| 1806 | 1809 |
| 1807 @override | 1810 @override |
| 1808 bool get hasImplicitReturnType => _unlinkedExecutable.returnType == null; | 1811 bool get hasImplicitReturnType => _unlinkedExecutable.returnType == null; |
| 1809 | 1812 |
| 1810 @override | 1813 @override |
| 1811 List<int> get implicitFunctionTypeIndices => const <int>[]; | 1814 List<int> get implicitFunctionTypeIndices => const <int>[]; |
| 1812 | 1815 |
| 1813 /** | 1816 /** |
| 1814 * Return the inferred return type of the executable element. Should only be | 1817 * Return the inferred return type of the executable element. Should only be |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1853 if (_name == null) { | 1856 if (_name == null) { |
| 1854 _name = _unlinkedExecutable.name; | 1857 _name = _unlinkedExecutable.name; |
| 1855 if (_name == '-' && _unlinkedExecutable.parameters.isEmpty) { | 1858 if (_name == '-' && _unlinkedExecutable.parameters.isEmpty) { |
| 1856 _name = 'unary-'; | 1859 _name = 'unary-'; |
| 1857 } | 1860 } |
| 1858 } | 1861 } |
| 1859 return _name; | 1862 return _name; |
| 1860 } | 1863 } |
| 1861 | 1864 |
| 1862 @override | 1865 @override |
| 1866 ResynthesizerContext get resynthesizerContext => compilationUnit; | |
| 1867 | |
| 1868 @override | |
| 1863 DartType get returnType => declaredReturnType ?? inferredReturnType; | 1869 DartType get returnType => declaredReturnType ?? inferredReturnType; |
| 1864 | 1870 |
| 1865 @override | 1871 @override |
| 1866 void set returnType(DartType inferredType) { | 1872 void set returnType(DartType inferredType) { |
| 1867 assert(_inferredReturnType == null); | 1873 assert(_inferredReturnType == null); |
| 1868 _inferredReturnType = inferredType; | 1874 _inferredReturnType = inferredType; |
| 1869 } | 1875 } |
| 1870 | 1876 |
| 1871 @override | 1877 @override |
| 1872 FunctionTypeImpl get type => _type ??= new FunctionTypeImpl(this); | 1878 FunctionTypeImpl get type => _type ??= new FunctionTypeImpl(this); |
| 1873 | 1879 |
| 1874 @override | 1880 @override |
| 1875 TypeParameterizedElementForLink get typeParameterContext => this; | 1881 TypeParameterizedElementMixin get typeParameterContext => this; |
| 1876 | 1882 |
| 1877 @override | 1883 @override |
| 1878 List<UnlinkedParam> get unlinkedParameters => _unlinkedExecutable.parameters; | 1884 List<UnlinkedParam> get unlinkedParameters => _unlinkedExecutable.parameters; |
| 1879 | 1885 |
| 1880 @override | 1886 @override |
| 1881 List<UnlinkedTypeParam> get _unlinkedTypeParams => | 1887 List<UnlinkedTypeParam> get unlinkedTypeParams => |
| 1882 _unlinkedExecutable.typeParameters; | 1888 _unlinkedExecutable.typeParameters; |
| 1883 | 1889 |
| 1884 @override | 1890 @override |
| 1885 bool isAccessibleIn(LibraryElement library) => | 1891 bool isAccessibleIn(LibraryElement library) => |
| 1886 !Identifier.isPrivateName(name) || identical(this.library, library); | 1892 !Identifier.isPrivateName(name) || identical(this.library, library); |
| 1887 | 1893 |
| 1888 /** | 1894 /** |
| 1889 * Store the results of type inference for this method in [compilationUnit]. | 1895 * Store the results of type inference for this method in [compilationUnit]. |
| 1890 */ | 1896 */ |
| 1891 void link(CompilationUnitElementInBuildUnit compilationUnit) { | 1897 void link(CompilationUnitElementInBuildUnit compilationUnit) { |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2248 stack.length -= numNamed + numPositional; | 2254 stack.length -= numNamed + numPositional; |
| 2249 strPtr += numNamed; | 2255 strPtr += numNamed; |
| 2250 EntityRef ref = _getNextRef(); | 2256 EntityRef ref = _getNextRef(); |
| 2251 ConstructorElementForLink element = | 2257 ConstructorElementForLink element = |
| 2252 unit._resolveRef(ref.reference).asConstructor; | 2258 unit._resolveRef(ref.reference).asConstructor; |
| 2253 if (element != null) { | 2259 if (element != null) { |
| 2254 ClassElementForLink_Class enclosingClass = element.enclosingClass; | 2260 ClassElementForLink_Class enclosingClass = element.enclosingClass; |
| 2255 stack.add(enclosingClass.buildType((int i) { | 2261 stack.add(enclosingClass.buildType((int i) { |
| 2256 // Type argument explicitly specified. | 2262 // Type argument explicitly specified. |
| 2257 if (i < ref.typeArguments.length) { | 2263 if (i < ref.typeArguments.length) { |
| 2258 return unit._resolveTypeRef( | 2264 return unit.resolveTypeRef( |
| 2259 ref.typeArguments[i], variable._typeParameterContext); | 2265 ref.typeArguments[i], variable._typeParameterContext); |
| 2260 } | 2266 } |
| 2261 // In strong mode, type argument defaults to bound (if any). | 2267 // In strong mode, type argument defaults to bound (if any). |
| 2262 if (linker.strongMode) { | 2268 if (linker.strongMode) { |
| 2263 TypeParameterElement typeParameter = enclosingClass.typeParameters[i]; | 2269 TypeParameterElement typeParameter = enclosingClass.typeParameters[i]; |
| 2264 if (typeParameter.bound != null) { | 2270 if (typeParameter.bound != null) { |
| 2265 return typeParameter.bound; | 2271 return typeParameter.bound; |
| 2266 } | 2272 } |
| 2267 } | 2273 } |
| 2268 // Otherwise type argument defaults to `dynamic`. | 2274 // Otherwise type argument defaults to `dynamic`. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2388 List<String> _getNextStrings(int n) { | 2394 List<String> _getNextStrings(int n) { |
| 2389 List<String> result = new List<String>(n); | 2395 List<String> result = new List<String>(n); |
| 2390 for (int i = 0; i < n; i++) { | 2396 for (int i = 0; i < n; i++) { |
| 2391 result[i] = _getNextString(); | 2397 result[i] = _getNextString(); |
| 2392 } | 2398 } |
| 2393 return result; | 2399 return result; |
| 2394 } | 2400 } |
| 2395 | 2401 |
| 2396 DartType _getNextTypeRef() { | 2402 DartType _getNextTypeRef() { |
| 2397 EntityRef ref = _getNextRef(); | 2403 EntityRef ref = _getNextRef(); |
| 2398 return unit._resolveTypeRef(ref, variable._typeParameterContext); | 2404 return unit.resolveTypeRef(ref, variable._typeParameterContext); |
| 2399 } | 2405 } |
| 2400 | 2406 |
| 2401 /** | 2407 /** |
| 2402 * Return the type of the property with the given [propertyName] in the | 2408 * Return the type of the property with the given [propertyName] in the |
| 2403 * given [targetType]. May return `dynamic` if the property cannot be | 2409 * given [targetType]. May return `dynamic` if the property cannot be |
| 2404 * resolved. | 2410 * resolved. |
| 2405 */ | 2411 */ |
| 2406 DartType _getPropertyType(DartType targetType, String propertyName) { | 2412 DartType _getPropertyType(DartType targetType, String propertyName) { |
| 2407 return targetType is InterfaceType | 2413 return targetType is InterfaceType |
| 2408 ? targetType.lookUpGetter(propertyName, library)?.returnType | 2414 ? targetType.lookUpGetter(propertyName, library)?.returnType |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2575 bool get isStatic => unlinkedVariable.isStatic; | 2581 bool get isStatic => unlinkedVariable.isStatic; |
| 2576 | 2582 |
| 2577 @override | 2583 @override |
| 2578 void set type(DartType inferredType) { | 2584 void set type(DartType inferredType) { |
| 2579 assert(!isStatic); | 2585 assert(!isStatic); |
| 2580 assert(_inferredInstanceType == null); | 2586 assert(_inferredInstanceType == null); |
| 2581 _inferredInstanceType = inferredType; | 2587 _inferredInstanceType = inferredType; |
| 2582 } | 2588 } |
| 2583 | 2589 |
| 2584 @override | 2590 @override |
| 2585 TypeParameterizedElementForLink get _typeParameterContext => enclosingElement; | 2591 TypeParameterizedElementMixin get _typeParameterContext => enclosingElement; |
| 2586 | 2592 |
| 2587 /** | 2593 /** |
| 2588 * Store the results of type inference for this field in | 2594 * Store the results of type inference for this field in |
| 2589 * [compilationUnit]. | 2595 * [compilationUnit]. |
| 2590 */ | 2596 */ |
| 2591 void link(CompilationUnitElementInBuildUnit compilationUnit) { | 2597 void link(CompilationUnitElementInBuildUnit compilationUnit) { |
| 2592 if (hasImplicitType) { | 2598 if (hasImplicitType) { |
| 2593 compilationUnit._storeLinkedType( | 2599 compilationUnit._storeLinkedType( |
| 2594 unlinkedVariable.inferredTypeSlot, | 2600 unlinkedVariable.inferredTypeSlot, |
| 2595 isStatic ? inferredType : _inferredInstanceType, | 2601 isStatic ? inferredType : _inferredInstanceType, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2649 * Element representing a function-typed parameter resynthesied from a summary | 2655 * Element representing a function-typed parameter resynthesied from a summary |
| 2650 * during linking. | 2656 * during linking. |
| 2651 */ | 2657 */ |
| 2652 class FunctionElementForLink_FunctionTypedParam extends Object | 2658 class FunctionElementForLink_FunctionTypedParam extends Object |
| 2653 with ParameterParentElementForLink | 2659 with ParameterParentElementForLink |
| 2654 implements FunctionElement { | 2660 implements FunctionElement { |
| 2655 @override | 2661 @override |
| 2656 final ParameterElementForLink enclosingElement; | 2662 final ParameterElementForLink enclosingElement; |
| 2657 | 2663 |
| 2658 @override | 2664 @override |
| 2659 final TypeParameterizedElementForLink typeParameterContext; | 2665 final TypeParameterizedElementMixin typeParameterContext; |
| 2660 | 2666 |
| 2661 @override | 2667 @override |
| 2662 final List<UnlinkedParam> unlinkedParameters; | 2668 final List<UnlinkedParam> unlinkedParameters; |
| 2663 | 2669 |
| 2664 DartType _returnType; | 2670 DartType _returnType; |
| 2665 List<int> _implicitFunctionTypeIndices; | 2671 List<int> _implicitFunctionTypeIndices; |
| 2666 | 2672 |
| 2667 FunctionElementForLink_FunctionTypedParam(this.enclosingElement, | 2673 FunctionElementForLink_FunctionTypedParam(this.enclosingElement, |
| 2668 this.typeParameterContext, this.unlinkedParameters); | 2674 this.typeParameterContext, this.unlinkedParameters); |
| 2669 | 2675 |
| 2670 @override | 2676 @override |
| 2671 List<int> get implicitFunctionTypeIndices { | 2677 List<int> get implicitFunctionTypeIndices { |
| 2672 if (_implicitFunctionTypeIndices == null) { | 2678 if (_implicitFunctionTypeIndices == null) { |
| 2673 _implicitFunctionTypeIndices = enclosingElement | 2679 _implicitFunctionTypeIndices = enclosingElement |
| 2674 .enclosingElement.implicitFunctionTypeIndices | 2680 .enclosingElement.implicitFunctionTypeIndices |
| 2675 .toList(); | 2681 .toList(); |
| 2676 _implicitFunctionTypeIndices.add(enclosingElement._parameterIndex); | 2682 _implicitFunctionTypeIndices.add(enclosingElement._parameterIndex); |
| 2677 } | 2683 } |
| 2678 return _implicitFunctionTypeIndices; | 2684 return _implicitFunctionTypeIndices; |
| 2679 } | 2685 } |
| 2680 | 2686 |
| 2681 @override | 2687 @override |
| 2682 DartType get returnType { | 2688 DartType get returnType { |
| 2683 if (_returnType == null) { | 2689 if (_returnType == null) { |
| 2684 if (enclosingElement._unlinkedParam.type == null) { | 2690 if (enclosingElement._unlinkedParam.type == null) { |
| 2685 _returnType = DynamicTypeImpl.instance; | 2691 _returnType = DynamicTypeImpl.instance; |
| 2686 } else { | 2692 } else { |
| 2687 _returnType = enclosingElement.compilationUnit._resolveTypeRef( | 2693 _returnType = enclosingElement.compilationUnit.resolveTypeRef( |
| 2688 enclosingElement._unlinkedParam.type, typeParameterContext); | 2694 enclosingElement._unlinkedParam.type, typeParameterContext); |
| 2689 } | 2695 } |
| 2690 } | 2696 } |
| 2691 return _returnType; | 2697 return _returnType; |
| 2692 } | 2698 } |
| 2693 | 2699 |
| 2694 @override | 2700 @override |
| 2695 List<TypeParameterElement> get typeParameters => const []; | 2701 List<TypeParameterElement> get typeParameters => const []; |
| 2696 | 2702 |
| 2697 @override | 2703 @override |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2771 | 2777 |
| 2772 @override | 2778 @override |
| 2773 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2779 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2774 } | 2780 } |
| 2775 | 2781 |
| 2776 /** | 2782 /** |
| 2777 * Element representing a typedef resynthesized from a summary during linking. | 2783 * Element representing a typedef resynthesized from a summary during linking. |
| 2778 */ | 2784 */ |
| 2779 class FunctionTypeAliasElementForLink extends Object | 2785 class FunctionTypeAliasElementForLink extends Object |
| 2780 with | 2786 with |
| 2781 TypeParameterizedElementForLink, | 2787 TypeParameterizedElementMixin, |
| 2782 ParameterParentElementForLink, | 2788 ParameterParentElementForLink, |
| 2783 ReferenceableElementForLink | 2789 ReferenceableElementForLink |
| 2784 implements FunctionTypeAliasElement, ElementImpl { | 2790 implements FunctionTypeAliasElement, ElementImpl { |
| 2785 @override | 2791 @override |
| 2786 final CompilationUnitElementForLink enclosingElement; | 2792 final CompilationUnitElementForLink enclosingElement; |
| 2787 | 2793 |
| 2788 /** | 2794 /** |
| 2789 * The unlinked representation of the typedef in the summary. | 2795 * The unlinked representation of the typedef in the summary. |
| 2790 */ | 2796 */ |
| 2791 final UnlinkedTypedef _unlinkedTypedef; | 2797 final UnlinkedTypedef _unlinkedTypedef; |
| 2792 | 2798 |
| 2793 FunctionTypeImpl _type; | 2799 FunctionTypeImpl _type; |
| 2794 DartType _returnType; | 2800 DartType _returnType; |
| 2795 | 2801 |
| 2796 FunctionTypeAliasElementForLink(this.enclosingElement, this._unlinkedTypedef); | 2802 FunctionTypeAliasElementForLink(this.enclosingElement, this._unlinkedTypedef); |
| 2797 | 2803 |
| 2798 @override | 2804 @override |
| 2799 DartType get asStaticType { | 2805 DartType get asStaticType { |
| 2800 return enclosingElement.enclosingElement._linker.typeProvider.typeType; | 2806 return enclosingElement.enclosingElement._linker.typeProvider.typeType; |
| 2801 } | 2807 } |
| 2802 | 2808 |
| 2803 @override | 2809 @override |
| 2804 CompilationUnitElementForLink get compilationUnit => enclosingElement; | 2810 CompilationUnitElementForLink get compilationUnit => enclosingElement; |
| 2805 | 2811 |
| 2806 @override | 2812 @override |
| 2807 TypeParameterizedElementForLink get enclosingTypeParameterContext => null; | 2813 TypeParameterizedElementMixin get enclosingTypeParameterContext => null; |
| 2808 | 2814 |
| 2809 @override | 2815 @override |
| 2810 String get identifier => _unlinkedTypedef.name; | 2816 String get identifier => _unlinkedTypedef.name; |
| 2811 | 2817 |
| 2812 @override | 2818 @override |
| 2813 List<int> get implicitFunctionTypeIndices => const <int>[]; | 2819 List<int> get implicitFunctionTypeIndices => const <int>[]; |
| 2814 | 2820 |
| 2815 @override | 2821 @override |
| 2816 bool get isSynthetic => false; | 2822 bool get isSynthetic => false; |
| 2817 | 2823 |
| 2818 @override | 2824 @override |
| 2819 LibraryElementForLink get library => enclosingElement.library; | 2825 LibraryElementForLink get library => enclosingElement.library; |
| 2820 | 2826 |
| 2821 @override | 2827 @override |
| 2822 String get name => _unlinkedTypedef.name; | 2828 String get name => _unlinkedTypedef.name; |
| 2823 | 2829 |
| 2824 @override | 2830 @override |
| 2825 DartType get returnType => _returnType ??= | 2831 ResynthesizerContext get resynthesizerContext => enclosingElement; |
| 2826 enclosingElement._resolveTypeRef(_unlinkedTypedef.returnType, this); | |
| 2827 | 2832 |
| 2828 @override | 2833 @override |
| 2829 TypeParameterizedElementForLink get typeParameterContext => this; | 2834 DartType get returnType => _returnType ??= |
| 2835 enclosingElement.resolveTypeRef(_unlinkedTypedef.returnType, this); | |
| 2836 | |
| 2837 @override | |
| 2838 TypeParameterizedElementMixin get typeParameterContext => this; | |
| 2830 | 2839 |
| 2831 @override | 2840 @override |
| 2832 List<UnlinkedParam> get unlinkedParameters => _unlinkedTypedef.parameters; | 2841 List<UnlinkedParam> get unlinkedParameters => _unlinkedTypedef.parameters; |
| 2833 | 2842 |
| 2834 @override | 2843 @override |
| 2835 List<UnlinkedTypeParam> get _unlinkedTypeParams => | 2844 List<UnlinkedTypeParam> get unlinkedTypeParams => |
| 2836 _unlinkedTypedef.typeParameters; | 2845 _unlinkedTypedef.typeParameters; |
| 2837 | 2846 |
| 2838 @override | 2847 @override |
| 2839 DartType buildType( | 2848 DartType buildType( |
| 2840 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { | 2849 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { |
| 2841 int numTypeParameters = _unlinkedTypedef.typeParameters.length; | 2850 int numTypeParameters = _unlinkedTypedef.typeParameters.length; |
| 2842 if (numTypeParameters != 0) { | 2851 if (numTypeParameters != 0) { |
| 2843 List<DartType> typeArguments = new List<DartType>(numTypeParameters); | 2852 List<DartType> typeArguments = new List<DartType>(numTypeParameters); |
| 2844 for (int i = 0; i < numTypeParameters; i++) { | 2853 for (int i = 0; i < numTypeParameters; i++) { |
| 2845 typeArguments[i] = getTypeArgument(i); | 2854 typeArguments[i] = getTypeArgument(i); |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3533 */ | 3542 */ |
| 3534 class ParameterElementForLink implements ParameterElementImpl { | 3543 class ParameterElementForLink implements ParameterElementImpl { |
| 3535 /** | 3544 /** |
| 3536 * The unlinked representation of the parameter in the summary. | 3545 * The unlinked representation of the parameter in the summary. |
| 3537 */ | 3546 */ |
| 3538 final UnlinkedParam _unlinkedParam; | 3547 final UnlinkedParam _unlinkedParam; |
| 3539 | 3548 |
| 3540 /** | 3549 /** |
| 3541 * The innermost enclosing element that can declare type parameters. | 3550 * The innermost enclosing element that can declare type parameters. |
| 3542 */ | 3551 */ |
| 3543 final TypeParameterizedElementForLink _typeParameterContext; | 3552 final TypeParameterizedElementMixin _typeParameterContext; |
| 3544 | 3553 |
| 3545 /** | 3554 /** |
| 3546 * If this parameter has a default value and the enclosing library | 3555 * If this parameter has a default value and the enclosing library |
| 3547 * is part of the build unit being linked, the parameter's node in | 3556 * is part of the build unit being linked, the parameter's node in |
| 3548 * the constant evaluation dependency graph. Otherwise `null`. | 3557 * the constant evaluation dependency graph. Otherwise `null`. |
| 3549 */ | 3558 */ |
| 3550 ConstNode _constNode; | 3559 ConstNode _constNode; |
| 3551 | 3560 |
| 3552 /** | 3561 /** |
| 3553 * The compilation unit in which this parameter appears. | 3562 * The compilation unit in which this parameter appears. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3605 this, _typeParameterContext, _unlinkedParam.parameters)); | 3614 this, _typeParameterContext, _unlinkedParam.parameters)); |
| 3606 } else if (_unlinkedParam.type == null) { | 3615 } else if (_unlinkedParam.type == null) { |
| 3607 if (!compilationUnit.isInBuildUnit) { | 3616 if (!compilationUnit.isInBuildUnit) { |
| 3608 _inferredType = compilationUnit.getLinkedType( | 3617 _inferredType = compilationUnit.getLinkedType( |
| 3609 _unlinkedParam.inferredTypeSlot, _typeParameterContext); | 3618 _unlinkedParam.inferredTypeSlot, _typeParameterContext); |
| 3610 return _inferredType; | 3619 return _inferredType; |
| 3611 } else { | 3620 } else { |
| 3612 _declaredType = DynamicTypeImpl.instance; | 3621 _declaredType = DynamicTypeImpl.instance; |
| 3613 } | 3622 } |
| 3614 } else { | 3623 } else { |
| 3615 _declaredType = compilationUnit._resolveTypeRef( | 3624 _declaredType = compilationUnit.resolveTypeRef( |
| 3616 _unlinkedParam.type, _typeParameterContext); | 3625 _unlinkedParam.type, _typeParameterContext); |
| 3617 } | 3626 } |
| 3618 } | 3627 } |
| 3619 return _declaredType; | 3628 return _declaredType; |
| 3620 } | 3629 } |
| 3621 | 3630 |
| 3622 @override | 3631 @override |
| 3623 void set type(DartType inferredType) { | 3632 void set type(DartType inferredType) { |
| 3624 assert(_inferredType == null); | 3633 assert(_inferredType == null); |
| 3625 _inferredType = inferredType; | 3634 _inferredType = inferredType; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3682 /** | 3691 /** |
| 3683 * Get all the parameters of this element. | 3692 * Get all the parameters of this element. |
| 3684 */ | 3693 */ |
| 3685 List<ParameterElementForLink> get parameters { | 3694 List<ParameterElementForLink> get parameters { |
| 3686 if (_parameters == null) { | 3695 if (_parameters == null) { |
| 3687 List<UnlinkedParam> unlinkedParameters = this.unlinkedParameters; | 3696 List<UnlinkedParam> unlinkedParameters = this.unlinkedParameters; |
| 3688 int numParameters = unlinkedParameters.length; | 3697 int numParameters = unlinkedParameters.length; |
| 3689 _parameters = new List<ParameterElementForLink>(numParameters); | 3698 _parameters = new List<ParameterElementForLink>(numParameters); |
| 3690 for (int i = 0; i < numParameters; i++) { | 3699 for (int i = 0; i < numParameters; i++) { |
| 3691 UnlinkedParam unlinkedParam = unlinkedParameters[i]; | 3700 UnlinkedParam unlinkedParam = unlinkedParameters[i]; |
| 3692 _parameters[i] = new ParameterElementForLink(this, unlinkedParam, | 3701 _parameters[i] = new ParameterElementForLink( |
| 3693 typeParameterContext, typeParameterContext.compilationUnit, i); | 3702 this, |
| 3703 unlinkedParam, | |
| 3704 typeParameterContext, | |
| 3705 typeParameterContext.resynthesizerContext | |
| 3706 as CompilationUnitElementForLink, | |
| 3707 i); | |
| 3694 } | 3708 } |
| 3695 } | 3709 } |
| 3696 return _parameters; | 3710 return _parameters; |
| 3697 } | 3711 } |
| 3698 | 3712 |
| 3699 /** | 3713 /** |
| 3700 * Get the innermost enclosing element that can declare type parameters (which | 3714 * Get the innermost enclosing element that can declare type parameters (which |
| 3701 * may be [this], or may be a parent when there are function-typed | 3715 * may be [this], or may be a parent when there are function-typed |
| 3702 * parameters). | 3716 * parameters). |
| 3703 */ | 3717 */ |
| 3704 TypeParameterizedElementForLink get typeParameterContext; | 3718 TypeParameterizedElementMixin get typeParameterContext; |
| 3705 | 3719 |
| 3706 /** | 3720 /** |
| 3707 * Get the list of unlinked parameters of this element. | 3721 * Get the list of unlinked parameters of this element. |
| 3708 */ | 3722 */ |
| 3709 List<UnlinkedParam> get unlinkedParameters; | 3723 List<UnlinkedParam> get unlinkedParameters; |
| 3710 } | 3724 } |
| 3711 | 3725 |
| 3712 /** | 3726 /** |
| 3713 * Element representing a getter or setter resynthesized from a summary during | 3727 * Element representing a getter or setter resynthesized from a summary during |
| 3714 * linking. | 3728 * linking. |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4060 DartType _returnType; | 4074 DartType _returnType; |
| 4061 | 4075 |
| 4062 TopLevelFunctionElementForLink( | 4076 TopLevelFunctionElementForLink( |
| 4063 CompilationUnitElementForLink enclosingUnit, UnlinkedExecutable _buf) | 4077 CompilationUnitElementForLink enclosingUnit, UnlinkedExecutable _buf) |
| 4064 : super(enclosingUnit, null, _buf); | 4078 : super(enclosingUnit, null, _buf); |
| 4065 | 4079 |
| 4066 @override | 4080 @override |
| 4067 DartType get asStaticType => type; | 4081 DartType get asStaticType => type; |
| 4068 | 4082 |
| 4069 @override | 4083 @override |
| 4084 String get identifier => _unlinkedExecutable.name; | |
| 4085 | |
| 4086 @override | |
| 4070 ElementKind get kind => ElementKind.FUNCTION; | 4087 ElementKind get kind => ElementKind.FUNCTION; |
| 4071 | 4088 |
| 4072 @override | 4089 @override |
| 4073 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 4090 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 4074 } | 4091 } |
| 4075 | 4092 |
| 4076 /** | 4093 /** |
| 4077 * Element representing a top level variable resynthesized from a | 4094 * Element representing a top level variable resynthesized from a |
| 4078 * summary during linking. | 4095 * summary during linking. |
| 4079 */ | 4096 */ |
| 4080 class TopLevelVariableElementForLink extends VariableElementForLink | 4097 class TopLevelVariableElementForLink extends VariableElementForLink |
| 4081 implements TopLevelVariableElement { | 4098 implements TopLevelVariableElement { |
| 4082 TopLevelVariableElementForLink(CompilationUnitElementForLink enclosingElement, | 4099 TopLevelVariableElementForLink(CompilationUnitElementForLink enclosingElement, |
| 4083 UnlinkedVariable unlinkedVariable) | 4100 UnlinkedVariable unlinkedVariable) |
| 4084 : super(unlinkedVariable, enclosingElement); | 4101 : super(unlinkedVariable, enclosingElement); |
| 4085 | 4102 |
| 4086 @override | 4103 @override |
| 4087 CompilationUnitElementForLink get enclosingElement => compilationUnit; | 4104 CompilationUnitElementForLink get enclosingElement => compilationUnit; |
| 4088 | 4105 |
| 4089 @override | 4106 @override |
| 4090 bool get isStatic => true; | 4107 bool get isStatic => true; |
| 4091 | 4108 |
| 4092 @override | 4109 @override |
| 4093 LibraryElementForLink get library => compilationUnit.library; | 4110 LibraryElementForLink get library => compilationUnit.library; |
| 4094 | 4111 |
| 4095 @override | 4112 @override |
| 4096 TypeParameterizedElementForLink get _typeParameterContext => null; | 4113 TypeParameterizedElementMixin get _typeParameterContext => null; |
| 4097 | 4114 |
| 4098 /** | 4115 /** |
| 4099 * Store the results of type inference for this variable in | 4116 * Store the results of type inference for this variable in |
| 4100 * [compilationUnit]. | 4117 * [compilationUnit]. |
| 4101 */ | 4118 */ |
| 4102 void link(CompilationUnitElementInBuildUnit compilationUnit) { | 4119 void link(CompilationUnitElementInBuildUnit compilationUnit) { |
| 4103 if (hasImplicitType) { | 4120 if (hasImplicitType) { |
| 4104 TypeInferenceNode typeInferenceNode = this._typeInferenceNode; | 4121 TypeInferenceNode typeInferenceNode = this._typeInferenceNode; |
| 4105 if (typeInferenceNode != null) { | 4122 if (typeInferenceNode != null) { |
| 4106 compilationUnit._storeLinkedType( | 4123 compilationUnit._storeLinkedType( |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4215 } else { | 4232 } else { |
| 4216 variableElement._inferredType = | 4233 variableElement._inferredType = |
| 4217 new ExprTypeComputer(variableElement).compute(); | 4234 new ExprTypeComputer(variableElement).compute(); |
| 4218 } | 4235 } |
| 4219 } | 4236 } |
| 4220 | 4237 |
| 4221 @override | 4238 @override |
| 4222 String toString() => 'TypeInferenceNode($variableElement)'; | 4239 String toString() => 'TypeInferenceNode($variableElement)'; |
| 4223 } | 4240 } |
| 4224 | 4241 |
| 4225 /** | |
| 4226 * Element representing a type parameter resynthesized from a summary during | |
| 4227 * linking. | |
| 4228 */ | |
| 4229 class TypeParameterElementForLink implements TypeParameterElementImpl { | |
| 4230 /** | |
| 4231 * The unlinked representation of the type parameter in the summary. | |
| 4232 */ | |
| 4233 final UnlinkedTypeParam _unlinkedTypeParam; | |
| 4234 | |
| 4235 /** | |
| 4236 * The number of type parameters whose scope overlaps this one, and which are | |
| 4237 * declared earlier in the file. | |
| 4238 */ | |
| 4239 final int nestingLevel; | |
| 4240 | |
| 4241 @override | |
| 4242 final TypeParameterizedElementForLink enclosingElement; | |
| 4243 | |
| 4244 TypeParameterTypeImpl _type; | |
| 4245 ElementLocation _location; | |
| 4246 | |
| 4247 DartType _bound; | |
| 4248 | |
| 4249 TypeParameterElementForLink( | |
| 4250 this.enclosingElement, this._unlinkedTypeParam, this.nestingLevel); | |
| 4251 | |
| 4252 @override | |
| 4253 DartType get bound { | |
| 4254 if (_unlinkedTypeParam.bound == null) { | |
| 4255 return null; | |
| 4256 } | |
| 4257 return _bound ??= enclosingElement.compilationUnit | |
| 4258 ._resolveTypeRef(_unlinkedTypeParam.bound, enclosingElement); | |
| 4259 } | |
| 4260 | |
| 4261 @override | |
| 4262 String get identifier => name; | |
| 4263 | |
| 4264 @override | |
| 4265 ElementKind get kind => ElementKind.TYPE_PARAMETER; | |
| 4266 | |
| 4267 @override | |
| 4268 ElementLocation get location => | |
| 4269 _location ??= new ElementLocationImpl.con1(this); | |
| 4270 | |
| 4271 @override | |
| 4272 String get name => _unlinkedTypeParam.name; | |
| 4273 | |
| 4274 @override | |
| 4275 TypeParameterTypeImpl get type => _type ??= new TypeParameterTypeImpl(this); | |
| 4276 | |
| 4277 @override | |
| 4278 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 4279 } | |
| 4280 | |
| 4281 /** | |
| 4282 * Mixin representing an element which can have type parameters. | |
| 4283 */ | |
| 4284 abstract class TypeParameterizedElementForLink | |
| 4285 implements TypeParameterizedElement { | |
| 4286 List<TypeParameterType> _typeParameterTypes; | |
| 4287 List<TypeParameterElementForLink> _typeParameters; | |
| 4288 int _nestingLevel; | |
| 4289 | |
| 4290 /** | |
| 4291 * Get the compilation unit in which this element is declared. | |
| 4292 */ | |
| 4293 CompilationUnitElementForLink get compilationUnit; | |
| 4294 | |
| 4295 /** | |
| 4296 * Get the type parameter context enclosing this one, if any. | |
| 4297 */ | |
| 4298 TypeParameterizedElementForLink get enclosingTypeParameterContext; | |
| 4299 | |
| 4300 /** | |
| 4301 * Find out how many type parameters are in scope in this context. | |
| 4302 */ | |
| 4303 int get typeParameterNestingLevel => | |
| 4304 _nestingLevel ??= _unlinkedTypeParams.length + | |
| 4305 (enclosingTypeParameterContext?.typeParameterNestingLevel ?? 0); | |
| 4306 | |
| 4307 List<TypeParameterElementForLink> get typeParameters { | |
| 4308 if (_typeParameters == null) { | |
| 4309 int enclosingNestingLevel = | |
| 4310 enclosingTypeParameterContext?.typeParameterNestingLevel ?? 0; | |
| 4311 int numTypeParameters = _unlinkedTypeParams.length; | |
| 4312 _typeParameters = | |
| 4313 new List<TypeParameterElementForLink>(numTypeParameters); | |
| 4314 for (int i = 0; i < numTypeParameters; i++) { | |
| 4315 _typeParameters[i] = new TypeParameterElementForLink( | |
| 4316 this, _unlinkedTypeParams[i], enclosingNestingLevel + i); | |
| 4317 } | |
| 4318 } | |
| 4319 return _typeParameters; | |
| 4320 } | |
| 4321 | |
| 4322 /** | |
| 4323 * Get a list of [TypeParameterType] objects corresponding to the | |
| 4324 * element's type parameters. | |
| 4325 */ | |
| 4326 List<TypeParameterType> get typeParameterTypes { | |
| 4327 if (_typeParameterTypes == null) { | |
| 4328 _typeParameterTypes = typeParameters | |
| 4329 .map((TypeParameterElementForLink e) => e.type) | |
| 4330 .toList(); | |
| 4331 } | |
| 4332 return _typeParameterTypes; | |
| 4333 } | |
| 4334 | |
| 4335 /** | |
| 4336 * Get the [UnlinkedTypeParam]s representing the type parameters declared by | |
| 4337 * this element. | |
| 4338 */ | |
| 4339 List<UnlinkedTypeParam> get _unlinkedTypeParams; | |
| 4340 | |
| 4341 /** | |
| 4342 * Convert the given [index] into a type parameter type. | |
| 4343 */ | |
| 4344 TypeParameterType getTypeParameterType(int index) { | |
| 4345 List<TypeParameterType> types = typeParameterTypes; | |
| 4346 if (index <= types.length) { | |
| 4347 return types[types.length - index]; | |
| 4348 } else if (enclosingTypeParameterContext != null) { | |
| 4349 return enclosingTypeParameterContext | |
| 4350 .getTypeParameterType(index - types.length); | |
| 4351 } else { | |
| 4352 // If we get here, it means that a summary contained a type parameter inde x | |
| 4353 // that was out of range. | |
| 4354 throw new RangeError('Invalid type parameter index'); | |
| 4355 } | |
| 4356 } | |
| 4357 | |
| 4358 /** | |
| 4359 * Find out if the given [typeParameter] is in scope in this context. | |
| 4360 */ | |
| 4361 bool isTypeParameterInScope(TypeParameterElementForLink typeParameter) { | |
| 4362 if (typeParameter.enclosingElement == this) { | |
| 4363 return true; | |
| 4364 } else if (enclosingTypeParameterContext != null) { | |
| 4365 return enclosingTypeParameterContext | |
| 4366 .isTypeParameterInScope(typeParameter); | |
| 4367 } else { | |
| 4368 return false; | |
| 4369 } | |
| 4370 } | |
| 4371 } | |
| 4372 | |
| 4373 class TypeProviderForLink implements TypeProvider { | 4242 class TypeProviderForLink implements TypeProvider { |
| 4374 final Linker _linker; | 4243 final Linker _linker; |
| 4375 | 4244 |
| 4376 InterfaceType _boolType; | 4245 InterfaceType _boolType; |
| 4377 InterfaceType _deprecatedType; | 4246 InterfaceType _deprecatedType; |
| 4378 InterfaceType _doubleType; | 4247 InterfaceType _doubleType; |
| 4379 InterfaceType _functionType; | 4248 InterfaceType _functionType; |
| 4380 InterfaceType _futureDynamicType; | 4249 InterfaceType _futureDynamicType; |
| 4381 InterfaceType _futureNullType; | 4250 InterfaceType _futureNullType; |
| 4382 InterfaceType _futureType; | 4251 InterfaceType _futureType; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4572 } | 4441 } |
| 4573 | 4442 |
| 4574 /** | 4443 /** |
| 4575 * If the variable has an explicitly declared return type, return it. | 4444 * If the variable has an explicitly declared return type, return it. |
| 4576 * Otherwise return `null`. | 4445 * Otherwise return `null`. |
| 4577 */ | 4446 */ |
| 4578 DartType get declaredType { | 4447 DartType get declaredType { |
| 4579 if (unlinkedVariable.type == null) { | 4448 if (unlinkedVariable.type == null) { |
| 4580 return null; | 4449 return null; |
| 4581 } else { | 4450 } else { |
| 4582 return _declaredType ??= compilationUnit._resolveTypeRef( | 4451 return _declaredType ??= compilationUnit.resolveTypeRef( |
| 4583 unlinkedVariable.type, _typeParameterContext); | 4452 unlinkedVariable.type, _typeParameterContext); |
| 4584 } | 4453 } |
| 4585 } | 4454 } |
| 4586 | 4455 |
| 4587 @override | 4456 @override |
| 4588 PropertyAccessorElementForLink_Variable get getter => | 4457 PropertyAccessorElementForLink_Variable get getter => |
| 4589 _getter ??= new PropertyAccessorElementForLink_Variable(this, false); | 4458 _getter ??= new PropertyAccessorElementForLink_Variable(this, false); |
| 4590 | 4459 |
| 4591 @override | 4460 @override |
| 4592 bool get hasImplicitType => unlinkedVariable.type == null; | 4461 bool get hasImplicitType => unlinkedVariable.type == null; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4664 | 4533 |
| 4665 @override | 4534 @override |
| 4666 void set type(DartType newType) { | 4535 void set type(DartType newType) { |
| 4667 // TODO(paulberry): store inferred type. | 4536 // TODO(paulberry): store inferred type. |
| 4668 } | 4537 } |
| 4669 | 4538 |
| 4670 /** | 4539 /** |
| 4671 * The context in which type parameters should be interpreted, or `null` if | 4540 * The context in which type parameters should be interpreted, or `null` if |
| 4672 * there are no type parameters in scope. | 4541 * there are no type parameters in scope. |
| 4673 */ | 4542 */ |
| 4674 TypeParameterizedElementForLink get _typeParameterContext; | 4543 TypeParameterizedElementMixin get _typeParameterContext; |
| 4675 | 4544 |
| 4676 @override | 4545 @override |
| 4677 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 4546 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 4678 | 4547 |
| 4679 @override | 4548 @override |
| 4680 String toString() => '$enclosingElement.$name'; | 4549 String toString() => '$enclosingElement.$name'; |
| 4681 } | 4550 } |
| OLD | NEW |