From d372ad2629561935351831d642676f137e8bf4a7 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Sat, 29 Apr 2023 21:35:23 +0200 Subject: [PATCH] Update to 1.8.21 (#1071) --- build.gradle.kts | 13 +---- docs/build.gradle.kts | 10 ++++ gradle.properties | 2 +- gradle/projects.libs.versions.toml | 8 ++-- libs/arrow-meta/api/arrow-meta.api | 4 +- libs/arrow-meta/build.gradle.kts | 6 +++ .../src/main/kotlin/arrow/meta/Meta.kt | 3 +- .../arrow/meta/dsl/analysis/AnalysisSyntax.kt | 4 +- .../arrow/meta/dsl/config/ConfigSyntax.kt | 1 + .../arrow/meta/phases/analysis/KtUtils.kt | 14 +++--- .../arrow/meta/phases/codegen/ir/IrUtils.kt | 4 +- .../arrow/meta/ir/syntax/IrSyntaxTest.kt | 6 +-- libs/gradle-plugin-commons/build.gradle.kts | 10 ++++ .../plugin/gradle/ArrowMetaGradlePlugin.kt | 25 +++++++++- libs/meta-test/build.gradle.kts | 6 +++ .../plugin/testing/CompilationAssertions.kt | 4 +- .../meta/plugin/testing/CompilerTestDSL.kt | 2 - .../arrow/meta/plugin/testing/ExampleTest.kt | 47 +++++++++++++------ 18 files changed, 114 insertions(+), 55 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index dfe671c41..3aac3bb22 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,6 @@ import org.jetbrains.dokka.gradle.DokkaTask +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @Suppress("DSL_SCOPE_VIOLATION") plugins { @@ -96,14 +98,3 @@ configure(subprojects - project(":arrow-meta-docs")) { } } } - -val toolchain = project.extensions.getByType() -allprojects { - tasks.withType().configureEach { - javaCompiler.set(toolchain.compilerFor { - val jvmTargetVersion = properties["jvmTargetVersion"].toString() - val javaVersion = if (jvmTargetVersion == "1.8") "8" else jvmTargetVersion - languageVersion.set(JavaLanguageVersion.of(javaVersion)) - }) - } -} diff --git a/docs/build.gradle.kts b/docs/build.gradle.kts index be1bbc347..4efbfb472 100644 --- a/docs/build.gradle.kts +++ b/docs/build.gradle.kts @@ -11,6 +11,16 @@ plugins { alias(libs.plugins.arrowGradleConfig.kotlin) } +kotlin { + explicitApi = null + + val jvmTargetVersion = properties["jvmTargetVersion"].toString() + val javaVersion = if (jvmTargetVersion == "1.8") "8" else jvmTargetVersion + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(javaVersion)) + } +} + dependencies { runtimeOnly(libs.kotlin.stdlibJDK8) runtimeOnly(projects.arrowMeta) diff --git a/gradle.properties b/gradle.properties index f7b5d1202..7ff33e951 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ pom.smc.url=https://github.com/arrow-kt/arrow-meta/ pom.smc.connection=scm:git:git://github.com/arrow-kt/arrow-meta.git pom.smc.developerConnection=scm:git:ssh://git@github.com/arrow-kt/arrow-meta.git -jvmTargetVersion=1.8 +jvmTargetVersion=11 # Gradle options org.gradle.jvmargs=-Xmx4g diff --git a/gradle/projects.libs.versions.toml b/gradle/projects.libs.versions.toml index 31046a10c..940f715d4 100644 --- a/gradle/projects.libs.versions.toml +++ b/gradle/projects.libs.versions.toml @@ -1,18 +1,18 @@ [versions] -arrow = "1.1.5" -arrowGradleConfig = "0.11.0" +arrow = "1.2.0-RC" +arrowGradleConfig = "0.12.0-rc.3" assertj = "3.24.2" classgraph = "4.8.157" dokka = "1.8.10" intellijOpenApi = "7.0.3" javaAssist = "3.29.2-GA" junit = "5.9.2" -kotlin = "1.8.10" +kotlin = "1.8.21" kotlinCompileTesting = "1.5.0" javaCompileTesting = "0.21.0" kotlinBinaryCompatibilityValidator = "0.13.0" detekt = "1.22.0" -ksp = "1.8.10-1.0.9" +ksp = "1.8.21-1.0.11" [libraries] arrowCore = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" } diff --git a/libs/arrow-meta/api/arrow-meta.api b/libs/arrow-meta/api/arrow-meta.api index bce9e398d..fa19e2cba 100644 --- a/libs/arrow-meta/api/arrow-meta.api +++ b/libs/arrow-meta/api/arrow-meta.api @@ -729,13 +729,13 @@ public final class arrow/meta/phases/codegen/ir/IrUtils : org/jetbrains/kotlin/i public fun createExpressionBody (IILkotlin/jvm/functions/Function1;)Lorg/jetbrains/kotlin/ir/expressions/IrExpressionBody; public fun createExpressionBody (IILorg/jetbrains/kotlin/ir/expressions/IrExpression;)Lorg/jetbrains/kotlin/ir/expressions/IrExpressionBody; public fun createExpressionBody (Lorg/jetbrains/kotlin/ir/expressions/IrExpression;)Lorg/jetbrains/kotlin/ir/expressions/IrExpressionBody; - public fun createFakeOverrideFunction (IILorg/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin;Lorg/jetbrains/kotlin/name/Name;Lorg/jetbrains/kotlin/descriptors/DescriptorVisibility;Lorg/jetbrains/kotlin/descriptors/Modality;Lorg/jetbrains/kotlin/ir/types/IrType;ZZZZZZZ)Lorg/jetbrains/kotlin/ir/declarations/IrSimpleFunction; - public fun createFakeOverrideProperty (IILorg/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin;Lorg/jetbrains/kotlin/name/Name;Lorg/jetbrains/kotlin/descriptors/DescriptorVisibility;Lorg/jetbrains/kotlin/descriptors/Modality;ZZZZZZ)Lorg/jetbrains/kotlin/ir/declarations/IrProperty; public fun createField (IILorg/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin;Lorg/jetbrains/kotlin/ir/symbols/IrFieldSymbol;Lorg/jetbrains/kotlin/name/Name;Lorg/jetbrains/kotlin/ir/types/IrType;Lorg/jetbrains/kotlin/descriptors/DescriptorVisibility;ZZZ)Lorg/jetbrains/kotlin/ir/declarations/IrField; public fun createFlexibleType (Lorg/jetbrains/kotlin/types/model/SimpleTypeMarker;Lorg/jetbrains/kotlin/types/model/SimpleTypeMarker;)Lorg/jetbrains/kotlin/types/model/KotlinTypeMarker; public fun createFunction (IILorg/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin;Lorg/jetbrains/kotlin/ir/symbols/IrSimpleFunctionSymbol;Lorg/jetbrains/kotlin/name/Name;Lorg/jetbrains/kotlin/descriptors/DescriptorVisibility;Lorg/jetbrains/kotlin/descriptors/Modality;Lorg/jetbrains/kotlin/ir/types/IrType;ZZZZZZZZLorg/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedContainerSource;)Lorg/jetbrains/kotlin/ir/declarations/IrSimpleFunction; + public fun createFunctionWithLateBinding (IILorg/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin;Lorg/jetbrains/kotlin/name/Name;Lorg/jetbrains/kotlin/descriptors/DescriptorVisibility;Lorg/jetbrains/kotlin/descriptors/Modality;Lorg/jetbrains/kotlin/ir/types/IrType;ZZZZZZZ)Lorg/jetbrains/kotlin/ir/declarations/IrSimpleFunction; public fun createLocalDelegatedProperty (IILorg/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin;Lorg/jetbrains/kotlin/ir/symbols/IrLocalDelegatedPropertySymbol;Lorg/jetbrains/kotlin/name/Name;Lorg/jetbrains/kotlin/ir/types/IrType;Z)Lorg/jetbrains/kotlin/ir/declarations/IrLocalDelegatedProperty; public fun createProperty (IILorg/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin;Lorg/jetbrains/kotlin/ir/symbols/IrPropertySymbol;Lorg/jetbrains/kotlin/name/Name;Lorg/jetbrains/kotlin/descriptors/DescriptorVisibility;Lorg/jetbrains/kotlin/descriptors/Modality;ZZZZZZZLorg/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedContainerSource;)Lorg/jetbrains/kotlin/ir/declarations/IrProperty; + public fun createPropertyWithLateBinding (IILorg/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin;Lorg/jetbrains/kotlin/name/Name;Lorg/jetbrains/kotlin/descriptors/DescriptorVisibility;Lorg/jetbrains/kotlin/descriptors/Modality;ZZZZZZ)Lorg/jetbrains/kotlin/ir/declarations/IrProperty; public fun createSimpleType (Lorg/jetbrains/kotlin/types/model/TypeConstructorMarker;Ljava/util/List;ZZLjava/util/List;)Lorg/jetbrains/kotlin/types/model/SimpleTypeMarker; public fun createStarProjection (Lorg/jetbrains/kotlin/types/model/TypeParameterMarker;)Lorg/jetbrains/kotlin/ir/types/impl/IrStarProjectionImpl; public synthetic fun createStarProjection (Lorg/jetbrains/kotlin/types/model/TypeParameterMarker;)Lorg/jetbrains/kotlin/types/model/TypeArgumentMarker; diff --git a/libs/arrow-meta/build.gradle.kts b/libs/arrow-meta/build.gradle.kts index 77fe4a267..34ecffff6 100644 --- a/libs/arrow-meta/build.gradle.kts +++ b/libs/arrow-meta/build.gradle.kts @@ -10,6 +10,12 @@ plugins { kotlin { explicitApi = null + + val jvmTargetVersion = properties["jvmTargetVersion"].toString() + val javaVersion = if (jvmTargetVersion == "1.8") "8" else jvmTargetVersion + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(javaVersion)) + } } tasks.compileKotlin { diff --git a/libs/arrow-meta/src/main/kotlin/arrow/meta/Meta.kt b/libs/arrow-meta/src/main/kotlin/arrow/meta/Meta.kt index c6384fdc1..13cdfafd3 100644 --- a/libs/arrow-meta/src/main/kotlin/arrow/meta/Meta.kt +++ b/libs/arrow-meta/src/main/kotlin/arrow/meta/Meta.kt @@ -45,9 +45,11 @@ typealias CliPlugin = Plugin /** * Enables syntactic sugar for plugin creation via: "pluginId" { meta( + * * ``` * ..phases * ``` + * * ) } */ operator fun String.invoke(phases: CompilerContext.() -> List): CliPlugin = @@ -59,7 +61,6 @@ operator fun String.invoke(phases: CompilerContext.() -> List): * * Plugin authors are encouraged to define [CliPlugin] extensions by making them part of the [Meta] * receiver: - * * ```kotlin * val Meta.helloWorld: CliPlugin get() = * "Hello World" { diff --git a/libs/arrow-meta/src/main/kotlin/arrow/meta/dsl/analysis/AnalysisSyntax.kt b/libs/arrow-meta/src/main/kotlin/arrow/meta/dsl/analysis/AnalysisSyntax.kt index bd97f77d7..f478ff60b 100644 --- a/libs/arrow-meta/src/main/kotlin/arrow/meta/dsl/analysis/AnalysisSyntax.kt +++ b/libs/arrow-meta/src/main/kotlin/arrow/meta/dsl/analysis/AnalysisSyntax.kt @@ -26,8 +26,8 @@ import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppressio /** * The Analysis phase determines if the parsed AST type checks and resolves properly. As part of * this phase, we have access to events happening before and after resolution. Before resolution, we - * are given the chance to modify the compiler trees in the form of `KtElement` via the [Quote - * Template System]. + * are given the chance to modify the compiler trees in the form of `KtElement` via the + * [Quote Template System]. */ interface AnalysisSyntax { diff --git a/libs/arrow-meta/src/main/kotlin/arrow/meta/dsl/config/ConfigSyntax.kt b/libs/arrow-meta/src/main/kotlin/arrow/meta/dsl/config/ConfigSyntax.kt index cc3a14d93..b48fe70b9 100644 --- a/libs/arrow-meta/src/main/kotlin/arrow/meta/dsl/config/ConfigSyntax.kt +++ b/libs/arrow-meta/src/main/kotlin/arrow/meta/dsl/config/ConfigSyntax.kt @@ -30,6 +30,7 @@ interface ConfigSyntax { * * @updateConfiguration enables a DSL using [CompilerContext], and it can update * [CompilerConfiguration] through its mutable API. + * * @return [Config] [ExtensionPhase]. */ fun updateConfig( diff --git a/libs/arrow-meta/src/main/kotlin/arrow/meta/phases/analysis/KtUtils.kt b/libs/arrow-meta/src/main/kotlin/arrow/meta/phases/analysis/KtUtils.kt index 8d91d1130..cc7ecf23f 100644 --- a/libs/arrow-meta/src/main/kotlin/arrow/meta/phases/analysis/KtUtils.kt +++ b/libs/arrow-meta/src/main/kotlin/arrow/meta/phases/analysis/KtUtils.kt @@ -29,7 +29,6 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.TypeProjection -import org.jetbrains.kotlin.utils.addToStdlib.safeAs fun KtDeclarationWithBody.body(): KtExpression? = bodyExpression ?: bodyBlockExpression @@ -146,9 +145,10 @@ fun resolveFunctionTypeEq(): Eq = Eq { t1, t2 -> * intersect(typeConstructorEq(), types).isNotEmpty() * //sampleEnd * ``` - * @see [org.jetbrains.kotlin.types.TypeUtils] for more abstractions + * * @param eq can be define for e.g.: [TypeConstructor], [MemberScope] or typeArguments List< - * [TypeProjection]>, etc. + * [TypeProjection]>, etc. + * @see [org.jetbrains.kotlin.types.TypeUtils] for more abstractions * @see functionTypeEq */ fun C.intersect( @@ -163,8 +163,9 @@ fun C.intersect( /** * given [eq] this function returns a List of [KotlinType] that are contained by both [list] and * [other] + * * @param eq can be defined for [TypeConstructor], [MemberScope] or typeArguments List< - * [TypeProjection]>, etc. + * [TypeProjection]>, etc. * @see intersect */ fun D.intersect( @@ -191,9 +192,8 @@ fun KtAnnotated.isAnnotatedWith(regex: Regex): Boolean = val KtClass.companionObject: KtObjectDeclaration? get() = - declarations - .singleOrNull { it.safeAs()?.isCompanion() == true } - .safeAs() + declarations.singleOrNull { (it as? KtObjectDeclaration)?.isCompanion() == true } + as? KtObjectDeclaration fun DeclarationDescriptor.skipGeneration(): Boolean = platform != CommonPlatforms.defaultCommonPlatform && diff --git a/libs/arrow-meta/src/main/kotlin/arrow/meta/phases/codegen/ir/IrUtils.kt b/libs/arrow-meta/src/main/kotlin/arrow/meta/phases/codegen/ir/IrUtils.kt index ba1e34fa5..6d3297ddd 100644 --- a/libs/arrow-meta/src/main/kotlin/arrow/meta/phases/codegen/ir/IrUtils.kt +++ b/libs/arrow-meta/src/main/kotlin/arrow/meta/phases/codegen/ir/IrUtils.kt @@ -48,7 +48,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstituto import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject import org.jetbrains.kotlin.resolve.descriptorUtil.classId import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.utils.addToStdlib.safeAs class IrUtils( val pluginContext: IrPluginContext, @@ -227,8 +226,7 @@ fun IrMemberAccessExpression<*>.getTypeSubstitutionMap( container.allTypeParameters.withIndex().associate { it.value to getTypeArgument(it.index)!! } val IrMemberAccessExpression<*>.typeSubstitutions: Map - get() = - symbol.owner.safeAs()?.let(::getTypeSubstitutionMap) ?: emptyMap() + get() = (symbol.owner as? IrTypeParametersContainer)?.let(::getTypeSubstitutionMap) ?: emptyMap() /** returns a Pair of the descriptor and it's substituted KotlinType at the call-site */ private fun IrSimpleFunction.substitutedValueParameters( diff --git a/libs/arrow-meta/src/test/kotlin/arrow/meta/ir/syntax/IrSyntaxTest.kt b/libs/arrow-meta/src/test/kotlin/arrow/meta/ir/syntax/IrSyntaxTest.kt index 46cdd8864..d7256dc2b 100644 --- a/libs/arrow-meta/src/test/kotlin/arrow/meta/ir/syntax/IrSyntaxTest.kt +++ b/libs/arrow-meta/src/test/kotlin/arrow/meta/ir/syntax/IrSyntaxTest.kt @@ -137,7 +137,7 @@ class IrSyntaxTest { // TODO: IrErrorDeclaration::class.java, // TODO: IrErrorExpression::class.java, // TODO: IrErrorCallExpression::class.java - ), + ), """ package test @@ -192,8 +192,8 @@ class IrSyntaxTest { 9 - 6 } } - """.trimIndent( - ) + """ + .trimIndent() ) } } diff --git a/libs/gradle-plugin-commons/build.gradle.kts b/libs/gradle-plugin-commons/build.gradle.kts index 89660593d..cf0771d37 100644 --- a/libs/gradle-plugin-commons/build.gradle.kts +++ b/libs/gradle-plugin-commons/build.gradle.kts @@ -16,6 +16,16 @@ tasks.processResources { } } +kotlin { + explicitApi = null + + val jvmTargetVersion = properties["jvmTargetVersion"].toString() + val javaVersion = if (jvmTargetVersion == "1.8") "8" else jvmTargetVersion + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(javaVersion)) + } +} + dependencies { compileOnly(gradleApi()) compileOnly(libs.kotlin.stdlibJDK8) diff --git a/libs/gradle-plugin-commons/src/main/kotlin/arrow/meta/plugin/gradle/ArrowMetaGradlePlugin.kt b/libs/gradle-plugin-commons/src/main/kotlin/arrow/meta/plugin/gradle/ArrowMetaGradlePlugin.kt index 7c5e2c7a3..c2bc441f1 100644 --- a/libs/gradle-plugin-commons/src/main/kotlin/arrow/meta/plugin/gradle/ArrowMetaGradlePlugin.kt +++ b/libs/gradle-plugin-commons/src/main/kotlin/arrow/meta/plugin/gradle/ArrowMetaGradlePlugin.kt @@ -2,8 +2,8 @@ package arrow.meta.plugin.gradle import io.github.classgraph.ClassGraph import java.io.File -import java.lang.module.ModuleDescriptor.Version import java.util.Properties +import kotlin.math.max import org.gradle.api.InvalidUserDataException import org.gradle.api.Project import org.gradle.api.provider.Provider @@ -124,4 +124,27 @@ public interface ArrowMetaGradlePlugin : KotlinCompilerPluginSupportPlugin { private companion object { private const val VERSION_KEY = "compilerPluginVersion" } + + private data class Version(val components: List) : Comparable { + override fun compareTo(other: Version): Int = + compareComponents(this.components, other.components) + + private fun compareComponents(x: List, y: List): Int { + val maxComponent = max(x.size, y.size) + for (i in 0 until maxComponent) { + val xComponent = x.getOrElse(i) { 0 } + val yComponent = y.getOrElse(i) { 0 } + if (xComponent != yComponent) return (xComponent - yComponent) + } + // if we get there, that means they're equal + return 0 + } + + companion object { + fun parse(version: String): Version? { + val elements = version.split('.', '-', '+').map { it.toIntOrNull() } + return if (elements.any { it == null }) null else Version(elements.filterNotNull()) + } + } + } } diff --git a/libs/meta-test/build.gradle.kts b/libs/meta-test/build.gradle.kts index 64d795d9f..271136692 100644 --- a/libs/meta-test/build.gradle.kts +++ b/libs/meta-test/build.gradle.kts @@ -10,6 +10,12 @@ plugins { kotlin { explicitApi = null + + val jvmTargetVersion = properties["jvmTargetVersion"].toString() + val javaVersion = if (jvmTargetVersion == "1.8") "8" else jvmTargetVersion + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(javaVersion)) + } } dependencies { diff --git a/libs/meta-test/src/main/kotlin/arrow/meta/plugin/testing/CompilationAssertions.kt b/libs/meta-test/src/main/kotlin/arrow/meta/plugin/testing/CompilationAssertions.kt index 047c4364e..8dadd2d5e 100644 --- a/libs/meta-test/src/main/kotlin/arrow/meta/plugin/testing/CompilationAssertions.kt +++ b/libs/meta-test/src/main/kotlin/arrow/meta/plugin/testing/CompilationAssertions.kt @@ -28,7 +28,6 @@ private const val VARIABLE = "[^(]+" * developed by [Thilo Schuchort](https://github.com/tschuchortdev). * * Main schema: - * * ``` * assertThis( * CompilerTest( @@ -43,7 +42,6 @@ private const val VARIABLE = "[^(]+" * (`code`). Then, the expected behavior (`assert`) will be checked. * * For instance: - * * ``` * assertThis( * CompilerTest( @@ -58,7 +56,7 @@ private const val VARIABLE = "[^(]+" * ``` * * @param compilerTest necessary data to run the compilation, source code to be compiled and - * expected behavior + * expected behavior * @see [CompilerTest] */ fun assertThis(compilerTest: CompilerTest): Unit = compilerTest.run(interpreter) diff --git a/libs/meta-test/src/main/kotlin/arrow/meta/plugin/testing/CompilerTestDSL.kt b/libs/meta-test/src/main/kotlin/arrow/meta/plugin/testing/CompilerTestDSL.kt index 0d66d903d..2ca8ac3fc 100644 --- a/libs/meta-test/src/main/kotlin/arrow/meta/plugin/testing/CompilerTestDSL.kt +++ b/libs/meta-test/src/main/kotlin/arrow/meta/plugin/testing/CompilerTestDSL.kt @@ -180,7 +180,6 @@ interface AssertSyntax { * property. * * For instance: - * * ``` * compilesWith { it.contains("Unsafe operation") } * ``` @@ -197,7 +196,6 @@ interface AssertSyntax { * checked by a provided function. * * For instance: - * * ``` * failsWith { it.contains("Expecting a top level declaration") } * ``` diff --git a/libs/meta-test/src/test/kotlin/arrow/meta/plugin/testing/ExampleTest.kt b/libs/meta-test/src/test/kotlin/arrow/meta/plugin/testing/ExampleTest.kt index 251e39292..0eef89d42 100755 --- a/libs/meta-test/src/test/kotlin/arrow/meta/plugin/testing/ExampleTest.kt +++ b/libs/meta-test/src/test/kotlin/arrow/meta/plugin/testing/ExampleTest.kt @@ -16,7 +16,8 @@ class ExampleTest { | fun hello(): String = | "Hello world!" | - """.source + """ + .source }, assert = { compiles } ) @@ -32,7 +33,8 @@ class ExampleTest { | fun hello(): String = | "Hello world!" | - """.source + """ + .source }, assert = { "hello()".source.evalsTo("Hello world!") } ) @@ -50,7 +52,8 @@ class ExampleTest { | fun hello(): String = | "Hello world!" | - """.source + """ + .source }, assert = { "hello()".source.evalsTo("Hello world!") } ) @@ -61,10 +64,13 @@ class ExampleTest { fun `check that fails`() { assertThis( CompilerTest( - code = { """ + code = { + """ | classsss Error | - """.source }, + """ + .source + }, assert = { fails } ) ) @@ -74,10 +80,13 @@ class ExampleTest { fun `check that emits an error diagnostic when compilation fails`() { assertThis( CompilerTest( - code = { """ + code = { + """ | classsss Error | - """.source }, + """ + .source + }, assert = { failsWith { it.contains("Expecting a top level declaration") } } ) ) @@ -92,7 +101,8 @@ class ExampleTest { | | val x: String = "Hello world!" | - """.source + """ + .source }, assert = { "x".source.evalsTo("Hello world!") } ) @@ -109,7 +119,8 @@ class ExampleTest { | | val x: String = "Hello world!" | - """.source + """ + .source }, assert = { "x".source.evalsTo("Hello world!") } ) @@ -162,12 +173,14 @@ class ExampleTest { | | val x: String = "hello world!" | - """.source, + """ + .source, """ | | val y: String = "HELLO WORLD!" | - """.source + """ + .source ) }, assert = { compiles } @@ -185,7 +198,8 @@ class ExampleTest { | | fun helloWorld(): String = "Hello World!" | - """.source + """ + .source }, assert = { compiles } ) @@ -213,7 +227,8 @@ class ExampleTest { | | fun helloWorld(): String = "Hello World!" | - """.source + """ + .source }, assert = { compiles } ) @@ -230,7 +245,8 @@ class ExampleTest { | | fun helloWorld(): String = "Hello World!" | - """.source + """ + .source }, assert = { failsWith { @@ -258,7 +274,8 @@ class ExampleTest { | | fun helloWorld(): String = "Hello World!" | - """.source + """ + .source }, assert = { failsWith {