@@ -419,16 +419,15 @@ TypeChecker::getDynamicBridgedThroughObjCClass(DeclContext *dc,
419
419
return dc->getASTContext ().getBridgedToObjC (dc, valueType);
420
420
}
421
421
422
- Type TypeChecker ::resolveTypeInContext (TypeDecl *typeDecl, DeclContext *foundDC ,
423
- TypeResolution resolution ,
424
- bool isSpecialized) {
425
- auto fromDC = resolution. getDeclContext ();
422
+ Type TypeResolution ::resolveTypeInContext (TypeDecl *typeDecl,
423
+ DeclContext *foundDC ,
424
+ bool isSpecialized) {
425
+ auto fromDC = getDeclContext ();
426
426
ASTContext &ctx = fromDC->getASTContext ();
427
427
428
428
// If we found a generic parameter, map to the archetype if there is one.
429
429
if (auto genericParam = dyn_cast<GenericTypeParamDecl>(typeDecl)) {
430
- return resolution.mapTypeIntoContext (
431
- genericParam->getDeclaredInterfaceType ());
430
+ return mapTypeIntoContext (genericParam->getDeclaredInterfaceType ());
432
431
}
433
432
434
433
if (!isSpecialized) {
@@ -440,13 +439,12 @@ Type TypeChecker::resolveTypeInContext(TypeDecl *typeDecl, DeclContext *foundDC,
440
439
parentDC = parentDC->getParent ()) {
441
440
auto *parentNominal = parentDC->getSelfNominalTypeDecl ();
442
441
if (parentNominal == nominalType)
443
- return resolution.mapTypeIntoContext (
444
- parentDC->getDeclaredInterfaceType ());
442
+ return mapTypeIntoContext (parentDC->getDeclaredInterfaceType ());
445
443
if (isa<ExtensionDecl>(parentDC)) {
446
444
auto *extendedType = parentNominal;
447
445
while (extendedType != nullptr ) {
448
446
if (extendedType == nominalType)
449
- return resolution. mapTypeIntoContext (
447
+ return mapTypeIntoContext (
450
448
extendedType->getDeclaredInterfaceType ());
451
449
extendedType = extendedType->getParent ()->getSelfNominalTypeDecl ();
452
450
}
@@ -466,11 +464,11 @@ Type TypeChecker::resolveTypeInContext(TypeDecl *typeDecl, DeclContext *foundDC,
466
464
if (auto *ugAliasDecl =
467
465
dyn_cast<TypeAliasDecl>(unboundGeneric->getAnyGeneric ())) {
468
466
if (ugAliasDecl == aliasDecl) {
469
- if (resolution. getStage () == TypeResolutionStage::Structural &&
467
+ if (getStage () == TypeResolutionStage::Structural &&
470
468
aliasDecl->getUnderlyingTypeRepr () != nullptr ) {
471
469
return aliasDecl->getStructuralType ();
472
470
}
473
- return resolution. mapTypeIntoContext (
471
+ return mapTypeIntoContext (
474
472
aliasDecl->getDeclaredInterfaceType ());
475
473
}
476
474
@@ -481,12 +479,11 @@ Type TypeChecker::resolveTypeInContext(TypeDecl *typeDecl, DeclContext *foundDC,
481
479
if (auto *aliasType =
482
480
dyn_cast<TypeAliasType>(extendedType.getPointer ())) {
483
481
if (aliasType->getDecl () == aliasDecl) {
484
- if (resolution. getStage () == TypeResolutionStage::Structural &&
482
+ if (getStage () == TypeResolutionStage::Structural &&
485
483
aliasDecl->getUnderlyingTypeRepr () != nullptr ) {
486
484
return aliasDecl->getStructuralType ();
487
485
}
488
- return resolution.mapTypeIntoContext (
489
- aliasDecl->getDeclaredInterfaceType ());
486
+ return mapTypeIntoContext (aliasDecl->getDeclaredInterfaceType ());
490
487
}
491
488
extendedType = aliasType->getParent ();
492
489
continue ;
@@ -507,12 +504,11 @@ Type TypeChecker::resolveTypeInContext(TypeDecl *typeDecl, DeclContext *foundDC,
507
504
return aliasDecl->getUnboundGenericType ();
508
505
509
506
// Otherwise, return the appropriate type.
510
- if (resolution. getStage () == TypeResolutionStage::Structural &&
507
+ if (getStage () == TypeResolutionStage::Structural &&
511
508
aliasDecl->getUnderlyingTypeRepr () != nullptr ) {
512
509
return aliasDecl->getStructuralType ();
513
510
}
514
- return resolution.mapTypeIntoContext (
515
- aliasDecl->getDeclaredInterfaceType ());
511
+ return mapTypeIntoContext (aliasDecl->getDeclaredInterfaceType ());
516
512
}
517
513
518
514
// When a nominal type used outside its context, return the unbound
@@ -539,12 +535,11 @@ Type TypeChecker::resolveTypeInContext(TypeDecl *typeDecl, DeclContext *foundDC,
539
535
if (!foundDC->getDeclaredInterfaceType ())
540
536
return ErrorType::get (ctx);
541
537
542
- selfType =
543
- resolution.mapTypeIntoContext (foundDC->getDeclaredInterfaceType ());
538
+ selfType = mapTypeIntoContext (foundDC->getDeclaredInterfaceType ());
544
539
} else {
545
540
// Otherwise, we want the protocol 'Self' type for
546
541
// substituting into alias types and associated types.
547
- selfType = resolution. mapTypeIntoContext (foundDC->getSelfInterfaceType ());
542
+ selfType = mapTypeIntoContext (foundDC->getSelfInterfaceType ());
548
543
549
544
if (selfType->is <GenericTypeParamType>()) {
550
545
if (typeDecl->getDeclContext ()->getSelfProtocolDecl ()) {
@@ -559,9 +554,9 @@ Type TypeChecker::resolveTypeInContext(TypeDecl *typeDecl, DeclContext *foundDC,
559
554
// because we use the Sequence.SubSequence default instead of
560
555
// the Collection.SubSequence default, even when the conforming
561
556
// type wants to conform to Collection.
562
- if (resolution. getStage () == TypeResolutionStage::Structural) {
563
- return resolution. resolveSelfAssociatedType (selfType, foundDC,
564
- typeDecl->getName ());
557
+ if (getStage () == TypeResolutionStage::Structural) {
558
+ return resolveSelfAssociatedType (selfType, foundDC,
559
+ typeDecl->getName ());
565
560
} else if (auto assocType = dyn_cast<AssociatedTypeDecl>(typeDecl)) {
566
561
typeDecl = assocType->getAssociatedTypeAnchor ();
567
562
}
@@ -587,8 +582,8 @@ Type TypeChecker::resolveTypeInContext(TypeDecl *typeDecl, DeclContext *foundDC,
587
582
}
588
583
589
584
// Finally, substitute the base type into the member type.
590
- return substMemberTypeWithBase (fromDC-> getParentModule (), typeDecl, selfType,
591
- resolution. usesArchetypes ());
585
+ return TypeChecker:: substMemberTypeWithBase (
586
+ fromDC-> getParentModule (), typeDecl, selfType, usesArchetypes ());
592
587
}
593
588
594
589
static TypeResolutionOptions
@@ -1071,8 +1066,8 @@ static Type resolveTypeDecl(TypeDecl *typeDecl, DeclContext *foundDC,
1071
1066
ComponentIdentTypeRepr *comp) {
1072
1067
// Resolve the type declaration to a specific type. How this occurs
1073
1068
// depends on the current context and where the type was found.
1074
- Type type = TypeChecker:: resolveTypeInContext (
1075
- typeDecl, foundDC, resolution, isa<GenericIdentTypeRepr>(comp));
1069
+ Type type = resolution. resolveTypeInContext (typeDecl, foundDC,
1070
+ isa<GenericIdentTypeRepr>(comp));
1076
1071
1077
1072
if (type->hasError () && foundDC &&
1078
1073
(isa<AssociatedTypeDecl>(typeDecl) || isa<TypeAliasDecl>(typeDecl))) {
0 commit comments