diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f4070000..e234f3f9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/annotations/build.gradle b/annotations/build.gradle index 6d11f738b..69d3ec57d 100644 --- a/annotations/build.gradle +++ b/annotations/build.gradle @@ -1,6 +1,2 @@ apply plugin: 'org.jetbrains.kotlin.jvm' -apply plugin: 'com.vanniktech.maven.publish' - -dependencies { - implementation deps.kotlin.stdlib -} \ No newline at end of file +apply plugin: 'com.vanniktech.maven.publish' \ No newline at end of file diff --git a/compiler/build.gradle b/compiler/build.gradle index 02a94f5f1..f88b620b7 100644 --- a/compiler/build.gradle +++ b/compiler/build.gradle @@ -8,7 +8,6 @@ dependencies { implementation project(':annotations') implementation deps.dagger2.dagger implementation deps.jsr250 - implementation deps.kotlin.stdlib implementation deps.kotlinpoet compileOnly deps.auto.service.annotations @@ -31,13 +30,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" } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/BindingModuleGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/BindingModuleGenerator.kt index df5b5f8c3..8f78810cc 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/BindingModuleGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/BindingModuleGenerator.kt @@ -145,7 +145,6 @@ internal class BindingModuleGenerator( .toList() } - @OptIn(ExperimentalStdlibApi::class) override fun flush( codeGenDir: File, module: ModuleDescriptor diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KotlinPoet.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KotlinPoet.kt index ecb7038df..6ac48203f 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KotlinPoet.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KotlinPoet.kt @@ -249,21 +249,11 @@ internal fun TypeName.withJvmSuppressWildcardsIfNeed return when { hasJvmSuppressWildcards || isGenericType -> this.jvmSuppressWildcards() - isFunctionType -> this.jvmSuppressWildcardsKt31734() + isFunctionType -> this.jvmSuppressWildcards() else -> this } } -// TODO: remove with Kotlin 1.4. -// Notice the empty member. Instead of generating `@JvmSuppressWildcards Type` it generates -// `@JvmSuppressWildcards() Type`. This is necessary to avoid KT-31734 where the type is a function. -private fun TypeName.jvmSuppressWildcardsKt31734() = - copy( - annotations = this.annotations + AnnotationSpec.builder(JvmSuppressWildcards::class) - .addMember("") - .build() - ) - internal fun List.asArgumentList( asProvider: Boolean, includeModule: Boolean diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt index 7d9bdf433..5c0070186 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt @@ -50,7 +50,6 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() { } } - @OptIn(ExperimentalStdlibApi::class) private fun generateFactoryClass( codeGenDir: File, module: ModuleDescriptor, @@ -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 diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt index a4d5e6fb9..b07b5d3db 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt @@ -61,7 +61,6 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() { } } - @OptIn(ExperimentalStdlibApi::class) private fun generateMembersInjectorClass( codeGenDir: File, module: ModuleDescriptor, diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt index 5a91c36c2..7c86c7387 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt @@ -90,7 +90,6 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { } } - @OptIn(ExperimentalStdlibApi::class) private fun generateFactoryClass( codeGenDir: File, module: ModuleDescriptor, diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt b/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt index 946a966df..0d4c48cf0 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt @@ -116,14 +116,12 @@ 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) } @@ -131,14 +129,12 @@ internal val Class<*>.hintContributesScope: KClass<*>? ?.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) } @@ -146,7 +142,6 @@ internal val Class<*>.hintBindingScope: KClass<*>? ?.also { assertThat(it.size).isEqualTo(1) } ?.first() -@OptIn(ExperimentalStdlibApi::class) internal fun Class<*>.moduleFactoryClass( providerMethodName: String, companion: Boolean = false @@ -160,14 +155,12 @@ 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}_" } ?: "" @@ -175,7 +168,6 @@ internal fun Class<*>.membersInjector(): Class<*> { "$enclosingClassString${simpleName}_MembersInjector") } -@OptIn(ExperimentalStdlibApi::class) private fun Class<*>.contributedProperties(packagePrefix: String): List>? { // 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? diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MembersInjectorGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MembersInjectorGeneratorTest.kt index 8c89b9eaa..ef0ea2cea 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MembersInjectorGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MembersInjectorGeneratorTest.kt @@ -166,6 +166,7 @@ public final class InjectClass_MembersInjector implements MembersInjector { "b" }, Provider { listOf("c") }, @@ -675,7 +676,6 @@ public final class InjectClass_MembersInjector 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. diff --git a/dependencies.gradle b/dependencies.gradle index c1047b4db..e9f385219 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -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() @@ -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", diff --git a/gradle-plugin/build.gradle b/gradle-plugin/build.gradle index aa878ac15..d57ef769a 100644 --- a/gradle-plugin/build.gradle +++ b/gradle-plugin/build.gradle @@ -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 @@ -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 diff --git a/gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/gradle-plugin/gradle/wrapper/gradle-wrapper.properties index 33682bbbf..4d9ca1649 100644 --- a/gradle-plugin/gradle/wrapper/gradle-wrapper.properties +++ b/gradle-plugin/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 33682bbbf..4d9ca1649 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/integration-tests/library/build.gradle b/integration-tests/library/build.gradle index f779b75ed..87f5f6b46 100644 --- a/integration-tests/library/build.gradle +++ b/integration-tests/library/build.gradle @@ -15,7 +15,6 @@ if (rootProject.ext.generateDaggerFactoriesWithAnvil) { dependencies { api deps.dagger2.dagger - api deps.kotlin.stdlib } //noinspection UnnecessaryQualifiedReference diff --git a/integration-tests/tests/build.gradle b/integration-tests/tests/build.gradle index 073818e66..7d78c65ee 100644 --- a/integration-tests/tests/build.gradle +++ b/integration-tests/tests/build.gradle @@ -8,7 +8,6 @@ dependencies { testImplementation project(':integration-tests:library') testImplementation deps.dagger2.dagger testImplementation deps.junit - testImplementation deps.kotlin.stdlib testImplementation deps.truth kaptTest deps.dagger2.compiler diff --git a/sample/app/build.gradle b/sample/app/build.gradle index 43f5478d7..3e5c6e529 100644 --- a/sample/app/build.gradle +++ b/sample/app/build.gradle @@ -39,7 +39,6 @@ dependencies { implementation project(':sample:library') implementation project(':sample:scopes') - implementation deps.kotlin.stdlib implementation deps.androidx.appcompat implementation deps.androidx.core implementation deps.androidx.material diff --git a/sample/library/build.gradle b/sample/library/build.gradle index 014f4477f..51da41db5 100644 --- a/sample/library/build.gradle +++ b/sample/library/build.gradle @@ -16,12 +16,4 @@ if (rootProject.ext.generateDaggerFactoriesWithAnvil) { dependencies { api project(':sample:scopes') 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" - } } diff --git a/sample/library/src/main/java/com/squareup/anvil/sample/Description.kt b/sample/library/src/main/java/com/squareup/anvil/sample/Description.kt index a20e1fef7..749528caa 100644 --- a/sample/library/src/main/java/com/squareup/anvil/sample/Description.kt +++ b/sample/library/src/main/java/com/squareup/anvil/sample/Description.kt @@ -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) @@ -16,12 +15,8 @@ object Description { MOTHER -> "daughter" } - return "$name, $child of ${ - ComponentHolder.component() - .fatherProvider() - .father(god)} and ${ - ComponentHolder.component() - .motherProvider() - .mother(god)}" + return "$name, $child of " + + "${ComponentHolder.component().fatherProvider().father(god)} and " + + ComponentHolder.component().motherProvider().mother(god) } } diff --git a/sample/scopes/build.gradle b/sample/scopes/build.gradle index 62ab6e9b3..d32997f6c 100644 --- a/sample/scopes/build.gradle +++ b/sample/scopes/build.gradle @@ -1,6 +1,5 @@ apply plugin: 'org.jetbrains.kotlin.jvm' dependencies { - api deps.kotlin.stdlib api deps.inject } \ No newline at end of file