Skip to content

Conversation

@swankjesse
Copy link
Collaborator

The result is that IntelliJ + Kotlin correctly infers the right nullability
for Okio's APIs. I used IntelliJ's "Specify types explicitly" quick fix on
the 'a' and 'b' variables below and it did the right thing.

fun specifyTypeExplicitly(source: BufferedSource) {
  val a: String? = source.readUtf8Line()
  val b: String = source.readUtf8LineStrict()
}

@swankjesse
Copy link
Collaborator Author

I had 3 choices for @Nullable (Android, JetBrains, JSR-305). I decided to go with JSR-305 for these reasons:

  1. The package-level @ParametersAreNonnullByDefault means we don’t need to litter annotations everywhere.
  2. Guava uses it, so many applications already import it

I’m not happy adding a dependency from Okio onto anything. I’m convincing myself that it’s okay.

@codefromthecrypt
Copy link

codefromthecrypt commented May 2, 2017 via email

@swankjesse
Copy link
Collaborator Author

I’m going to try making this a provided dependency. That’d prevent it from showing up in end-users builds. It shouldn’t impact static analysis.

The result is that IntelliJ + Kotlin correctly infers the right nullability
for Okio's APIs. I used IntelliJ's "Specify types explicitly" quick fix on
the 'a' and 'b' variables below and it did the right thing.

    fun specifyTypeExplicitly(source: BufferedSource) {
      val a: String? = source.readUtf8Line()
      val b: String = source.readUtf8LineStrict()
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants