@@ -2999,7 +2999,7 @@ ModuleFile::getDeclCheckedImpl(DeclID DID) {
2999
2999
return nullptr ;
3000
3000
}
3001
3001
3002
- param->setInterfaceType (paramTy-> getInOutObjectType () );
3002
+ param->setInterfaceType (paramTy);
3003
3003
param->setVariadic (isVariadic);
3004
3004
3005
3005
// Decode the default argument kind.
@@ -4263,25 +4263,13 @@ Expected<Type> ModuleFile::getTypeChecked(TypeID TID) {
4263
4263
4264
4264
case decls_block::PAREN_TYPE: {
4265
4265
TypeID underlyingID;
4266
- bool isVariadic, isAutoClosure, isEscaping;
4267
- unsigned rawOwnership;
4268
- decls_block::ParenTypeLayout::readRecord (scratch, underlyingID, isVariadic,
4269
- isAutoClosure, isEscaping,
4270
- rawOwnership);
4271
- auto ownership =
4272
- getActualValueOwnership ((serialization::ValueOwnership)rawOwnership);
4273
- if (!ownership) {
4274
- error ();
4275
- return nullptr ;
4276
- }
4266
+ decls_block::ParenTypeLayout::readRecord (scratch, underlyingID);
4277
4267
4278
4268
auto underlyingTy = getTypeChecked (underlyingID);
4279
4269
if (!underlyingTy)
4280
4270
return underlyingTy.takeError ();
4281
4271
4282
- typeOrOffset = ParenType::get (
4283
- ctx, underlyingTy.get ()->getInOutObjectType (),
4284
- ParameterTypeFlags (isVariadic, isAutoClosure, isEscaping, *ownership));
4272
+ typeOrOffset = ParenType::get (ctx, underlyingTy.get ());
4285
4273
break ;
4286
4274
}
4287
4275
@@ -4301,44 +4289,42 @@ Expected<Type> ModuleFile::getTypeChecked(TypeID TID) {
4301
4289
4302
4290
IdentifierID nameID;
4303
4291
TypeID typeID;
4304
- bool isVariadic, isAutoClosure, isEscaping;
4305
- unsigned rawOwnership;
4306
- decls_block::TupleTypeEltLayout::readRecord (scratch, nameID, typeID,
4307
- isVariadic, isAutoClosure,
4308
- isEscaping, rawOwnership);
4309
-
4310
- auto ownership =
4311
- getActualValueOwnership ((serialization::ValueOwnership)rawOwnership);
4312
- if (!ownership) {
4313
- error ();
4314
- return nullptr ;
4315
- }
4292
+ decls_block::TupleTypeEltLayout::readRecord (scratch, nameID, typeID);
4316
4293
4317
4294
auto elementTy = getTypeChecked (typeID);
4318
4295
if (!elementTy)
4319
4296
return elementTy.takeError ();
4320
4297
4321
- elements.emplace_back (elementTy.get ()->getInOutObjectType (),
4322
- getIdentifier (nameID),
4323
- ParameterTypeFlags (isVariadic, isAutoClosure,
4324
- isEscaping, *ownership));
4298
+ elements.emplace_back (elementTy.get (), getIdentifier (nameID));
4325
4299
}
4326
4300
4327
4301
typeOrOffset = TupleType::get (elements, ctx);
4328
4302
break ;
4329
4303
}
4330
4304
4331
- case decls_block::FUNCTION_TYPE: {
4332
- TypeID inputID;
4305
+ case decls_block::FUNCTION_TYPE:
4306
+ case decls_block::GENERIC_FUNCTION_TYPE: {
4333
4307
TypeID resultID;
4334
4308
uint8_t rawRepresentation;
4335
- bool autoClosure, noescape, throws;
4309
+ bool autoClosure = false , noescape = false , throws;
4310
+ GenericSignature *genericSig = nullptr ;
4311
+
4312
+ if (recordID == decls_block::FUNCTION_TYPE) {
4313
+ decls_block::FunctionTypeLayout::readRecord (scratch, resultID,
4314
+ rawRepresentation,
4315
+ autoClosure,
4316
+ noescape,
4317
+ throws);
4318
+ } else {
4319
+ GenericSignatureID rawGenericSig;
4320
+ decls_block::GenericFunctionTypeLayout::readRecord (scratch,
4321
+ resultID,
4322
+ rawRepresentation,
4323
+ throws,
4324
+ rawGenericSig);
4325
+ genericSig = getGenericSignature (rawGenericSig);
4326
+ }
4336
4327
4337
- decls_block::FunctionTypeLayout::readRecord (scratch, inputID, resultID,
4338
- rawRepresentation,
4339
- autoClosure,
4340
- noescape,
4341
- throws);
4342
4328
auto representation = getActualFunctionTypeRepresentation (rawRepresentation);
4343
4329
if (!representation.hasValue ()) {
4344
4330
error ();
@@ -4348,14 +4334,56 @@ Expected<Type> ModuleFile::getTypeChecked(TypeID TID) {
4348
4334
auto info = FunctionType::ExtInfo (*representation, autoClosure, noescape,
4349
4335
throws);
4350
4336
4351
- auto inputTy = getTypeChecked (inputID);
4352
- if (!inputTy)
4353
- return inputTy.takeError ();
4354
4337
auto resultTy = getTypeChecked (resultID);
4355
4338
if (!resultTy)
4356
4339
return resultTy.takeError ();
4357
4340
4358
- typeOrOffset = FunctionType::get (inputTy.get (), resultTy.get (), info);
4341
+ SmallVector<AnyFunctionType::Param, 8 > params;
4342
+ while (true ) {
4343
+ auto entry = DeclTypeCursor.advance (AF_DontPopBlockAtEnd);
4344
+ if (entry.Kind != llvm::BitstreamEntry::Record)
4345
+ break ;
4346
+
4347
+ scratch.clear ();
4348
+ unsigned recordID = DeclTypeCursor.readRecord (entry.ID , scratch,
4349
+ &blobData);
4350
+ if (recordID != decls_block::FUNCTION_PARAM)
4351
+ break ;
4352
+
4353
+ IdentifierID labelID;
4354
+ TypeID typeID;
4355
+ bool isVariadic, isAutoClosure, isEscaping;
4356
+ unsigned rawOwnership;
4357
+ decls_block::FunctionParamLayout::readRecord (scratch, labelID, typeID,
4358
+ isVariadic, isAutoClosure,
4359
+ isEscaping, rawOwnership);
4360
+
4361
+ auto ownership =
4362
+ getActualValueOwnership ((serialization::ValueOwnership)rawOwnership);
4363
+ if (!ownership) {
4364
+ error ();
4365
+ return nullptr ;
4366
+ }
4367
+
4368
+ auto paramTy = getTypeChecked (typeID);
4369
+ if (!paramTy)
4370
+ return paramTy.takeError ();
4371
+
4372
+ params.emplace_back (paramTy.get (),
4373
+ getIdentifier (labelID),
4374
+ ParameterTypeFlags (isVariadic, isAutoClosure,
4375
+ isEscaping, *ownership));
4376
+ }
4377
+
4378
+ if (recordID == decls_block::FUNCTION_TYPE) {
4379
+ assert (genericSig == nullptr );
4380
+ typeOrOffset = FunctionType::get (params, resultTy.get (), info);
4381
+ } else {
4382
+ assert (genericSig != nullptr );
4383
+ typeOrOffset = GenericFunctionType::get (genericSig,
4384
+ params, resultTy.get (), info);
4385
+ }
4386
+
4359
4387
break ;
4360
4388
}
4361
4389
@@ -4437,18 +4465,6 @@ Expected<Type> ModuleFile::getTypeChecked(TypeID TID) {
4437
4465
break ;
4438
4466
}
4439
4467
4440
- case decls_block::INOUT_TYPE: {
4441
- TypeID objectTypeID;
4442
- decls_block::InOutTypeLayout::readRecord (scratch, objectTypeID);
4443
-
4444
- auto objectTy = getTypeChecked (objectTypeID);
4445
- if (!objectTy)
4446
- return objectTy.takeError ();
4447
-
4448
- typeOrOffset = InOutType::get (objectTy.get ());
4449
- break ;
4450
- }
4451
-
4452
4468
case decls_block::REFERENCE_STORAGE_TYPE: {
4453
4469
uint8_t rawOwnership;
4454
4470
TypeID objectTypeID;
@@ -4596,40 +4612,6 @@ Expected<Type> ModuleFile::getTypeChecked(TypeID TID) {
4596
4612
break ;
4597
4613
}
4598
4614
4599
- case decls_block::GENERIC_FUNCTION_TYPE: {
4600
- TypeID inputID;
4601
- TypeID resultID;
4602
- uint8_t rawRep;
4603
- bool throws = false ;
4604
- GenericSignatureID rawGenericSig;
4605
-
4606
- decls_block::GenericFunctionTypeLayout::readRecord (scratch,
4607
- inputID,
4608
- resultID,
4609
- rawRep,
4610
- throws,
4611
- rawGenericSig);
4612
- auto rep = getActualFunctionTypeRepresentation (rawRep);
4613
- if (!rep.hasValue ()) {
4614
- error ();
4615
- return nullptr ;
4616
- }
4617
-
4618
- auto sig = getGenericSignature (rawGenericSig);
4619
- auto info = GenericFunctionType::ExtInfo (*rep, throws);
4620
-
4621
- auto inputTy = getTypeChecked (inputID);
4622
- if (!inputTy)
4623
- return inputTy.takeError ();
4624
- auto resultTy = getTypeChecked (resultID);
4625
- if (!resultTy)
4626
- return resultTy.takeError ();
4627
-
4628
- typeOrOffset = GenericFunctionType::get (sig, inputTy.get (), resultTy.get (),
4629
- info);
4630
- break ;
4631
- }
4632
-
4633
4615
case decls_block::SIL_BLOCK_STORAGE_TYPE: {
4634
4616
TypeID captureID;
4635
4617
0 commit comments