mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SILGen] Also handle initializers without bodies
I was surprised to see this parses fine already, but SILGen still needs a new check.
This commit is contained in:
@@ -776,9 +776,9 @@ void SILGenModule::emitConstructor(ConstructorDecl *decl) {
|
||||
postEmitFunction(constant, f);
|
||||
});
|
||||
|
||||
// If this constructor was imported, we don't need the initializing
|
||||
// constructor to be emitted.
|
||||
if (!decl->hasClangNode()) {
|
||||
// Constructors may not have bodies if they've been imported, or if they've
|
||||
// been parsed from a textual interface.
|
||||
if (decl->hasBody()) {
|
||||
SILDeclRef initConstant(decl, SILDeclRef::Kind::Initializer);
|
||||
emitOrDelayFunction(
|
||||
*this, initConstant,
|
||||
@@ -796,14 +796,16 @@ void SILGenModule::emitConstructor(ConstructorDecl *decl) {
|
||||
}
|
||||
} else {
|
||||
// Struct and enum constructors do everything in a single function.
|
||||
emitOrDelayFunction(
|
||||
*this, constant, [this, constant, decl, declCtx](SILFunction *f) {
|
||||
preEmitFunction(constant, decl, f, decl);
|
||||
PrettyStackTraceSILFunction X("silgen emitConstructor", f);
|
||||
f->setProfiler(getOrCreateProfilerForConstructors(declCtx, decl));
|
||||
SILGenFunction(*this, *f, decl).emitValueConstructor(decl);
|
||||
postEmitFunction(constant, f);
|
||||
});
|
||||
if (decl->hasBody()) {
|
||||
emitOrDelayFunction(
|
||||
*this, constant, [this, constant, decl, declCtx](SILFunction *f) {
|
||||
preEmitFunction(constant, decl, f, decl);
|
||||
PrettyStackTraceSILFunction X("silgen emitConstructor", f);
|
||||
f->setProfiler(getOrCreateProfilerForConstructors(declCtx, decl));
|
||||
SILGenFunction(*this, *f, decl).emitValueConstructor(decl);
|
||||
postEmitFunction(constant, f);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,15 @@
|
||||
|
||||
// CHECK-LABEL: public class Test
|
||||
public class Test {
|
||||
// CHECK: public init(){{$}}
|
||||
public init()
|
||||
|
||||
// CHECK: public func method(){{$}}
|
||||
public func method()
|
||||
|
||||
// CHECK: public subscript(_: Int) -> Void{{$}}
|
||||
public subscript(_: Int) -> Void { get set }
|
||||
|
||||
// NEGATIVE-NOT: deinit
|
||||
deinit
|
||||
} // CHECK: {{^}$}}
|
||||
|
||||
Reference in New Issue
Block a user