@@ -3249,6 +3249,20 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3249
3249
FD->getFullName ());
3250
3250
}
3251
3251
}
3252
+
3253
+ // If the function is exported to C, it must be representable in (Obj-)C.
3254
+ // FIXME: This needs to be moved to its own request if we want to
3255
+ // productize @_cdecl.
3256
+ if (auto CDeclAttr = FD->getAttrs ().getAttribute <swift::CDeclAttr>()) {
3257
+ Optional<ForeignErrorConvention> errorConvention;
3258
+ if (isRepresentableInObjC (FD, ObjCReason::ExplicitlyCDecl,
3259
+ errorConvention)) {
3260
+ if (FD->hasThrows ()) {
3261
+ FD->setForeignErrorConvention (*errorConvention);
3262
+ TC.diagnose (CDeclAttr->getLocation (), diag::cdecl_throws);
3263
+ }
3264
+ }
3265
+ }
3252
3266
}
3253
3267
3254
3268
void visitModuleDecl (ModuleDecl *) { }
@@ -4108,10 +4122,6 @@ static void validateParameterType(ParamDecl *decl) {
4108
4122
}
4109
4123
4110
4124
void TypeChecker::validateDecl (ValueDecl *D) {
4111
- // Generic parameters are validated as part of their context.
4112
- if (isa<GenericTypeParamDecl>(D))
4113
- return ;
4114
-
4115
4125
// Handling validation failure due to re-entrancy is left
4116
4126
// up to the caller, who must call hasInterfaceType() to
4117
4127
// check that validateDecl() returned a fully-formed decl.
@@ -4139,13 +4149,11 @@ void TypeChecker::validateDecl(ValueDecl *D) {
4139
4149
case DeclKind::IfConfig:
4140
4150
case DeclKind::PoundDiagnostic:
4141
4151
case DeclKind::MissingMember:
4142
- llvm_unreachable (" not a value decl" );
4143
-
4144
4152
case DeclKind::Module:
4145
- return ;
4146
-
4153
+ case DeclKind::OpaqueType:
4147
4154
case DeclKind::GenericTypeParam:
4148
- llvm_unreachable (" handled above" );
4155
+ llvm_unreachable (" should not get here" );
4156
+ return ;
4149
4157
4150
4158
case DeclKind::AssociatedType: {
4151
4159
auto assocType = cast<AssociatedTypeDecl>(D);
@@ -4158,9 +4166,6 @@ void TypeChecker::validateDecl(ValueDecl *D) {
4158
4166
typeAlias->computeType ();
4159
4167
break ;
4160
4168
}
4161
-
4162
- case DeclKind::OpaqueType:
4163
- break ;
4164
4169
4165
4170
case DeclKind::Enum:
4166
4171
case DeclKind::Struct:
@@ -4254,40 +4259,12 @@ void TypeChecker::validateDecl(ValueDecl *D) {
4254
4259
}
4255
4260
4256
4261
case DeclKind::Func:
4257
- case DeclKind::Accessor: {
4258
- auto *FD = cast<FuncDecl>(D);
4259
-
4260
- DeclValidationRAII IBV (FD);
4261
-
4262
- // FIXME: Roll all of this interface type computation into a request.
4263
- FD->computeType ();
4264
-
4265
- // If the function is exported to C, it must be representable in (Obj-)C.
4266
- if (auto CDeclAttr = FD->getAttrs ().getAttribute <swift::CDeclAttr>()) {
4267
- Optional<ForeignErrorConvention> errorConvention;
4268
- if (isRepresentableInObjC (FD, ObjCReason::ExplicitlyCDecl,
4269
- errorConvention)) {
4270
- if (FD->hasThrows ()) {
4271
- FD->setForeignErrorConvention (*errorConvention);
4272
- diagnose (CDeclAttr->getLocation (), diag::cdecl_throws);
4273
- }
4274
- }
4275
- }
4276
-
4277
- break ;
4278
- }
4279
-
4280
- case DeclKind::Constructor: {
4281
- auto *CD = cast<ConstructorDecl>(D);
4282
- DeclValidationRAII IBV (CD);
4283
- CD->computeType ();
4284
- break ;
4285
- }
4286
-
4262
+ case DeclKind::Accessor:
4263
+ case DeclKind::Constructor:
4287
4264
case DeclKind::Destructor: {
4288
- auto *DD = cast<DestructorDecl >(D);
4289
- DeclValidationRAII IBV (DD );
4290
- DD ->computeType ();
4265
+ auto *AFD = cast<AbstractFunctionDecl >(D);
4266
+ DeclValidationRAII IBV (AFD );
4267
+ AFD ->computeType ();
4291
4268
break ;
4292
4269
}
4293
4270
0 commit comments