Skip to content

Commit c1e8924

Browse files
authored
Merge pull request #69559 from tshortli/module-interface-lazy-typecheck-has-missing-inits
AST: Make HasMissingDesignatedInitializersRequest more consistent
2 parents 040e7a7 + 62c9d8e commit c1e8924

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

lib/AST/NameLookupRequests.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "swift/AST/NameLookup.h"
1413
#include "swift/AST/NameLookupRequests.h"
1514
#include "swift/AST/ASTContext.h"
1615
#include "swift/AST/Decl.h"
16+
#include "swift/AST/Evaluator.h"
1717
#include "swift/AST/GenericParamList.h"
18+
#include "swift/AST/Module.h"
19+
#include "swift/AST/NameLookup.h"
1820
#include "swift/AST/PotentialMacroExpansions.h"
1921
#include "swift/AST/ProtocolConformance.h"
20-
#include "swift/AST/Evaluator.h"
21-
#include "swift/AST/Module.h"
2222
#include "swift/AST/SourceFile.h"
23+
#include "swift/AST/TypeCheckRequests.h"
2324
#include "swift/ClangImporter/ClangImporterRequests.h"
2425
#include "swift/Subsystems.h"
2526

@@ -156,6 +157,13 @@ HasMissingDesignatedInitializersRequest::evaluate(Evaluator &evaluator,
156157
if (!scope.isPublic())
157158
return false;
158159

160+
// Make sure any implicit constructors are synthesized.
161+
(void)evaluateOrDefault(
162+
evaluator,
163+
ResolveImplicitMemberRequest{subject,
164+
ImplicitMemberAction::ResolveImplicitInit},
165+
{});
166+
159167
auto constructors = subject->lookupDirect(DeclBaseName::createConstructor());
160168
return llvm::any_of(constructors, [&](ValueDecl *decl) {
161169
auto init = cast<ConstructorDecl>(decl);

test/Inputs/lazy_typecheck.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ public class PublicClass {
206206

207207
public class PublicDerivedClass: PublicClass {}
208208

209+
open class PublicClassSynthesizedDesignatedInit {}
210+
209211
class InternalClass: NoTypecheckProto {
210212
init(x: NoTypecheck) {}
211213
}

test/Inputs/lazy_typecheck_client.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func testPublicStruct() {
4343
PublicStruct.activeMethod()
4444
}
4545

46-
func testPublicClass() {
46+
func testPublicClasses() {
4747
let c = PublicClass(x: 2)
4848
let _: Int = c.publicMethod()
4949
let _: Int = c.publicProperty
@@ -55,6 +55,11 @@ func testPublicClass() {
5555
let _: Int = d.publicProperty
5656
let _: String = d.publicPropertyInferredType
5757
PublicDerivedClass.publicClassMethod()
58+
59+
class DerivedFromPublicClassSynthesizedDesignatedInit: PublicClassSynthesizedDesignatedInit {
60+
init() {}
61+
}
62+
let _ = DerivedFromPublicClassSynthesizedDesignatedInit()
5863
}
5964

6065
func testPublicEnum(_ e: PublicEnum) {

0 commit comments

Comments
 (0)