Allow '+new' in produced framework for classes with empty constructor
This commit is contained in:
committed by
SvyatoslavScherbina
parent
79b0dc5652
commit
9e8d784dac
+11
-2
@@ -244,9 +244,13 @@ internal class ObjCExportHeaderGenerator(val context: Context) {
|
|||||||
val presentConstructors = mutableSetOf<String>()
|
val presentConstructors = mutableSetOf<String>()
|
||||||
|
|
||||||
descriptor.constructors.filter { mapper.shouldBeExposed(it) }.forEach {
|
descriptor.constructors.filter { mapper.shouldBeExposed(it) }.forEach {
|
||||||
if (!descriptor.isArray) presentConstructors += getSelector(it)
|
val selector = getSelector(it)
|
||||||
|
if (!descriptor.isArray) presentConstructors += selector
|
||||||
|
|
||||||
+"${getSignature(it, it)};"
|
+"${getSignature(it, it)};"
|
||||||
|
if (selector == "init") {
|
||||||
|
+"+ (instancetype)new OBJC_SWIFT_UNAVAILABLE(\"use object initializers instead\");"
|
||||||
|
}
|
||||||
+""
|
+""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,8 +282,13 @@ internal class ObjCExportHeaderGenerator(val context: Context) {
|
|||||||
|
|
||||||
// Hide "unimplemented" super constructors:
|
// Hide "unimplemented" super constructors:
|
||||||
superClass?.constructors?.filter { mapper.shouldBeExposed(it) }?.forEach {
|
superClass?.constructors?.filter { mapper.shouldBeExposed(it) }?.forEach {
|
||||||
if (getSelector(it) !in presentConstructors) {
|
val selector = getSelector(it)
|
||||||
|
if (selector !in presentConstructors) {
|
||||||
+"${getSignature(it, it)} __attribute__((unavailable));"
|
+"${getSignature(it, it)} __attribute__((unavailable));"
|
||||||
|
if (selector == "init") {
|
||||||
|
+"+(instancetype) new __attribute__((unavailable));"
|
||||||
|
}
|
||||||
|
|
||||||
+""
|
+""
|
||||||
// TODO: consider adding exception-throwing impls for these.
|
// TODO: consider adding exception-throwing impls for these.
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user