Skip to content

Commit

Permalink
Enable the explicit API mode for Kotlin in the :sample:library module.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcello Galhardo committed Oct 25, 2020
1 parent 6d6d1be commit 03d2f84
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
5 changes: 4 additions & 1 deletion sample/library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ dependencies {
//noinspection UnnecessaryQualifiedReference
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
freeCompilerArgs += [
"-Xexplicit-api=strict",
"-Xopt-in=kotlin.RequiresOptIn",
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import com.squareup.anvil.sample.Parent.MOTHER
import com.squareup.scopes.ComponentHolder
import java.util.Locale

object Description {
public object Description {
@OptIn(ExperimentalStdlibApi::class)
fun of(god: God): String {
public fun of(god: God): String {
val name = god.name.toLowerCase(Locale.US)
.capitalize(Locale.US)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.squareup.anvil.sample.mother.MotherProvider
import com.squareup.scopes.AppScope

@ContributesTo(AppScope::class)
interface DescriptionComponent {
fun fatherProvider(): FatherProvider
fun motherProvider(): MotherProvider
public interface DescriptionComponent {
public fun fatherProvider(): FatherProvider
public fun motherProvider(): MotherProvider
}
4 changes: 2 additions & 2 deletions sample/library/src/main/java/com/squareup/anvil/sample/God.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package com.squareup.anvil.sample
import com.squareup.anvil.sample.Parent.FATHER
import com.squareup.anvil.sample.Parent.MOTHER

enum class God(val parent: Parent) {
public enum class God(public val parent: Parent) {
ZEUS(FATHER),
HERA(MOTHER),
HEPHAESTUS(FATHER),
}

enum class Parent {
public enum class Parent {
FATHER, MOTHER
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package com.squareup.anvil.sample.father

import com.squareup.anvil.sample.God

interface FatherProvider {
fun father(god: God): String
public interface FatherProvider {
public fun father(god: God): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.squareup.anvil.sample.God.ZEUS
import com.squareup.scopes.AppScope

@ContributesBinding(AppScope::class)
object RealFatherProvider : FatherProvider {
public object RealFatherProvider : FatherProvider {
override fun father(god: God): String =
when (god) {
ZEUS, HERA -> "Cronus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package com.squareup.anvil.sample.mother

import com.squareup.anvil.sample.God

interface MotherProvider {
fun mother(god: God): String
public interface MotherProvider {
public fun mother(god: God): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.squareup.anvil.sample.God.ZEUS
import com.squareup.scopes.AppScope

@ContributesBinding(AppScope::class)
object RealMotherProvider : MotherProvider {
public object RealMotherProvider : MotherProvider {
override fun mother(god: God): String =
when (god) {
HERA, ZEUS -> "Rhea"
Expand Down

0 comments on commit 03d2f84

Please sign in to comment.