Handle newline character in deprecation message in ObjCExport

#KT-39206 Fixed
This commit is contained in:
Svyatoslav Scherbina
2020-08-19 18:14:47 +03:00
committed by SvyatoslavScherbina
parent fac1cf189c
commit b1a9715907
4 changed files with 40 additions and 0 deletions
@@ -1234,6 +1234,7 @@ private fun Deprecation.toDeprecationAttribute(): String {
// TODO: consider avoiding code generation for unavailable.
val message = this.message.orEmpty()
.replace("\n", "\\n")
return "$attribute(\"$message\")"
}
@@ -513,6 +513,18 @@ __attribute__((swift_name("Kt38641Kt")))
+ (void)setOverrideVarDescriptionImpl:(id<KtKT38641OverrideVar>)impl newValue:(NSString *)newValue __attribute__((swift_name("setOverrideVarDescription(impl:newValue:)")));
@end;
__attribute__((swift_name("JsonConfiguration")))
@interface KtJsonConfiguration : KtBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable("This class is deprecated for removal during serialization 1.0 API stabilization.\nFor configuring Json instances, the corresponding builder function can be used instead, e.g. instead of'Json(JsonConfiguration.Stable.copy(isLenient = true))' 'Json { isLenient = true }' should be used.\nInstead of storing JsonConfiguration instances of the code, Json instances can be used directly:'Json(MyJsonConfiguration.copy(prettyPrint = true))' can be replaced with 'Json(from = MyApplicationJson) { prettyPrint = true }'")));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Kt39206Kt")))
@interface KtKt39206Kt : KtBase
+ (int32_t)myFunc __attribute__((swift_name("myFunc()"))) __attribute__((deprecated("Don't call this\nPlease")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("LibraryKt")))
@interface KtLibraryKt : KtBase
@@ -0,0 +1,14 @@
// See https://youtrack.jetbrains.com/issue/KT-39206.
@Deprecated("Don't call this\nPlease")
fun myFunc() = 17
// See https://youtrack.jetbrains.com/issue/KT-41193.
@Deprecated(
level = DeprecationLevel.ERROR,
message = "This class is deprecated for removal during serialization 1.0 API stabilization.\n" +
"For configuring Json instances, the corresponding builder function can be used instead, e.g. instead of" +
"'Json(JsonConfiguration.Stable.copy(isLenient = true))' 'Json { isLenient = true }' should be used.\n" +
"Instead of storing JsonConfiguration instances of the code, Json instances can be used directly:" +
"'Json(MyJsonConfiguration.copy(prettyPrint = true))' can be replaced with 'Json(from = MyApplicationJson) { prettyPrint = true }'"
)
public open class JsonConfiguration
@@ -0,0 +1,13 @@
import Kt
private func test1() throws {
try assertEquals(actual: Kt39206Kt.myFunc(), expected: 17)
}
class Kt39206Tests : SimpleTestProvider {
override init() {
super.init()
test("Test1", test1)
}
}