Skip to content

Commit

Permalink
Upgrade all modules except for the gradle-plugin to Kotlin 1.4.10.
Browse files Browse the repository at this point in the history
  • Loading branch information
vRallev committed Nov 20, 2020
1 parent 5505384 commit 57c0e35
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# solution.
fail-fast: false
matrix:
kotlin-version: [1.3.72, 1.4.10, 1.4.20-RC]
kotlin-version: [1.4.10, 1.4.20-RC]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -142,7 +142,7 @@ jobs:
# solution.
fail-fast: false
matrix:
kotlin-version: [1.3.72, 1.4.10]
kotlin-version: [1.4.10]

steps:
- uses: actions/checkout@v2
Expand Down
12 changes: 4 additions & 8 deletions compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ if (rootProject.ext.kotlinIrSupported) {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"

// TODO: remove the if-check when upgrading to Kotlin 1.4.
if (rootProject.ext.kotlinVersion.startsWith('1.4')) {
// The flag is needed because we extend an interface that uses @JvmDefault and the Kotlin
// compiler requires this flag when doing so.
freeCompilerArgs += "-Xjvm-default=enable"
}

// The flag is needed because we extend an interface that uses @JvmDefault and the Kotlin
// compiler requires this flag when doing so.
freeCompilerArgs += "-Xjvm-default=enable"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ internal class BindingModuleGenerator(
.toList()
}

@OptIn(ExperimentalStdlibApi::class)
override fun flush(
codeGenDir: File,
module: ModuleDescriptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() {
}
}

@OptIn(ExperimentalStdlibApi::class)
private fun generateFactoryClass(
codeGenDir: File,
module: ModuleDescriptor,
Expand All @@ -60,7 +59,7 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() {
val packageName = clazz.containingKtFile.packageFqName.asString()
val className = "${clazz.generateClassName()}_Factory"

val parameters = constructor.getValueParameters().mapToParameter(module)
val parameters = constructor.valueParameters.mapToParameter(module)

val typeParameters = clazz.typeParameterList
?.parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() {
}
}

@OptIn(ExperimentalStdlibApi::class)
private fun generateMembersInjectorClass(
codeGenDir: File,
module: ModuleDescriptor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() {
}
}

@OptIn(ExperimentalStdlibApi::class)
private fun generateFactoryClass(
codeGenDir: File,
module: ModuleDescriptor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,37 +116,32 @@ internal val Result.innerModule: Class<*>
internal val Result.injectClass: Class<*>
get() = classLoader.loadClass("com.squareup.test.InjectClass")

@OptIn(ExperimentalStdlibApi::class)
internal val Class<*>.hintContributes: KClass<*>?
get() = contributedProperties(HINT_CONTRIBUTES_PACKAGE_PREFIX)
?.filter { it.java == this }
?.also { assertThat(it.size).isEqualTo(1) }
?.first()

@OptIn(ExperimentalStdlibApi::class)
internal val Class<*>.hintContributesScope: KClass<*>?
get() = contributedProperties(HINT_CONTRIBUTES_PACKAGE_PREFIX)
?.also { assertThat(it.size).isEqualTo(2) }
?.filter { it.java != this }
?.also { assertThat(it.size).isEqualTo(1) }
?.first()

@OptIn(ExperimentalStdlibApi::class)
internal val Class<*>.hintBinding: KClass<*>?
get() = contributedProperties(HINT_BINDING_PACKAGE_PREFIX)
?.filter { it.java == this }
?.also { assertThat(it.size).isEqualTo(1) }
?.first()

@OptIn(ExperimentalStdlibApi::class)
internal val Class<*>.hintBindingScope: KClass<*>?
get() = contributedProperties(HINT_BINDING_PACKAGE_PREFIX)
?.also { assertThat(it.size).isEqualTo(2) }
?.filter { it.java != this }
?.also { assertThat(it.size).isEqualTo(1) }
?.first()

@OptIn(ExperimentalStdlibApi::class)
internal fun Class<*>.moduleFactoryClass(
providerMethodName: String,
companion: Boolean = false
Expand All @@ -160,22 +155,19 @@ internal fun Class<*>.moduleFactoryClass(
)
}

@OptIn(ExperimentalStdlibApi::class)
internal fun Class<*>.factoryClass(): Class<*> {
val enclosingClassString = enclosingClass?.let { "${it.simpleName}_" } ?: ""

return classLoader.loadClass("${`package`.name}.$enclosingClassString${simpleName}_Factory")
}

@OptIn(ExperimentalStdlibApi::class)
internal fun Class<*>.membersInjector(): Class<*> {
val enclosingClassString = enclosingClass?.let { "${it.simpleName}_" } ?: ""

return classLoader.loadClass("${`package`.name}." +
"$enclosingClassString${simpleName}_MembersInjector")
}

@OptIn(ExperimentalStdlibApi::class)
private fun Class<*>.contributedProperties(packagePrefix: String): List<KClass<*>>? {
// The capitalize() doesn't make sense, I don't know where this is coming from. Maybe it's a
// bug in the compile testing library?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public final class InjectClass_MembersInjector implements MembersInjector<Inject
Provider::class.java, Provider::class.java
)

@Suppress("RedundantLambdaArrow")
val membersInjectorInstance = constructor
.newInstance(
Provider { "a" }, Provider<CharSequence> { "b" }, Provider { listOf("c") },
Expand Down Expand Up @@ -675,7 +676,6 @@ public final class InjectClass_MembersInjector<T, U, V> implements MembersInject
}
}

@OptIn(ExperimentalStdlibApi::class)
private fun Class<*>.staticInjectMethod(memberName: String): Method {
// We can't check the @InjectedFieldSignature annotation unfortunately, because it has class
// retention.
Expand Down
9 changes: 8 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ext {
daggerVersion = '2.28'
espressoVersion = '3.2.0'
kotlinVersion = project.hasProperty('square.kotlinVersion') ?
project.getProperty('square.kotlinVersion') : '1.3.72'
project.getProperty('square.kotlinVersion') : '1.4.10'

kotlinUseIR = (project.hasProperty('square.useIR') ?
project.getProperty('square.useIR') : 'false').toBoolean()
Expand Down Expand Up @@ -70,6 +70,13 @@ ext {
stdlib: "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion",
],

// Required until Gradle uses Kotlin 1.4.
kotlin_gradle: [
gradle_plugin: "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72",
gradle_plugin_api: "org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.3.72",
stdlib: "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72",
],

kotlinpoet: "com.squareup:kotlinpoet:1.7.2",

truth: "com.google.truth:truth:1.0.1",
Expand Down
8 changes: 4 additions & 4 deletions gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
}

dependencies {
classpath deps.kotlin.gradle_plugin
classpath deps.kotlin_gradle.gradle_plugin
classpath deps.maven_publishing_plugin
classpath deps.gradle_publishing_plugin
classpath deps.ktlint_plugin
Expand Down Expand Up @@ -76,9 +76,9 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
}

dependencies {
implementation deps.kotlin.gradle_plugin
implementation deps.kotlin.gradle_plugin_api
implementation deps.kotlin.stdlib
implementation deps.kotlin_gradle.gradle_plugin
implementation deps.kotlin_gradle.gradle_plugin_api
implementation deps.kotlin_gradle.stdlib

// Compile only so that Java / Kotlin modules don't download it unnecessarily.
compileOnly deps.android_gradle_plugin
Expand Down
7 changes: 0 additions & 7 deletions sample/library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,3 @@ dependencies {
api deps.dagger2.dagger
api deps.kotlin.stdlib
}

//noinspection UnnecessaryQualifiedReference
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.squareup.scopes.ComponentHolder
import java.util.Locale

object Description {
@OptIn(ExperimentalStdlibApi::class)
fun of(god: God): String {
val name = god.name.toLowerCase(Locale.US)
.capitalize(Locale.US)
Expand All @@ -16,12 +15,8 @@ object Description {
MOTHER -> "daughter"
}

return "$name, $child of ${
ComponentHolder.component<DescriptionComponent>()
.fatherProvider()
.father(god)} and ${
ComponentHolder.component<DescriptionComponent>()
.motherProvider()
.mother(god)}"
return "$name, $child of " +
"${ComponentHolder.component<DescriptionComponent>().fatherProvider().father(god)} and " +
ComponentHolder.component<DescriptionComponent>().motherProvider().mother(god)
}
}

0 comments on commit 57c0e35

Please sign in to comment.