@@ -911,12 +911,10 @@ static void collectNonOveriddenSuperclassInits(
911
911
static void addImplicitInheritedConstructorsToClass (ClassDecl *decl) {
912
912
// Bail out if we're validating one of our constructors already;
913
913
// we'll revisit the issue later.
914
- if (!decl->hasClangNode ()) {
915
- for (auto member : decl->getMembers ()) {
916
- if (auto ctor = dyn_cast<ConstructorDecl>(member)) {
917
- if (ctor->isRecursiveValidation ())
918
- return ;
919
- }
914
+ for (auto member : decl->getMembers ()) {
915
+ if (auto ctor = dyn_cast<ConstructorDecl>(member)) {
916
+ if (ctor->isRecursiveValidation ())
917
+ return ;
920
918
}
921
919
}
922
920
@@ -925,34 +923,16 @@ static void addImplicitInheritedConstructorsToClass(ClassDecl *decl) {
925
923
auto &ctx = decl->getASTContext ();
926
924
SmallVector<std::pair<ValueDecl *, Type>, 4 > declaredInitializers;
927
925
llvm::SmallPtrSet<ConstructorDecl *, 4 > overriddenInits;
928
- if (decl->hasClangNode ()) {
929
- // Objective-C classes may have interesting initializers in extensions.
930
- for (auto member : decl->lookupDirect (DeclBaseName::createConstructor ())) {
931
- auto ctor = dyn_cast<ConstructorDecl>(member);
932
- if (!ctor)
933
- continue ;
934
-
935
- // Swift initializers added in extensions of Objective-C classes can never
936
- // be overrides.
937
- if (!ctor->hasClangNode ())
938
- continue ;
926
+ for (auto member : decl->getMembers ()) {
927
+ if (auto ctor = dyn_cast<ConstructorDecl>(member)) {
928
+ if (!ctor->isInvalid ()) {
929
+ auto type = getMemberTypeForComparison (ctx, ctor, nullptr );
930
+ declaredInitializers.push_back ({ctor, type});
931
+ }
939
932
940
933
if (auto overridden = ctor->getOverriddenDecl ())
941
934
overriddenInits.insert (overridden);
942
935
}
943
-
944
- } else {
945
- for (auto member : decl->getMembers ()) {
946
- if (auto ctor = dyn_cast<ConstructorDecl>(member)) {
947
- if (!ctor->isInvalid ()) {
948
- auto type = getMemberTypeForComparison (ctx, ctor, nullptr );
949
- declaredInitializers.push_back ({ctor, type});
950
- }
951
-
952
- if (auto overridden = ctor->getOverriddenDecl ())
953
- overriddenInits.insert (overridden);
954
- }
955
- }
956
936
}
957
937
958
938
// We can only inherit initializers if we have a superclass.
@@ -972,7 +952,7 @@ static void addImplicitInheritedConstructorsToClass(ClassDecl *decl) {
972
952
973
953
// We can't define these overrides if we have any uninitialized
974
954
// stored properties.
975
- if (!defaultInitable && !foundDesignatedInit && !decl-> hasClangNode () )
955
+ if (!defaultInitable && !foundDesignatedInit)
976
956
return ;
977
957
978
958
auto *superclassDecl = superclassTy->getClassOrBoundGenericClass ();
@@ -1001,10 +981,6 @@ static void addImplicitInheritedConstructorsToClass(ClassDecl *decl) {
1001
981
continue ;
1002
982
}
1003
983
1004
- // Everything after this is only relevant for Swift classes being defined.
1005
- if (decl->hasClangNode ())
1006
- continue ;
1007
-
1008
984
// If the superclass initializer is not accessible from the derived
1009
985
// class, don't synthesize an override, since we cannot reference the
1010
986
// superclass initializer's method descriptor at all.
@@ -1087,6 +1063,10 @@ InheritsSuperclassInitializersRequest::evaluate(Evaluator &eval,
1087
1063
}
1088
1064
1089
1065
static bool shouldAttemptInitializerSynthesis (const NominalTypeDecl *decl) {
1066
+ // Don't synthesize initializers for imported decls.
1067
+ if (decl->hasClangNode ())
1068
+ return false ;
1069
+
1090
1070
// Don't add implicit constructors in module interfaces.
1091
1071
if (auto *SF = decl->getParentSourceFile ())
1092
1072
if (SF->Kind == SourceFileKind::Interface)
@@ -1216,10 +1196,6 @@ HasMemberwiseInitRequest::evaluate(Evaluator &evaluator,
1216
1196
if (!shouldAttemptInitializerSynthesis (decl))
1217
1197
return false ;
1218
1198
1219
- // Don't synthesize a memberwise init for imported decls.
1220
- if (decl->hasClangNode ())
1221
- return false ;
1222
-
1223
1199
// If the user has already defined a designated initializer, then don't
1224
1200
// synthesize a memberwise init.
1225
1201
if (hasUserDefinedDesignatedInit (evaluator, decl))
@@ -1258,10 +1234,6 @@ HasDefaultInitRequest::evaluate(Evaluator &evaluator,
1258
1234
if (!shouldAttemptInitializerSynthesis (decl))
1259
1235
return false ;
1260
1236
1261
- // Don't synthesize a default for imported decls.
1262
- if (decl->hasClangNode ())
1263
- return false ;
1264
-
1265
1237
if (auto *sd = dyn_cast<StructDecl>(decl)) {
1266
1238
assert (!sd->hasUnreferenceableStorage () &&
1267
1239
" User-defined structs cannot have unreferenceable storage" );
0 commit comments