Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Oct 24, 2023
1 parent cd5d8b3 commit 6da5646
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public annotation class AdaptedBy(val adapter: KClass<*>, val nullSafe: Boolean
"value must be a JsonAdapter or JsonAdapter.Factory."
)
}
}
?: return null
} ?: return null

return if (adaptedBy.nullSafe) {
adapter.nullSafe()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ internal fun TargetProperty.generator(
val qualifierRawType = jsonQualifier.type.classOrNull!!.owner
val retentionValue =
qualifierRawType.getAnnotation(FqName("kotlin.annotation.Retention"))?.getValueArgument(0)
as IrGetEnumValue?
?: continue
as IrGetEnumValue? ?: continue
// TODO what about java qualifiers types?
val retention = retentionValue.symbol.owner.name.identifier
// Check Java types since that covers both Java and Kotlin annotations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,7 @@ private constructor(
targetType = targetType.defaultType,
moshiParam = moshiParam
)
}
?: subtypesExpression
} ?: subtypesExpression

// .create(Message::class.java, emptySet(), moshi) as JsonAdapter<Message>
irExprBody(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,8 @@ internal class IrSourcePrinterVisitor(
print(": ")
val type =
declaration.backingField?.type
?: declaration.getter?.returnType ?: error("Couldn't find return type")
?: declaration.getter?.returnType
?: error("Couldn't find return type")
print(type.renderSrc())
declaration.backingField?.let { field ->
field.initializer?.let { initializer ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ internal fun IrBuilderWithScope.defaultPrimitiveValue(
internal val IrProperty.type: IrType
get() =
getter?.returnType
?: setter?.valueParameters?.first()?.type ?: backingField?.type
?: error("No type for property $name")
?: setter?.valueParameters?.first()?.type
?: backingField?.type
?: error("No type for property $name")

internal fun DescriptorVisibility.checkIsVisible() {
if (this != DescriptorVisibilities.PUBLIC && this != DescriptorVisibilities.INTERNAL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ private val PRIMITIVE_CLASS_TO_DESC =
internal val Class<*>.descriptor: String
get() {
return when {
isPrimitive -> PRIMITIVE_CLASS_TO_DESC[this]?.toString()
isPrimitive ->
PRIMITIVE_CLASS_TO_DESC[this]?.toString()
?: throw RuntimeException("Unrecognized primitive $this")
isArray -> "[${componentType.descriptor}"
else -> "L$name;".replace('.', '/')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ internal data class KtProperty(

val javaType =
jvmField?.genericType
?: jvmGetter?.genericReturnType ?: jvmSetter?.genericReturnType
?: error(
?: jvmGetter?.genericReturnType
?: jvmSetter?.genericReturnType
?: error(
"No type information available for property '${km.name}' with type '${km.returnType.canonicalName}'."
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ private class MoshiSealedSymbolProcessor(environment: SymbolProcessorEnvironment
val alternates =
labelAnnotation.arguments.find { it.name?.getShortName() == "alternateLabels" }?.value
as? List<String> // arrays are lists in KSP https://github.com/google/ksp/issues/135
?: emptyList() // ksp ignores undefined args
?: emptyList() // ksp ignores undefined args

for (alternate in alternates) {
seenLabels.put(alternate, className)?.let { prev ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public class MetadataMoshiSealedJsonAdapterFactory : JsonAdapter.Factory {
val parentLabelKey =
supertypes.firstNotNullOfOrNull { supertype ->
supertype.getAnnotation(JsonClass::class.java)?.labelKey()
}
?: error("No JsonClass-annotated sealed supertype found for $rawType")
} ?: error("No JsonClass-annotated sealed supertype found for $rawType")
check(parentLabelKey != labelKey) {
"@NestedSealed-annotated subtype $rawType is inappropriately annotated with @JsonClass(generator = \"sealed:$labelKey\")."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public class MoshiSealedJsonAdapterFactory : JsonAdapter.Factory {
(supertype.classifier as? KClass<*>)?.findAnnotation<JsonClass>()
?: supertype.findAnnotation()
nestedJsonClass?.labelKey()
}
?: error("No JsonClass-annotated sealed supertype found for $rawTypeKotlin")
} ?: error("No JsonClass-annotated sealed supertype found for $rawTypeKotlin")
check(parentLabelKey != labelKey) {
"@NestedSealed-annotated subtype $rawType is inappropriately annotated with @JsonClass(generator = \"sealed:$labelKey\")."
}
Expand Down

0 comments on commit 6da5646

Please sign in to comment.