mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
Suppress common warnings in generated classes (#1028)
* Suppress common warnings in generated classes Followup from #1023 (Resolves #1023 too). Since we can't do targeted deprecation suppressions, we can just stick with blanket deprecations suppressions for now. This also suppresses a couple other common issues with all our generated adapters. Have just eyeballed the results for now, can add a proper test as a followup once #1014 is in * Add redundant projection and re-enable -Werror * Add tests for deprecation suppression With -Werror enabled now we can actually check this
This commit is contained in:
@@ -115,11 +115,7 @@
|
||||
</executions>
|
||||
<configuration>
|
||||
<args>
|
||||
<!--
|
||||
Disabled for now because we generate redundant `out` variance for some generics,
|
||||
but there's no way for us to know when it's redundant.
|
||||
-->
|
||||
<!-- <arg>-Werror</arg>-->
|
||||
<arg>-Werror</arg>
|
||||
<arg>-Xuse-experimental=kotlin.ExperimentalStdlibApi</arg>
|
||||
<arg>-XXLanguage:+InlineClasses</arg>
|
||||
</args>
|
||||
|
@@ -513,6 +513,7 @@ class DualKotlinTest(useReflection: Boolean) {
|
||||
assertThat(result).isEqualTo(instance)
|
||||
}
|
||||
|
||||
@Suppress("REDUNDANT_NULLABLE")
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class TypeAliasNullability(
|
||||
val aShouldBeNonNull: A,
|
||||
|
@@ -1169,6 +1169,22 @@ class GeneratedAdaptersTest {
|
||||
val instance = adapter.fromJson("""{"_links": "link", "_ids": "id" }""")!!
|
||||
assertThat(instance).isEqualTo(ClassWithFieldJson("link").apply { ids = "id" })
|
||||
}
|
||||
|
||||
/*
|
||||
* These are a smoke test for https://github.com/square/moshi/issues/1023 to ensure that we
|
||||
* suppress deprecation warnings for using deprecated properties or classes.
|
||||
*
|
||||
* Ideally when stubs are fixed to actually included Deprecated annotations, we could then only
|
||||
* generate a deprecation suppression as needed and on targeted usages.
|
||||
* https://youtrack.jetbrains.com/issue/KT-34951
|
||||
*/
|
||||
|
||||
@Deprecated("Deprecated for reasons")
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class DeprecatedClass(val foo: String)
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class DeprecatedProperty(@Deprecated("Deprecated for reasons") val foo: String)
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/square/moshi/issues/1022
|
||||
|
Reference in New Issue
Block a user