Skip to content

Commit

Permalink
Merge pull request #62 from lupuuss/release/2.6.0
Browse files Browse the repository at this point in the history
Release/2.6.0
  • Loading branch information
lupuuss authored Nov 28, 2024
2 parents 49749fd + 2428114 commit a4d1684
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 326 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</br>

[![Gradle Plugin Portal Stable](https://img.shields.io/gradle-plugin-portal/v/dev.mokkery)](https://plugins.gradle.org/plugin/dev.mokkery)
[![Kotlin](https://img.shields.io/badge/kotlin-2.0.21-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/kotlin-2.1.0-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![GitHub](https://img.shields.io/github/license/lupuuss/Mokkery)](https://github.com/lupuuss/Mokkery/blob/main/LICENSE)
[![Docs](https://img.shields.io/static/v1?label=api&message=reference&labelColor=gray&color=blueviolet&logo=gitbook&logoColor=white)](https://mokkery.dev/api_reference)

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ kotlin.code.style=official
kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning
kotlin.native.ignoreDisabledTargets=true
org.gradle.jvmargs=-Xmx3g
version=2.5.1-SNAPSHOT
version=2.6.0-SNAPSHOT
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
kotlin = "2.0.21"
kotlin = "2.1.0"
kotlinx-coroutines = "1.9.0"
buildconfig = "4.0.4"
google-autoservice = "1.0.1"
atomicfu = "0.26.0"
dokka = "2.0.0-Beta"
poko = "0.17.0"
poko = "0.17.2"
vanniktech-publish-plugin = "0.30.0"
objensis = "3.4"
bytebuddy = "1.14.19"
Expand Down
59 changes: 22 additions & 37 deletions kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,33 +87,12 @@
dependencies:
"@types/node" "*"

"@types/eslint-scope@^3.7.3":
version "3.7.4"
resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.4.tgz#37fc1223f0786c39627068a12e94d6e6fc61de16"
integrity sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA==
dependencies:
"@types/eslint" "*"
"@types/estree" "*"

"@types/eslint@*":
version "8.44.0"
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.44.0.tgz#55818eabb376e2272f77fbf5c96c43137c3c1e53"
integrity sha512-gsF+c/0XOguWgaOgvFs+xnnRqt9GwgTvIks36WpE6ueeI4KCEHHd8K/CKHqhOqrJKsYH8m27kRzQEvWXAwXUTw==
dependencies:
"@types/estree" "*"
"@types/json-schema" "*"

"@types/estree@*":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.1.tgz#aa22750962f3bf0e79d753d3cc067f010c95f194"
integrity sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==

"@types/estree@^1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4"
integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==

"@types/json-schema@*", "@types/json-schema@^7.0.8":
"@types/json-schema@^7.0.8":
version "7.0.12"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.12.tgz#d70faba7039d5fca54c83c7dbab41051d2b6f6cb"
integrity sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==
Expand Down Expand Up @@ -667,7 +646,7 @@ engine.io@~6.5.2:
engine.io-parser "~5.2.1"
ws "~8.11.0"

enhanced-resolve@^5.17.0:
enhanced-resolve@^5.17.1:
version "5.17.1"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz#67bfbbcc2f81d511be77d686a90267ef7f898a15"
integrity sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==
Expand Down Expand Up @@ -1113,10 +1092,10 @@ [email protected]:
minimatch "^9.0.3"
webpack-merge "^4.1.5"

[email protected].3:
version "6.4.3"
resolved "https://registry.yarnpkg.com/karma/-/karma-6.4.3.tgz#763e500f99597218bbb536de1a14acc4ceea7ce8"
integrity sha512-LuucC/RE92tJ8mlCwqEoRWXP38UMAqpnq98vktmS9SznSoUPPUJQbc91dHcxcunROvfQjdORVA/YFviH+Xci9Q==
[email protected].4:
version "6.4.4"
resolved "https://registry.yarnpkg.com/karma/-/karma-6.4.4.tgz#dfa5a426cf5a8b53b43cd54ef0d0d09742351492"
integrity sha512-LrtUxbdvt1gOpo3gxG+VAJlJAEMhbWlM4YrFQgql98FwF7+K8K12LYO4hnDdUkNjeztYrOXEMqgTajSWgmtI/w==
dependencies:
"@colors/colors" "1.5.0"
body-parser "^1.19.0"
Expand Down Expand Up @@ -1148,6 +1127,13 @@ kind-of@^6.0.2:
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/kotlin-web-helpers/-/kotlin-web-helpers-2.0.0.tgz#b112096b273c1e733e0b86560998235c09a19286"
integrity sha512-xkVGl60Ygn/zuLkDPx+oHj7jeLR7hCvoNF99nhwXMn8a3ApB4lLiC9pk4ol4NHPjyoCbvQctBqvzUcp8pkqyWw==
dependencies:
format-util "^1.0.5"

loader-runner@^4.2.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1"
Expand Down Expand Up @@ -1251,10 +1237,10 @@ mkdirp@^0.5.5:
dependencies:
minimist "^1.2.6"

[email protected].0:
version "10.7.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.0.tgz#9e5cbed8fa9b37537a25bd1f7fb4f6fc45458b9a"
integrity sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA==
[email protected].3:
version "10.7.3"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.3.tgz#ae32003cabbd52b59aece17846056a68eb4b0752"
integrity sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==
dependencies:
ansi-colors "^4.1.3"
browser-stdout "^1.3.1"
Expand Down Expand Up @@ -1843,12 +1829,11 @@ webpack-sources@^3.2.3:
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==

webpack@5.93.0:
version "5.93.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.93.0.tgz#2e89ec7035579bdfba9760d26c63ac5c3462a5e5"
integrity sha512-Y0m5oEY1LRuwly578VqluorkXbvXKh7U3rLoQCEO04M97ScRr44afGVkI0FQFsXzysk5OgFAxjZAb9rsGQVihA==
webpack@5.94.0:
version "5.94.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.94.0.tgz#77a6089c716e7ab90c1c67574a28da518a20970f"
integrity sha512-KcsGn50VT+06JH/iunZJedYGUJS5FGjow8wb9c0v5n1Om8O1g4L6LjtfxwlXIATopoQu+vOXXa7gYisWxCoPyg==
dependencies:
"@types/eslint-scope" "^3.7.3"
"@types/estree" "^1.0.5"
"@webassemblyjs/ast" "^1.12.1"
"@webassemblyjs/wasm-edit" "^1.12.1"
Expand All @@ -1857,7 +1842,7 @@ [email protected]:
acorn-import-attributes "^1.9.5"
browserslist "^4.21.10"
chrome-trace-event "^1.0.2"
enhanced-resolve "^5.17.0"
enhanced-resolve "^5.17.1"
es-module-lexer "^1.2.1"
eslint-scope "5.1.1"
events "^3.2.0"
Expand Down
2 changes: 1 addition & 1 deletion mokkery-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildConfig {
buildConfigField("String", "RUNTIME", str("mokkery-runtime"))
buildConfigField("String", "PLUGIN_ID", str(rootProject.ext["pluginId"]))
buildConfigField("String", "PLUGIN_ARTIFACT_ID", str(pluginProject.name))
buildConfigField("String", "MINIMUM_KOTLIN_VERSION", str("2.0.0"))
buildConfigField("String", "MINIMUM_KOTLIN_VERSION", str("2.1.0"))
buildConfigField("String", "COMPILED_KOTLIN_VERSION", str(libs.versions.kotlin.get()))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class MokkeryGradlePlugin : KotlinCompilerPluginSupportPlugin {
val currentKotlinVersion = kotlinToolingVersion.toKotlinVersion()
val minimumKotlinVersion = KotlinVersion(MokkeryConfig.MINIMUM_KOTLIN_VERSION)
if (currentKotlinVersion < minimumKotlinVersion) {
error("Current Kotlin version must be at least ${MokkeryConfig.MINIMUM_KOTLIN_VERSION}, but is $currentKotlinVersion!")
error("Current Kotlin version must be at least ${MokkeryConfig.MINIMUM_KOTLIN_VERSION}, but is $currentKotlinVersion! Downgrade Mokkery version or upgrade Kotlin version! Check https://mokkery.dev/docs/Setup#compatibility for compatibility guidelines!")
}
val compiledKotlinVersion = KotlinVersion(MokkeryConfig.COMPILED_KOTLIN_VERSION)
val versionWarnings = project.findProperty("dev.mokkery.versionWarnings")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@ package dev.mokkery.plugin

import dev.mokkery.MokkeryConfig
import dev.mokkery.plugin.ir.locationInFile
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.messageCollector
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.expressions.IrExpression

@Suppress("DEPRECATION")
val CompilerConfiguration.messageCollectorCompat: MessageCollector get() = try {
messageCollector
} catch (e: NoSuchMethodError) {
get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
}

internal inline fun MessageCollector.log(message: () -> String) {
report(CompilerMessageSeverity.LOGGING, "${MokkeryConfig.PLUGIN_ID}: ${message()}")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package dev.mokkery.plugin.core

import dev.mokkery.plugin.messageCollectorCompat
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
import org.jetbrains.kotlin.config.messageCollector
import org.jetbrains.kotlin.ir.builders.IrGeneratorContext
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.symbols.IrSymbol

val TransformerScope.messageCollector get() = compilerConfig.messageCollectorCompat
val TransformerScope.messageCollector get() = compilerConfig.messageCollector

fun TransformerScope.getClass(resolver: ClassResolver): IrClass = classes.getOrPut(resolver) {
resolver.resolve(pluginContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.fir.isPrimitiveType
import org.jetbrains.kotlin.fir.moduleData
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
import org.jetbrains.kotlin.fir.resolve.defaultType
import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
Expand All @@ -40,7 +41,6 @@ import org.jetbrains.kotlin.fir.types.ConeTypeParameterType
import org.jetbrains.kotlin.fir.types.FirTypeProjection
import org.jetbrains.kotlin.fir.types.isSomeFunctionType
import org.jetbrains.kotlin.fir.types.toConeTypeProjection
import org.jetbrains.kotlin.fir.types.toRegularClassSymbol
import org.jetbrains.kotlin.fir.types.type
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.isJs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.mokkery.plugin.diagnostics

import dev.mokkery.plugin.core.Mokkery.Errors
import dev.mokkery.plugin.fir.renderTypeCompat
import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap
import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory
import org.jetbrains.kotlin.diagnostics.rendering.CommonRenderers
Expand All @@ -11,7 +10,7 @@ import org.jetbrains.kotlin.fir.types.ConeKotlinType

class MokkeryDiagnosticRendererFactory : BaseDiagnosticRendererFactory() {

private val typeRenderer: DiagnosticParameterRenderer<ConeKotlinType> = FirDiagnosticRenderers.renderTypeCompat()
private val typeRenderer: DiagnosticParameterRenderer<ConeKotlinType> = FirDiagnosticRenderers.RENDER_TYPE

override val MAP = KtDiagnosticFactoryToRendererMap("MokkeryDiagnostic").apply {
put(
Expand Down
18 changes: 0 additions & 18 deletions mokkery-plugin/src/main/kotlin/dev/mokkery/plugin/fir/Utils.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
package dev.mokkery.plugin.fir

import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticParameterRenderer
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType


fun FirConstructorSymbol.isDefault() = valueParameterSymbols.isEmpty() || valueParameterSymbols.all { it.hasDefaultValue }

val FirRegularClassSymbol.constructors get() = declarationSymbols.filterIsInstance<FirConstructorSymbol>()

@Suppress("UNCHECKED_CAST")
fun FirDiagnosticRenderers.renderTypeCompat(): DiagnosticParameterRenderer<ConeKotlinType> = try {
RENDER_TYPE
} catch (e: NoSuchMethodError) {
FirDiagnosticRenderers::class
.java
.methods
.first { it.name == "getRENDER_TYPE" }
.invoke(this)
.let { it as DiagnosticParameterRenderer<ConeKotlinType> }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import dev.mokkery.plugin.core.IrMokkeryKind
import dev.mokkery.plugin.core.Kotlin
import dev.mokkery.plugin.core.Mokkery
import dev.mokkery.plugin.core.TransformerScope
import dev.mokkery.plugin.ir.compat.IrClassReferenceImplCompat
import dev.mokkery.plugin.ir.compat.IrFunctionExpressionImplCompat
import dev.mokkery.plugin.ir.compat.IrGetEnumValueImplCompat
import dev.mokkery.plugin.core.getClass
import dev.mokkery.plugin.core.getFunction
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
Expand Down Expand Up @@ -41,8 +38,11 @@ import org.jetbrains.kotlin.ir.expressions.IrFunctionExpression
import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
import org.jetbrains.kotlin.ir.expressions.IrSetField
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.IrWhen
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrIfThenElseImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionExpressionImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetEnumValueImpl
import org.jetbrains.kotlin.ir.expressions.putArgument
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
Expand All @@ -61,7 +61,7 @@ import org.jetbrains.kotlin.ir.util.primaryConstructor
import org.jetbrains.kotlin.name.Name

// use until resolved https://youtrack.jetbrains.com/issue/KT-66178/kClassReference-extension-returns-incorrect-IrClassReferenceImpl
fun IrBuilderWithScope.kClassReference(classType: IrType): IrClassReference = IrClassReferenceImplCompat(
fun IrBuilderWithScope.kClassReference(classType: IrType): IrClassReference = IrClassReferenceImpl(
startOffset = startOffset,
endOffset = endOffset,
type = context.irBuiltIns.kClassClass.starProjectedType,
Expand All @@ -72,7 +72,7 @@ fun IrBuilderWithScope.kClassReference(classType: IrType): IrClassReference = Ir
fun IrBuilderWithScope.irGetEnumEntry(
irClass: IrClass,
name: String
): IrGetEnumValue = IrGetEnumValueImplCompat(
): IrGetEnumValue = IrGetEnumValueImpl(
startOffset = startOffset,
endOffset = endOffset,
type = irClass.defaultType,
Expand Down Expand Up @@ -110,7 +110,7 @@ fun IrBlockBodyBuilder.irDelegatingDefaultConstructorOrAny(
}
}

fun IrBuilderWithScope.irIfNotNull(arg: IrExpression, then: IrExpression): IrIfThenElseImpl {
fun IrBuilderWithScope.irIfNotNull(arg: IrExpression, then: IrExpression): IrWhen {
return irIfThen(
condition = irNot(irEqualsNull(argument = arg)),
thenPart = then
Expand Down Expand Up @@ -141,20 +141,20 @@ fun IrBuilderWithScope.irLambda(
block(this@apply)
}
}
return IrFunctionExpressionImplCompat(
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
lambdaType,
lambda,
IrStatementOrigin.LAMBDA
return IrFunctionExpressionImpl(
startOffset = UNDEFINED_OFFSET,
endOffset = UNDEFINED_OFFSET,
type = lambdaType,
function = lambda,
origin = IrStatementOrigin.LAMBDA
)
}

fun IrBuilderWithScope.irInvokeIfNotNull(
function: IrExpression,
isSuspend: Boolean,
vararg args: IrExpression
): IrIfThenElseImpl {
): IrWhen {
return irIfNotNull(
function,
irInvoke(function, isSuspend, *args)
Expand Down Expand Up @@ -191,19 +191,19 @@ inline fun IrBuilderWithScope.irCall(
fun IrBuilderWithScope.irCall(
symbol: IrSimpleFunctionSymbol,
type: IrType = symbol.owner.returnType,
valueArgumentsCount: Int = symbol.owner.valueParameters.size,
typeArgumentsCount: Int = symbol.owner.typeParameters.size,
origin: IrStatementOrigin? = null,
superQualifierSymbol: IrClassSymbol? = null,
block: IrCall.() -> Unit = { }
): IrCall =
IrCallImpl(
startOffset, endOffset, type, symbol,
typeArgumentsCount = typeArgumentsCount,
valueArgumentsCount = valueArgumentsCount,
origin = origin,
superQualifierSymbol = superQualifierSymbol
).apply(block)
): IrCall = IrCallImpl(
startOffset = startOffset,
endOffset = endOffset,
type = type,
symbol = symbol,
typeArgumentsCount = typeArgumentsCount,
origin = origin,
superQualifierSymbol = superQualifierSymbol
).apply(block)

inline fun IrBuilderWithScope.irCallConstructor(
constructor: IrConstructor,
Expand Down
Loading

0 comments on commit a4d1684

Please sign in to comment.