diff --git a/arrow-annotations/build.gradle b/arrow-annotations/build.gradle index 2a13bcb43..5923ee60d 100644 --- a/arrow-annotations/build.gradle +++ b/arrow-annotations/build.gradle @@ -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" } diff --git a/arrow-core-data/build.gradle b/arrow-core-data/build.gradle index 2e1010070..bd20d6457 100644 --- a/arrow-core-data/build.gradle +++ b/arrow-core-data/build.gradle @@ -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" } diff --git a/arrow-core-retrofit/build.gradle b/arrow-core-retrofit/build.gradle index 8c5c267d5..34e1da380 100644 --- a/arrow-core-retrofit/build.gradle +++ b/arrow-core-retrofit/build.gradle @@ -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" } diff --git a/arrow-core-test/build.gradle b/arrow-core-test/build.gradle index 71ddfc2a0..c05b52eec 100644 --- a/arrow-core-test/build.gradle +++ b/arrow-core-test/build.gradle @@ -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" diff --git a/arrow-core/build.gradle b/arrow-core/build.gradle index 2fe6f7086..874037fdd 100644 --- a/arrow-core/build.gradle +++ b/arrow-core/build.gradle @@ -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" } diff --git a/arrow-core/src/main/kotlin/arrow/core/extensions/tuple.kt b/arrow-core/src/main/kotlin/arrow/core/extensions/tuple.kt index 5282dadd1..e4c2d3151 100644 --- a/arrow-core/src/main/kotlin/arrow/core/extensions/tuple.kt +++ b/arrow-core/src/main/kotlin/arrow/core/extensions/tuple.kt @@ -91,7 +91,7 @@ interface Tuple2Monad : Monad>, Tuple2Applicative { override fun Tuple2Of.flatMap(f: (A) -> Tuple2Of) = fix().flatMap { f(it).fix() } - override tailrec fun tailRecM(a: A, f: (A) -> Tuple2Of>): Tuple2 { + override fun tailRecM(a: A, f: (A) -> Tuple2Of>): Tuple2 { val b = f(a).fix().b return when (b) { is Left -> tailRecM(b.a, f) diff --git a/arrow-meta/arrow-meta-test-models/build.gradle b/arrow-meta/arrow-meta-test-models/build.gradle index 3f4f59d79..5adf5052b 100644 --- a/arrow-meta/arrow-meta-test-models/build.gradle +++ b/arrow-meta/arrow-meta-test-models/build.gradle @@ -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") diff --git a/arrow-meta/build.gradle b/arrow-meta/build.gradle index 837af65fb..d8ec5dc09 100644 --- a/arrow-meta/build.gradle +++ b/arrow-meta/build.gradle @@ -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' } diff --git a/arrow-meta/src/main/java/arrow/common/utils/AbstractProcessor.kt b/arrow-meta/src/main/java/arrow/common/utils/AbstractProcessor.kt index 8287858fa..b0f4d8cd8 100644 --- a/arrow-meta/src/main/java/arrow/common/utils/AbstractProcessor.kt +++ b/arrow-meta/src/main/java/arrow/common/utils/AbstractProcessor.kt @@ -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? = @@ -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() @@ -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) @@ -120,7 +115,7 @@ abstract class AbstractProcessor : KotlinAbstractProcessor(), ProcessorUtils, Ko protected abstract fun onProcess(annotations: Set, 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('?', '_') diff --git a/arrow-meta/src/main/java/arrow/core/extensions/ExtensionProcessor.kt b/arrow-meta/src/main/java/arrow/core/extensions/ExtensionProcessor.kt index 94e0241fb..6d6bec288 100644 --- a/arrow-meta/src/main/java/arrow/core/extensions/ExtensionProcessor.kt +++ b/arrow-meta/src/main/java/arrow/core/extensions/ExtensionProcessor.kt @@ -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 @@ -24,7 +23,7 @@ class ExtensionProcessor : MetaProcessor(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) } diff --git a/arrow-meta/src/main/java/arrow/meta/decoder/Decoder.kt b/arrow-meta/src/main/java/arrow/meta/decoder/Decoder.kt index c54a904dc..1fe2f2000 100644 --- a/arrow-meta/src/main/java/arrow/meta/decoder/Decoder.kt +++ b/arrow-meta/src/main/java/arrow/meta/decoder/Decoder.kt @@ -79,7 +79,7 @@ interface TypeDecoder : MetaDecoder { 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() @@ -203,7 +203,7 @@ interface TypeDecoder : MetaDecoder { 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)) diff --git a/arrow-meta/src/main/java/arrow/meta/encoder/jvm/TypeElementEncoder.kt b/arrow-meta/src/main/java/arrow/meta/encoder/jvm/TypeElementEncoder.kt index 30b1d26fc..1c3e509d3 100644 --- a/arrow-meta/src/main/java/arrow/meta/encoder/jvm/TypeElementEncoder.kt +++ b/arrow-meta/src/main/java/arrow/meta/encoder/jvm/TypeElementEncoder.kt @@ -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, @@ -156,8 +156,8 @@ interface TypeElementEncoder : KotlinMetatadataEncoder, KotlinPoetEncoder, Proce fun TypeElement.declaredFunctions(declaredElement: TypeElement): List { 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 } } } @@ -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 { @@ -386,7 +386,7 @@ interface TypeElementEncoder : KotlinMetatadataEncoder, KotlinPoetEncoder, Proce fun ExecutableElement.asConstructor(typeElement: TypeElement): Pair? = 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( diff --git a/arrow-meta/src/test/java/arrow/ap/tests/APTest.kt b/arrow-meta/src/test/java/arrow/ap/tests/APTest.kt index e73a6bfb1..dc2693f3c 100644 --- a/arrow-meta/src/test/java/arrow/ap/tests/APTest.kt +++ b/arrow-meta/src/test/java/arrow/ap/tests/APTest.kt @@ -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 @@ -17,7 +15,7 @@ abstract class APTest( fun testProcessor( vararg processor: AnnotationProcessor, - generationDir: File = Files.createTempDir(), + generationDir: File = createTempDir(), actualFileLocation: (File) -> String = { it.path } ) { @@ -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) diff --git a/arrow-syntax/build.gradle b/arrow-syntax/build.gradle index 889f8194f..69ce674aa 100644 --- a/arrow-syntax/build.gradle +++ b/arrow-syntax/build.gradle @@ -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") } diff --git a/build.gradle b/build.gradle index 83c36eb9f..80c424e55 100644 --- a/build.gradle +++ b/build.gradle @@ -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" diff --git a/gradle.properties b/gradle.properties index 9b33264e8..487e18915 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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