@@ -4278,135 +4278,16 @@ void TypeChecker::validateDecl(ValueDecl *D) {
4278
4278
}
4279
4279
4280
4280
case DeclKind::Func:
4281
- <<<<<<< HEAD
4282
- case DeclKind::Accessor: {
4283
- auto *FD = cast<FuncDecl>(D);
4284
-
4285
- DeclValidationRAII IBV (FD);
4286
-
4287
- // Accessors should pick up various parts of their type signatures
4288
- // directly from the storage declaration instead of re-deriving them.
4289
- // FIXME: should this include the generic signature?
4290
- if (auto accessor = dyn_cast<AccessorDecl>(FD)) {
4291
- auto storage = accessor->getStorage ();
4292
-
4293
- // Note that it's important for correctness that we're filling in
4294
- // empty TypeLocs, because otherwise revertGenericFuncSignature might
4295
- // erase the types we set, causing them to be re-validated in a later
4296
- // pass. That later validation might be incorrect even if the TypeLocs
4297
- // are a clone of the type locs from which we derived the value type,
4298
- // because the rules for interpreting types in parameter contexts
4299
- // are sometimes different from the rules elsewhere; for example,
4300
- // function types default to non-escaping.
4301
-
4302
- auto valueParams = accessor->getParameters ();
4303
-
4304
- // Determine the value type.
4305
- Type valueIfaceTy = storage->getValueInterfaceType ();
4306
- if (auto SD = dyn_cast<SubscriptDecl>(storage)) {
4307
- // Copy the index types instead of re-validating them.
4308
- auto indices = SD->getIndices ();
4309
- for (size_t i = 0 , e = indices->size (); i != e; ++i) {
4310
- auto subscriptParam = indices->get (i);
4311
- if (!subscriptParam->hasInterfaceType ())
4312
- continue ;
4313
-
4314
- Type paramIfaceTy = subscriptParam->getInterfaceType ();
4315
-
4316
- auto accessorParam = valueParams->get (valueParams->size () - e + i);
4317
- accessorParam->setInterfaceType (paramIfaceTy);
4318
- accessorParam->getTypeLoc ().setType (paramIfaceTy);
4319
- }
4320
- }
4321
-
4322
- // Propagate the value type into the correct position.
4323
- switch (accessor->getAccessorKind ()) {
4324
- // For getters, set the result type to the value type.
4325
- case AccessorKind::Get:
4326
- accessor->getBodyResultTypeLoc ().setType (valueIfaceTy);
4327
- break ;
4328
-
4329
- // For setters and observers, set the old/new value parameter's type
4330
- // to the value type.
4331
- case AccessorKind::DidSet:
4332
- case AccessorKind::WillSet:
4333
- case AccessorKind::Set: {
4334
- auto newValueParam = valueParams->get (0 );
4335
- newValueParam->setInterfaceType (valueIfaceTy);
4336
- newValueParam->getTypeLoc ().setType (valueIfaceTy);
4337
- accessor->getBodyResultTypeLoc ().setType (TupleType::getEmpty (Context));
4338
- break ;
4339
- }
4340
-
4341
- // Addressor result types can get complicated because of the owner.
4342
- case AccessorKind::Address:
4343
- case AccessorKind::MutableAddress:
4344
- if (Type resultType =
4345
- buildAddressorResultType (*this , accessor, valueIfaceTy)) {
4346
- accessor->getBodyResultTypeLoc ().setType (resultType);
4347
- }
4348
- break ;
4349
-
4350
- // These don't mention the value type directly.
4351
- // If we add yield types to the function type, we'll need to update this.
4352
- case AccessorKind::Read:
4353
- case AccessorKind::Modify:
4354
- accessor->getBodyResultTypeLoc ().setType (TupleType::getEmpty (Context));
4355
- break ;
4356
- }
4357
- }
4358
-
4359
- // We want the function to be available for name lookup as soon
4360
- // as it has a valid interface type.
4361
- typeCheckParameterList (FD->getParameters (), FD,
4362
- TypeResolverContext::AbstractFunctionDecl);
4363
- validateResultType (FD, FD->getBodyResultTypeLoc ());
4364
- // FIXME: Roll all of this interface type computation into a request.
4365
- FD->computeType ();
4366
-
4367
- // SWIFT_ENABLE_TENSORFLOW
4368
- // TODO(TF-789): Find proper way to type-check `@differentiable` attributes.
4369
- checkDeclDifferentiableAttributes (FD);
4370
- // SWIFT_ENABLE_TENSORFLOW END
4371
-
4372
- // If the function is exported to C, it must be representable in (Obj-)C.
4373
- if (auto CDeclAttr = FD->getAttrs ().getAttribute <swift::CDeclAttr>()) {
4374
- Optional<ForeignErrorConvention> errorConvention;
4375
- if (isRepresentableInObjC (FD, ObjCReason::ExplicitlyCDecl,
4376
- errorConvention)) {
4377
- if (FD->hasThrows ()) {
4378
- FD->setForeignErrorConvention (*errorConvention);
4379
- diagnose (CDeclAttr->getLocation (), diag::cdecl_throws);
4380
- }
4381
- }
4382
- }
4383
-
4384
- break ;
4385
- }
4386
-
4387
- case DeclKind::Constructor: {
4388
- auto *CD = cast<ConstructorDecl>(D);
4389
-
4390
- DeclValidationRAII IBV (CD);
4391
-
4392
- typeCheckParameterList (CD->getParameters (), CD,
4393
- TypeResolverContext::AbstractFunctionDecl);
4394
- CD->computeType ();
4395
- // SWIFT_ENABLE_TENSORFLOW
4396
- // TODO(TF-789): Find proper way to type-check `@differentiable` attributes.
4397
- checkDeclDifferentiableAttributes (CD);
4398
- // SWIFT_ENABLE_TENSORFLOW END
4399
- break ;
4400
- }
4401
-
4402
- =======
4403
4281
case DeclKind::Accessor:
4404
4282
case DeclKind::Constructor:
4405
- >>>>>>> swift-DEVELOPMENT-SNAPSHOT-2019 -10 -13 -a
4406
4283
case DeclKind::Destructor: {
4407
4284
auto *AFD = cast<AbstractFunctionDecl>(D);
4408
4285
DeclValidationRAII IBV (AFD);
4409
4286
AFD->computeType ();
4287
+ // SWIFT_ENABLE_TENSORFLOW
4288
+ // TODO(TF-789): Find proper way to type-check `@differentiable` attributes.
4289
+ checkDeclDifferentiableAttributes (CD);
4290
+ // SWIFT_ENABLE_TENSORFLOW END
4410
4291
break ;
4411
4292
}
4412
4293
@@ -4416,13 +4297,6 @@ void TypeChecker::validateDecl(ValueDecl *D) {
4416
4297
4417
4298
auto elementTy = SD->getElementInterfaceType ();
4418
4299
4419
- <<<<<<< HEAD
4420
- // SWIFT_ENABLE_TENSORFLOW
4421
- // TODO(TF-789): Find proper way to type-check `@differentiable` attributes.
4422
- checkDeclDifferentiableAttributes (SD);
4423
- // SWIFT_ENABLE_TENSORFLOW END
4424
-
4425
- =======
4426
4300
SmallVector<AnyFunctionType::Param, 2 > argTy;
4427
4301
SD->getIndices ()->getParams (argTy);
4428
4302
@@ -4434,7 +4308,11 @@ void TypeChecker::validateDecl(ValueDecl *D) {
4434
4308
4435
4309
// Record the interface type.
4436
4310
SD->setInterfaceType (funcTy);
4437
- >>>>>>> swift-DEVELOPMENT-SNAPSHOT-2019 -10 -13 -a
4311
+ // SWIFT_ENABLE_TENSORFLOW
4312
+ // TODO(TF-789): Find proper way to type-check `@differentiable` attributes.
4313
+ checkDeclDifferentiableAttributes (SD);
4314
+ // SWIFT_ENABLE_TENSORFLOW END
4315
+
4438
4316
break ;
4439
4317
}
4440
4318
0 commit comments