@@ -1343,9 +1343,9 @@ void TypeConverter::insert(TypeKey k, const TypeLowering *tl) {
13431343
13441344// / Lower each of the elements of the substituted type according to
13451345// / the abstraction pattern of the given original type.
1346- static CanTupleType getLoweredTupleType (TypeConverter &tc,
1347- AbstractionPattern origType,
1348- CanTupleType substType) {
1346+ static CanTupleType computeLoweredTupleType (TypeConverter &tc,
1347+ AbstractionPattern origType,
1348+ CanTupleType substType) {
13491349 assert (origType.matchesTuple (substType));
13501350
13511351 // Does the lowered tuple type differ from the substituted type in
@@ -1365,9 +1365,8 @@ static CanTupleType getLoweredTupleType(TypeConverter &tc,
13651365 assert (Flags.getValueOwnership () == ValueOwnership::Default);
13661366 assert (!Flags.isVariadic ());
13671367
1368- SILType silType = tc.getLoweredType (origEltType, substEltType);
1369- CanType loweredSubstEltType = silType.getASTType ();
1370-
1368+ CanType loweredSubstEltType =
1369+ tc.getLoweredRValueType (origEltType, substEltType);
13711370 changed = (changed || substEltType != loweredSubstEltType ||
13721371 !Flags.isNone ());
13731372
@@ -1388,15 +1387,15 @@ static CanTupleType getLoweredTupleType(TypeConverter &tc,
13881387 return cast<TupleType>(CanType (TupleType::get (loweredElts, tc.Context )));
13891388}
13901389
1391- static CanType getLoweredOptionalType (TypeConverter &tc,
1392- AbstractionPattern origType,
1393- CanType substType,
1394- CanType substObjectType) {
1390+ static CanType computeLoweredOptionalType (TypeConverter &tc,
1391+ AbstractionPattern origType,
1392+ CanType substType,
1393+ CanType substObjectType) {
13951394 assert (substType.getOptionalObjectType () == substObjectType);
13961395
13971396 CanType loweredObjectType =
1398- tc.getLoweredType (origType.getOptionalObjectType (), substObjectType)
1399- . getASTType ( );
1397+ tc.getLoweredRValueType (origType.getOptionalObjectType (),
1398+ substObjectType );
14001399
14011400 // If the object type didn't change, we don't have to rebuild anything.
14021401 if (loweredObjectType == substObjectType) {
@@ -1407,13 +1406,13 @@ static CanType getLoweredOptionalType(TypeConverter &tc,
14071406 return CanType (BoundGenericEnumType::get (optDecl, Type (), loweredObjectType));
14081407}
14091408
1410- static CanType getLoweredReferenceStorageType (TypeConverter &tc,
1411- AbstractionPattern origType,
1412- CanReferenceStorageType substType) {
1409+ static CanType
1410+ computeLoweredReferenceStorageType (TypeConverter &tc,
1411+ AbstractionPattern origType,
1412+ CanReferenceStorageType substType) {
14131413 CanType loweredReferentType =
1414- tc.getLoweredType (origType.getReferenceStorageReferentType (),
1415- substType.getReferentType ())
1416- .getASTType ();
1414+ tc.getLoweredRValueType (origType.getReferenceStorageReferentType (),
1415+ substType.getReferentType ());
14171416
14181417 if (loweredReferentType == substType.getReferentType ())
14191418 return substType;
@@ -1425,8 +1424,8 @@ static CanType getLoweredReferenceStorageType(TypeConverter &tc,
14251424CanSILFunctionType
14261425TypeConverter::getSILFunctionType (AbstractionPattern origType,
14271426 CanFunctionType substType) {
1428- return getLoweredType (origType, substType)
1429- . castTo <SILFunctionType>( );
1427+ return cast<SILFunctionType>(
1428+ getLoweredRValueType (origType, substType) );
14301429}
14311430
14321431const TypeLowering &
@@ -1445,7 +1444,7 @@ TypeConverter::getTypeLowering(AbstractionPattern origType,
14451444
14461445 // Lower the type.
14471446 CanType loweredSubstType =
1448- getLoweredRValueType (origType, substType);
1447+ computeLoweredRValueType (origType, substType);
14491448
14501449 // If that didn't change the type and the key is cacheable, there's no
14511450 // point in re-checking the table, so just construct a type lowering
@@ -1467,8 +1466,8 @@ TypeConverter::getTypeLowering(AbstractionPattern origType,
14671466 return lowering;
14681467}
14691468
1470- CanType TypeConverter::getLoweredRValueType (AbstractionPattern origType,
1471- CanType substType) {
1469+ CanType TypeConverter::computeLoweredRValueType (AbstractionPattern origType,
1470+ CanType substType) {
14721471 assert (!substType->hasError () &&
14731472 " Error types should not appear in type-checked AST" );
14741473
@@ -1559,17 +1558,18 @@ CanType TypeConverter::getLoweredRValueType(AbstractionPattern origType,
15591558
15601559 // Lower tuple element types.
15611560 if (auto substTupleType = dyn_cast<TupleType>(substType)) {
1562- return getLoweredTupleType (*this , origType, substTupleType);
1561+ return computeLoweredTupleType (*this , origType, substTupleType);
15631562 }
15641563
15651564 // Lower the referent type of reference storage types.
15661565 if (auto substRefType = dyn_cast<ReferenceStorageType>(substType)) {
1567- return getLoweredReferenceStorageType (*this , origType, substRefType);
1566+ return computeLoweredReferenceStorageType (*this , origType, substRefType);
15681567 }
15691568
15701569 // Lower the object type of optional types.
15711570 if (auto substObjectType = substType.getOptionalObjectType ()) {
1572- return getLoweredOptionalType (*this , origType, substType, substObjectType);
1571+ return computeLoweredOptionalType (*this , origType,
1572+ substType, substObjectType);
15731573 }
15741574
15751575 // The Swift type directly corresponds to the lowered type.
@@ -1961,8 +1961,7 @@ SILType TypeConverter::getSubstitutedStorageType(AbstractStorageDecl *value,
19611961 substType = substType.getReferenceStorageReferent ();
19621962 }
19631963
1964- SILType silSubstType = getLoweredType (origType, substType).getAddressType ();
1965- substType = silSubstType.getASTType ();
1964+ CanType substLoweredType = getLoweredRValueType (origType, substType);
19661965
19671966 // Type substitution preserves structural type structure, and the
19681967 // type-of-reference is only different in the outermost structural
@@ -1972,13 +1971,11 @@ SILType TypeConverter::getSubstitutedStorageType(AbstractStorageDecl *value,
19721971 // The only really significant manipulation there is with @weak and
19731972 // @unowned.
19741973 if (origRefType) {
1975- substType = CanType (ReferenceStorageType::get (substType,
1976- origRefType->getOwnership (),
1977- Context));
1978- return SILType::getPrimitiveType (substType, SILValueCategory::Address);
1974+ substLoweredType = CanReferenceStorageType::get (substType,
1975+ origRefType->getOwnership ());
19791976 }
19801977
1981- return silSubstType ;
1978+ return SILType::getPrimitiveAddressType (substLoweredType) ;
19821979}
19831980
19841981void TypeConverter::pushGenericContext (CanGenericSignature sig) {
@@ -2490,7 +2487,8 @@ CanSILBoxType TypeConverter::getBoxTypeForEnumElement(SILType enumType,
24902487
24912488 if (boxSignature == CanGenericSignature ()) {
24922489 auto eltIntfTy = elt->getArgumentInterfaceType ();
2493- auto boxVarTy = getLoweredType (eltIntfTy).getASTType ();
2490+
2491+ auto boxVarTy = getLoweredRValueType (eltIntfTy);
24942492 auto layout = SILLayout::get (C, nullptr , SILField (boxVarTy, true ));
24952493 return SILBoxType::get (C, layout, {});
24962494 }
@@ -2501,8 +2499,9 @@ CanSILBoxType TypeConverter::getBoxTypeForEnumElement(SILType enumType,
25012499 // Lower the enum element's argument in the box's context.
25022500 auto eltIntfTy = elt->getArgumentInterfaceType ();
25032501 GenericContextScope scope (*this , boxSignature);
2504- auto boxVarTy = getLoweredType (getAbstractionPattern (elt), eltIntfTy)
2505- .getASTType ();
2502+
2503+ auto boxVarTy = getLoweredRValueType (getAbstractionPattern (elt),
2504+ eltIntfTy);
25062505 auto layout = SILLayout::get (C, boxSignature, SILField (boxVarTy, true ));
25072506
25082507 // Instantiate the layout with enum's substitution list.
0 commit comments