Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Upgrade to Kotlin 1.4.0 #231

Merged
merged 2 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion arrow-annotations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ apply from: "$SUB_PROJECT"
apply from: "$DOC_CREATION"

dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION"
api "io.kindedj:kindedj:$KINDEDJ_VERSION"
}
5 changes: 2 additions & 3 deletions arrow-core-data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ apply from: "$SUB_PROJECT"
apply from: "$DOC_CREATION"

dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
api project(":arrow-annotations")
kapt project(":arrow-meta")
kaptTest project(":arrow-meta")
compileOnly project(":arrow-meta")
testCompileOnly project(":arrow-meta")
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
testImplementation project(":arrow-core-test")
testCompileOnly project(":arrow-syntax")
testCompileOnly project(":arrow-core")
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
testImplementation project(":arrow-core-test")
testImplementation "io.arrow-kt:arrow-mtl-data:$VERSION_NAME"
}
5 changes: 2 additions & 3 deletions arrow-core-retrofit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ apply from: "$DOC_CREATION"

dependencies {
compileOnly project(":arrow-core-data")
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
compileOnly "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
testImplementation project(":arrow-core-test")
testCompileOnly "org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
testCompileOnly "io.kotlintest:kotlintest-runner-junit5:$KOTLIN_TEST_VERSION", excludeArrow
testImplementation project(":arrow-core-test")
testImplementation "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
testImplementation "com.squareup.okhttp3:mockwebserver:$MOCKWEBSERVER_VERSION"
}
1 change: 0 additions & 1 deletion arrow-core-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ apply from: "$SUB_PROJECT"
dependencies {
api project(":arrow-core")
api project(":arrow-core-data")
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLINX_COROUTINES_VERSION"
api "io.kotlintest:kotlintest-runner-junit5:$KOTLIN_TEST_VERSION", excludeArrow
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
Expand Down
3 changes: 1 addition & 2 deletions arrow-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ apply from: "$SUB_PROJECT"
apply from: "$DOC_CREATION"

dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
compileOnly project(":arrow-annotations")
api project(":arrow-core-data")
kapt project(":arrow-meta")
kaptTest project(":arrow-meta")
compileOnly project(":arrow-meta")
testCompileOnly project(":arrow-meta")
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
testCompileOnly project(":arrow-core-test")
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
}
2 changes: 1 addition & 1 deletion arrow-core/src/main/kotlin/arrow/core/extensions/tuple.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ interface Tuple2Monad<F> : Monad<Tuple2PartialOf<F>>, Tuple2Applicative<F> {
override fun <A, B> Tuple2Of<F, A>.flatMap(f: (A) -> Tuple2Of<F, B>) =
fix().flatMap { f(it).fix() }

override tailrec fun <A, B> tailRecM(a: A, f: (A) -> Tuple2Of<F, Either<A, B>>): Tuple2<F, B> {
override fun <A, B> tailRecM(a: A, f: (A) -> Tuple2Of<F, Either<A, B>>): Tuple2<F, B> {
val b = f(a).fix().b
return when (b) {
is Left -> tailRecM(b.a, f)
Expand Down
1 change: 0 additions & 1 deletion arrow-meta/arrow-meta-test-models/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {
apply from: "$DOC_CREATION"

dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION"
compileOnly "com.google.auto.service:auto-service:$GOOGLE_AUTO_SERVICE_VERSION"
kapt "com.google.auto.service:auto-service:$GOOGLE_AUTO_SERVICE_VERSION"
compileOnly project(":arrow-annotations")
Expand Down
3 changes: 1 addition & 2 deletions arrow-meta/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ apply from: "$SUB_PROJECT"
apply from: "$DOC_CREATION"

dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION"
api project(':arrow-annotations')
api "me.eugeniomarletti.kotlin.metadata:kotlin-metadata:$KOTLIN_METADATA_VERSION"
api "io.arrow-kt:kotlin-metadata:$KOTLIN_METADATA_VERSION"
api("com.squareup:kotlinpoet:$KOTLIN_POET_VERSION") {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect'
}
Expand Down
13 changes: 4 additions & 9 deletions arrow-meta/src/main/java/arrow/common/utils/AbstractProcessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class AbstractProcessor : KotlinAbstractProcessor(), ProcessorUtils, Ko
locationName()
.replacePackageSeparatorsToFolderSeparators()
.replaceInvalidPathCharacters()
.let { "$userDir/build/kdocs/meta/$it.javadoc" }
.let { "$tmpDir/build/kdocs/meta/$it.javadoc" }
.let(::File)

fun Element.kDoc(): String? =
Expand All @@ -50,8 +50,8 @@ abstract class AbstractProcessor : KotlinAbstractProcessor(), ProcessorUtils, Ko
private fun processElementDoc(e: Element) {
try {
val doc = elementUtils.getDocComment(e)
val kDocLocation = e.kDocLocation()
if (doc != null && doc.trim { it <= ' ' }.isNotEmpty()) {
val kDocLocation = e.kDocLocation()
@Suppress("SwallowedException")
try {
val path = kDocLocation.toPath()
Expand All @@ -62,12 +62,7 @@ abstract class AbstractProcessor : KotlinAbstractProcessor(), ProcessorUtils, Ko
}
@Suppress("SwallowedException")
try {
Files.delete(path)
} catch (e: IOException) {
}
@Suppress("SwallowedException")
try {
Files.createFile(path)
kDocLocation.createNewFile()
} catch (e: IOException) {
}
kDocLocation.writeText(doc)
Expand Down Expand Up @@ -120,7 +115,7 @@ abstract class AbstractProcessor : KotlinAbstractProcessor(), ProcessorUtils, Ko
protected abstract fun onProcess(annotations: Set<TypeElement>, roundEnv: RoundEnvironment)
}

private val userDir get() = System.getProperty("user.dir")
private val tmpDir get() = System.getProperty("java.io.tmpdir")
private fun String.replacePackageSeparatorsToFolderSeparators() = replace('.', '/')
private fun String.replaceInvalidPathCharacters() = replace('?', '_')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package arrow.core.extensions

import arrow.common.messager.log
import arrow.common.utils.knownError
import arrow.extension
import arrow.meta.ast.Code
Expand All @@ -24,7 +23,7 @@ class ExtensionProcessor : MetaProcessor<extension>(extension::class), PolyTempl
when (annotatedElement) {
is AnnotatedElement.Interface -> {
val info = annotatedElement.typeElement.typeClassInstance()
log("[${info?.instance?.name?.simpleName}] : Generating [${info?.typeClass?.name?.simpleName}] extensions for [${info?.projectedCompanion}]")
// log("[${info?.instance?.name?.simpleName}] : Generating [${info?.typeClass?.name?.simpleName}] extensions for [${info?.projectedCompanion}]")
val fileSpec = annotatedElement.fileSpecBuilder(info)
info.processTypeClassExtensions(fileSpec, annotatedElement)
}
Expand Down
4 changes: 2 additions & 2 deletions arrow-meta/src/main/java/arrow/meta/decoder/Decoder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ interface TypeDecoder : MetaDecoder<Type> {
val builder = ParameterSpec.builder(
name = name,
type = type.lyrics(),
modifiers = *modifiers.map { it.lyrics() }.toTypedArray()
modifiers = modifiers.map { it.lyrics() }.toTypedArray()
)
val builderDefaultValue = if (defaultValue != null) builder.defaultValue(defaultValue.lyrics()) else builder
return builderDefaultValue.build()
Expand Down Expand Up @@ -203,7 +203,7 @@ interface TypeDecoder : MetaDecoder<Type> {
fun TypeName.FunctionLiteral.lyrics(): com.squareup.kotlinpoet.TypeName =
LambdaTypeName.get(
receiver = receiverType?.lyrics(),
parameters = *parameters.map { it.lyrics() }.toTypedArray(),
parameters = parameters.map { it.lyrics() }.toTypedArray(),
returnType = returnType.lyrics()
).copy(suspending = modifiers.contains(Modifier.Suspend))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ interface TypeElementEncoder : KotlinMetatadataEncoder, KotlinPoetEncoder, Proce
val typeElement = this@type as TypeElement
val classBuilder = Type(PackageName(pckgName), asType().asTypeName().toMeta(), Type.Shape.Class)
val declaredConstructorSignatures = meta.constructorList.map { it.getJvmConstructorSignature(meta.nameResolver, meta.classProto.typeTable) }
val constructors = ElementFilter.constructorsIn(elementUtils.getAllMembers(this@type)).filter {
declaredConstructorSignatures.contains(it.jvmMethodSignature)
val constructors = ElementFilter.constructorsIn(elementUtils.getAllMembers(this@type)).filter { executableElement ->
declaredConstructorSignatures.any { it?.asString() == executableElement.jvmMethodSignature }
}.mapNotNull { it.asConstructor(this@type) }
Either.Right(classBuilder.copy(
primaryConstructor = constructors.find { it.first }?.second,
Expand Down Expand Up @@ -156,8 +156,8 @@ interface TypeElementEncoder : KotlinMetatadataEncoder, KotlinPoetEncoder, Proce

fun TypeElement.declaredFunctions(declaredElement: TypeElement): List<Func> {
val declaredFunctionSignatures = meta.functionList.map { it.getJvmMethodSignature(meta.nameResolver, meta.classProto.typeTable) }
return allFunctions(declaredElement).filter {
declaredFunctionSignatures.contains(it.jvmMethodSignature)
return allFunctions(declaredElement).filter { function ->
declaredFunctionSignatures.any { it?.asString() == function.jvmMethodSignature }
}
}

Expand Down Expand Up @@ -308,7 +308,7 @@ interface TypeElementEncoder : KotlinMetatadataEncoder, KotlinPoetEncoder, Proce
}
val members = filteredMembers.mapNotNull { member ->
val templateFunction = allFunctions.find { (proto, function) ->
function.getJvmMethodSignature(proto.nameResolver, proto.classProto.typeTable) == member.jvmMethodSignature
function.getJvmMethodSignature(proto.nameResolver, proto.classProto.typeTable)?.asString() == member.jvmMethodSignature
}
@Suppress("SwallowedException")
try {
Expand Down Expand Up @@ -386,7 +386,7 @@ interface TypeElementEncoder : KotlinMetatadataEncoder, KotlinPoetEncoder, Proce
fun ExecutableElement.asConstructor(typeElement: TypeElement): Pair<Boolean, Func>? =
kotlinMetadataUtils().run {
typeElement.meta.constructorList.find {
it.getJvmConstructorSignature(typeElement.meta.nameResolver, typeElement.meta.classProto.typeTable) == this@asConstructor.jvmMethodSignature
it.getJvmConstructorSignature(typeElement.meta.nameResolver, typeElement.meta.classProto.typeTable)?.asString() == this@asConstructor.jvmMethodSignature
}?.let { constructor ->
constructor.isPrimary to
Func(
Expand Down
6 changes: 2 additions & 4 deletions arrow-meta/src/test/java/arrow/ap/tests/APTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package arrow.ap.tests

import com.google.common.collect.ImmutableList
import com.google.common.io.Files
import com.google.testing.compile.CompilationSubject.assertThat
import com.google.testing.compile.Compiler.javac
import com.google.testing.compile.JavaFileObjects
Expand All @@ -17,7 +15,7 @@ abstract class APTest(

fun testProcessor(
vararg processor: AnnotationProcessor,
generationDir: File = Files.createTempDir(),
generationDir: File = createTempDir(),
actualFileLocation: (File) -> String = { it.path }
) {

Expand All @@ -40,7 +38,7 @@ abstract class APTest(

val compilation = javac()
.withProcessors(proc)
.withOptions(ImmutableList.of("-Akapt.kotlin.generated=$generationDir", "-proc:only"))
.withOptions(listOf("-Akapt.kotlin.generated=$generationDir", "-proc:only"))
.compile(sources.map {
val stub = File(stubs, it).toURI().toURL()
JavaFileObjects.forResource(stub)
Expand Down
2 changes: 1 addition & 1 deletion arrow-syntax/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ apply from: "$SUB_PROJECT"
apply from: "$DOC_CREATION"

dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
api project(":arrow-annotations")
api project(":arrow-core")
testCompileOnly "org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
testImplementation project(":arrow-core-test")
}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ configure(subprojects

animalsniffer { // Ingore tests
sourceSets = [sourceSets.main]
ignore 'java.lang.*'
}
dependencies {
compileOnly "org.codehaus.mojo:animal-sniffer-annotations:1.19"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ kapt.incremental.apt=true

# Versions just related to arrow-core
GOOGLE_AUTO_SERVICE_VERSION=1.0-rc7
GOOGLE_COMPILE_TESTING_VERSION=0.15
GOOGLE_COMPILE_TESTING_VERSION=0.18
KOTLIN_POET_VERSION=1.5.0