Skip to content

Warnings when using Kotlin 2.3.0-RC #3467

@ansman

Description

@ansman

When using repeated fields, wire generates this code:

var floats: MutableList<Float>? = null
val unknownFields = reader.forEachTag { tag ->
  when (tag) {
    1 -> {
      if (floats == null) {
        val minimumByteSize = 4
        val initialCapacity = (reader.nextFieldMinLengthInBytes() / minimumByteSize)
          .coerceAtMost(Int.MAX_VALUE.toLong())
          .toInt()
        floats = ArrayList(initialCapacity)
      }
      floats!!.add(ProtoAdapter.FLOAT.decode(reader))
    }
}

With kotlin 2.3, this leads to a warning because floats is proven to be non null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions