@@ -1477,20 +1477,16 @@ SILConstantInfo TypeConverter::getConstantInfo(SILDeclRef constant) {
1477
1477
1478
1478
// First, get a function type for the constant. This creates the
1479
1479
// right type for a getter or setter.
1480
- auto formalType = makeConstantType (constant);
1481
1480
auto formalInterfaceType = makeConstantInterfaceType (constant);
1482
1481
GenericParamList *contextGenerics, *innerGenerics;
1483
1482
std::tie (contextGenerics, innerGenerics)
1484
1483
= getConstantContextGenericParams (constant);
1485
1484
1486
1485
// The formal type is just that with the right representation.
1487
1486
auto rep = getDeclRefRepresentation (constant);
1488
- formalType = adjustFunctionType (formalType, rep);
1489
1487
formalInterfaceType = adjustFunctionType (formalInterfaceType, rep);
1490
1488
// The lowered type is the formal type, but uncurried and with
1491
1489
// parameters automatically turned into their bridged equivalents.
1492
- auto loweredType =
1493
- getLoweredASTFunctionType (formalType, constant.uncurryLevel , constant);
1494
1490
auto loweredInterfaceType =
1495
1491
getLoweredASTFunctionType (formalInterfaceType, constant.uncurryLevel ,
1496
1492
constant);
@@ -1503,16 +1499,16 @@ SILConstantInfo TypeConverter::getConstantInfo(SILDeclRef constant) {
1503
1499
DEBUG (llvm::dbgs () << " lowering type for constant " ;
1504
1500
constant.print (llvm::dbgs ());
1505
1501
llvm::dbgs () << " \n formal type: " ;
1506
- formalType .print (llvm::dbgs ());
1502
+ formalInterfaceType .print (llvm::dbgs ());
1507
1503
llvm::dbgs () << " \n lowered AST type: " ;
1508
- loweredType .print (llvm::dbgs ());
1504
+ loweredInterfaceType .print (llvm::dbgs ());
1509
1505
llvm::dbgs () << " \n SIL type: " ;
1510
1506
silFnType.print (llvm::dbgs ());
1511
1507
llvm::dbgs () << " \n " );
1512
1508
1513
1509
SILConstantInfo result = {
1514
- formalType, formalInterfaceType,
1515
- loweredType, loweredInterfaceType,
1510
+ formalInterfaceType,
1511
+ loweredInterfaceType,
1516
1512
silFnType,
1517
1513
contextGenerics,
1518
1514
innerGenerics,
@@ -1749,28 +1745,6 @@ TypeConverter::substFunctionType(CanSILFunctionType origFnType,
1749
1745
Context);
1750
1746
}
1751
1747
1752
- // This is a hack until we eliminate contextual type usage from ConstantInfo,
1753
- // or add support for GenericFunctionType to mapTypeIntoContext().
1754
- static AnyFunctionType *mapFuncTypeIntoContext (Module *M,
1755
- GenericParamList *genericParams,
1756
- Type type) {
1757
- auto fnTy = type->castTo <AnyFunctionType>();
1758
- if (!genericParams)
1759
- return fnTy;
1760
-
1761
- auto inputTy = ArchetypeBuilder::mapTypeIntoContext (M, genericParams,
1762
- fnTy->getInput ());
1763
- auto resultTy = ArchetypeBuilder::mapTypeIntoContext (M, genericParams,
1764
- fnTy->getResult ());
1765
-
1766
- // Introduce a generic signature
1767
- if (fnTy->is <GenericFunctionType>())
1768
- return PolymorphicFunctionType::get (inputTy, resultTy, genericParams,
1769
- fnTy->getExtInfo ());
1770
- else
1771
- return FunctionType::get (inputTy, resultTy, fnTy->getExtInfo ());
1772
- }
1773
-
1774
1748
// / Returns the ConstantInfo corresponding to the VTable thunk for overriding.
1775
1749
// / Will be the same as getConstantInfo if the declaration does not override.
1776
1750
SILConstantInfo TypeConverter::getConstantOverrideInfo (SILDeclRef derived,
@@ -1829,14 +1803,7 @@ SILConstantInfo TypeConverter::getConstantOverrideInfo(SILDeclRef derived,
1829
1803
base.uncurryLevel + 1 );
1830
1804
}
1831
1805
1832
- auto overrideFormalTy = mapFuncTypeIntoContext (M.getSwiftModule (),
1833
- derivedInfo.ContextGenericParams ,
1834
- overrideInterfaceTy);
1835
-
1836
- // Lower the formal AST types.
1837
- auto overrideLoweredTy = getLoweredASTFunctionType (
1838
- cast<AnyFunctionType>(overrideFormalTy->getCanonicalType ()),
1839
- derived.uncurryLevel , derived);
1806
+ // Lower the formal AST type.
1840
1807
auto overrideLoweredInterfaceTy = getLoweredASTFunctionType (
1841
1808
cast<AnyFunctionType>(overrideInterfaceTy->getCanonicalType ()),
1842
1809
derived.uncurryLevel , derived);
@@ -1860,7 +1827,6 @@ SILConstantInfo TypeConverter::getConstantOverrideInfo(SILDeclRef derived,
1860
1827
1861
1828
// Build the SILConstantInfo and cache it.
1862
1829
SILConstantInfo overrideInfo;
1863
- overrideInfo.LoweredType = overrideLoweredTy;
1864
1830
overrideInfo.LoweredInterfaceType = overrideLoweredInterfaceTy;
1865
1831
overrideInfo.SILFnType = fnTy;
1866
1832
overrideInfo.ContextGenericParams = derivedInfo.ContextGenericParams ;
@@ -2037,29 +2003,17 @@ TypeConverter::getBridgedFunctionType(AbstractionPattern pattern,
2037
2003
genericSig = gft.getGenericSignature ();
2038
2004
}
2039
2005
2040
- // Pull the innermost generic parameter list in the type out.
2041
- Optional<GenericParamList *> genericParams;
2006
+ // Remove this when PolymorphicFunctionType goes away.
2042
2007
{
2043
2008
CanAnyFunctionType innerTy = t;
2044
2009
while (innerTy) {
2045
- if (auto pft = dyn_cast<PolymorphicFunctionType>(innerTy)) {
2046
- assert (!genericParams
2047
- || pft->getGenericParams ().getOuterParameters () == *genericParams);
2048
- genericParams = &pft->getGenericParams ();
2049
- }
2010
+ assert (!isa<PolymorphicFunctionType>(innerTy));
2050
2011
innerTy = dyn_cast<AnyFunctionType>(innerTy.getResult ());
2051
2012
}
2052
2013
}
2053
- GenericParamList *innerGenericParams
2054
- = genericParams ? *genericParams : nullptr ;
2055
2014
2056
2015
auto rebuild = [&](CanType input, CanType result) -> CanAnyFunctionType {
2057
- if (genericParams) {
2058
- assert (!genericSig && " got mix of poly/generic function type?!" );
2059
- return CanPolymorphicFunctionType::get (input, result,
2060
- innerGenericParams,
2061
- extInfo);
2062
- } else if (genericSig) {
2016
+ if (genericSig) {
2063
2017
return CanGenericFunctionType::get (genericSig, input, result, extInfo);
2064
2018
} else {
2065
2019
return CanFunctionType::get (input, result, extInfo);
@@ -2072,7 +2026,7 @@ TypeConverter::getBridgedFunctionType(AbstractionPattern pattern,
2072
2026
case SILFunctionTypeRepresentation::Method:
2073
2027
case SILFunctionTypeRepresentation::WitnessMethod:
2074
2028
// No bridging needed for native functions.
2075
- if (t->getExtInfo () == extInfo && !innerGenericParams )
2029
+ if (t->getExtInfo () == extInfo)
2076
2030
return t;
2077
2031
return rebuild (t.getInput (), t.getResult ());
2078
2032
@@ -2190,19 +2144,11 @@ TypeConverter::getLoweredASTFunctionType(CanAnyFunctionType fnType,
2190
2144
// The uncurried input types.
2191
2145
SmallVector<TupleTypeElt, 4 > inputs;
2192
2146
2193
- // The innermost generic parameter list.
2194
- // FIXME: Interface types make this unnecessary.
2195
- Optional<GenericParamList *> genericParams;
2196
-
2197
2147
// Merge inputs and generic parameters from the uncurry levels.
2198
2148
for (;;) {
2199
2149
inputs.push_back (TupleTypeElt (fnType->getInput ()));
2200
2150
2201
- if (auto pft = dyn_cast<PolymorphicFunctionType>(fnType)) {
2202
- assert (!genericParams
2203
- || pft->getGenericParams ().getOuterParameters () == *genericParams);
2204
- genericParams = &pft->getGenericParams ();
2205
- }
2151
+ assert (!isa<PolymorphicFunctionType>(fnType));
2206
2152
2207
2153
// The uncurried function calls all of the intermediate function
2208
2154
// levels and so throws if any of them do.
@@ -2263,18 +2209,9 @@ TypeConverter::getLoweredASTFunctionType(CanAnyFunctionType fnType,
2263
2209
2264
2210
// Create the new function type.
2265
2211
CanType inputType = CanType (TupleType::get (inputs, Context));
2266
- GenericParamList *innerGenericParams
2267
- = genericParams ? *genericParams : nullptr ;
2268
2212
if (genericSig) {
2269
- assert (!innerGenericParams && " got mix of Polymorphic/Generic FunctionType?!" );
2270
2213
return CanGenericFunctionType::get (genericSig,
2271
2214
inputType, resultType, extInfo);
2272
- }
2273
-
2274
- if (innerGenericParams) {
2275
- return CanPolymorphicFunctionType::get (inputType, resultType,
2276
- innerGenericParams,
2277
- extInfo);
2278
2215
} else {
2279
2216
return CanFunctionType::get (inputType, resultType, extInfo);
2280
2217
}
0 commit comments