Skip to content

Commit

Permalink
Bump Kotlin to 1.4.20 (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
raniejade authored Nov 26, 2020
1 parent ae4278f commit c3dff76
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allprojects {
tasks.withType<KotlinCompile<*>> {
if (this is KotlinJvmCompile) {
kotlinOptions {
apiVersion = "1.3"
apiVersion = "1.4"
jvmTarget = "1.8"
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ repositories {
}

dependencies {
api(kotlin("gradle-plugin", version = "1.4.0"))
api(kotlin("gradle-plugin", version = "1.4.20"))
api("org.jetbrains.dokka:dokka-gradle-plugin:1.4.0-rc")
api("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4")
api("gradle.plugin.org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.4.21")
api("com.github.jengelman.gradle.plugins:shadow:4.0.2")
implementation(kotlin("reflect", version = "1.4.0"))
implementation(kotlin("reflect", version = "1.4.20"))
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object Dependencies {
val mockitoCore = "org.mockito:mockito-core:2.23.4"
val mockitoInline = "org.mockito:mockito-inline:2.23.4"

val kotlinCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
val kotlinCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1"

val autoService = "com.google.auto.service:auto-service:1.0-rc4"
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This causes problems with composite builds!
#kotlin.mpp.enableGranularSourceSetsMetadata=false
#kotlin.mpp.enableGranularSourceSetsMetadata=true
#kotlin.native.enableDependencyPropagation=false
org.gradle.jvmargs=-Xmx3G
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions integration-test/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ repositories {
}

dependencies {
implementation(kotlin("gradle-plugin", version = "1.4.0"))
implementation(kotlin("reflect", version = "1.4.0"))
implementation(kotlin("gradle-plugin", version = "1.4.20"))
implementation(kotlin("reflect", version = "1.4.20"))
}
3 changes: 2 additions & 1 deletion integration-test/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This causes problems with composite builds!
#kotlin.mpp.enableGranularSourceSetsMetadata=false
#kotlin.mpp.enableGranularSourceSetsMetadata=true
#kotlin.native.enableDependencyPropagation=false
org.gradle.jvmargs=-Xmx3G
Binary file modified integration-test/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion integration-test/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions integration-test/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
1 change: 1 addition & 0 deletions integration-test/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

Expand Down
1 change: 0 additions & 1 deletion spek-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ gradlePlugin {
val autoService = "com.google.auto.service:auto-service:1.0-rc4"

dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("gradle-plugin"))
implementation(kotlin("gradle-plugin-api"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package org.spekframework.spek2.kotlin
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedName
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.backend.common.ir.addChild
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies
import org.jetbrains.kotlin.backend.common.serialization.knownBuiltins
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.builders.declarations.addField
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
import org.jetbrains.kotlin.ir.descriptors.WrappedFieldDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
import org.jetbrains.kotlin.ir.expressions.IrBlock
import org.jetbrains.kotlin.ir.expressions.IrExpression
Expand All @@ -21,6 +21,8 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.getClass
Expand Down Expand Up @@ -132,7 +134,7 @@ private class SpekCollector(
IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA,
IrSimpleFunctionSymbolImpl(descriptor),
Name.special("<anonymous>"),
Visibilities.LOCAL,
DescriptorVisibilities.LOCAL,
Modality.FINAL,
declaration.defaultType,
isInline = false,
Expand All @@ -141,7 +143,8 @@ private class SpekCollector(
isSuspend = false,
isExpect = false,
isOperator = false,
isFakeOverride = false
isFakeOverride = false,
isInfix = false,
).apply {
descriptor.bind(this)
parent = this@SpekCollector.file
Expand All @@ -168,22 +171,29 @@ private var topLevelInitializersCounter = 0
// 2. creates a property using the previously declared field as its backing field
// Previously a top level field would cause the object to created but now it requires a property
private fun IrFile.addTopLevelInitializer(expression: IrExpression, pluginContext: IrPluginContext) {
val threadLocalAnnotation = pluginContext.builtIns.builtInsModule.findClassAcrossModuleDependencies(
val threadLocalAnnotation = pluginContext.irBuiltIns.builtIns.builtInsModule.findClassAcrossModuleDependencies(
ClassId.topLevel(FqName("kotlin.native.concurrent.ThreadLocal")))!!
val t = pluginContext.symbols.externalSymbolTable.referenceClass(threadLocalAnnotation)
val fieldName = "topLevelInitializer${topLevelInitializersCounter++}".synthesizedName

addField {
name = fieldName
isFinal = true
isStatic = true
visibility = Visibilities.PRIVATE
type = expression.type
origin = IrDeclarationOrigin.PROPERTY_BACKING_FIELD
}.also { field ->
field.parent = this@addTopLevelInitializer
field.initializer = IrExpressionBodyImpl(startOffset, endOffset, expression)
field.annotations += DeclarationIrBuilder(pluginContext, field.symbol, startOffset, endOffset).irCallConstructor(t.constructors.first(), emptyList())
val descriptor = WrappedFieldDescriptor()
pluginContext.irFactory.createField(
startOffset,
endOffset,
IrDeclarationOrigin.PROPERTY_BACKING_FIELD,
IrFieldSymbolImpl(descriptor),
fieldName,
expression.type,
DescriptorVisibilities.PRIVATE,
true,
false,
true
).apply {
addChild(this)
descriptor.bind(this)
parent = this@addTopLevelInitializer
initializer = IrExpressionBodyImpl(startOffset, endOffset, expression)
annotations += DeclarationIrBuilder(pluginContext, this.symbol, startOffset, endOffset).irCallConstructor(t.constructors.first(), emptyList())
}

// Don't need a property anymore for a field to be initialized (in 1.4), previously this was needed.
Expand Down

0 comments on commit c3dff76

Please sign in to comment.