Skip to content

Commit e28287c

Browse files
nikitavlaevjbilgonmicnikpachooJSMonkdkrasnoff
authored
Updated Kotlin to 2.1.20 (#798)
* KTL-1794 chore: 2.1.20-Beta1 * KTL-2024 chore: 2.1.20-Beta2 * fix: remove usage of JsConfig and use newly introduced extension property for getting the compiled module name * KTL-2157: Updated Kotlin version to 2.1.20-RC * KTL-2178: Updated Kotlin version to 2.1.20-RC2 * KTL-2234: Updated Kotlin version to 2.1.20-RC3 * KTL-2179: Updated Kotlin to 2.1.20 --------- Co-authored-by: Ilya Goncharov <[email protected]> Co-authored-by: nikpachoo <[email protected]> Co-authored-by: Artem Kobzar <[email protected]> Co-authored-by: Dmitrii Krasnov <[email protected]>
1 parent ea1a664 commit e28287c

23 files changed

+27
-43
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
kotlin = "2.1.10"
2+
kotlin = "2.1.20"
33
kotlinIdeVersion = "1.9.20-506"
44
kotlinIdeVersionWithSuffix = "231-1.9.20-506-IJ8109.175"
55
spring-boot = "2.7.10"

src/main/kotlin/com/compiler/server/compiler/components/ErrorAnalyzer.kt

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
1717
import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
1818
import org.jetbrains.kotlin.config.CompilerConfiguration
1919
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
20+
import org.jetbrains.kotlin.config.moduleName
2021
import org.jetbrains.kotlin.container.*
2122
import org.jetbrains.kotlin.context.ContextForNewModule
2223
import org.jetbrains.kotlin.context.ModuleContext
@@ -32,7 +33,6 @@ import org.jetbrains.kotlin.incremental.components.InlineConstTracker
3233
import org.jetbrains.kotlin.incremental.components.LookupTracker
3334
import org.jetbrains.kotlin.ir.backend.js.MainModule
3435
import org.jetbrains.kotlin.ir.backend.js.ModulesStructure
35-
import org.jetbrains.kotlin.js.config.JsConfig
3636
import org.jetbrains.kotlin.js.resolve.JsPlatformAnalyzerServices
3737
import org.jetbrains.kotlin.name.Name
3838
import org.jetbrains.kotlin.platform.TargetPlatform
@@ -114,14 +114,6 @@ class ErrorAnalyzer(
114114

115115
fun analyzeFileForJs(files: List<KtFile>, coreEnvironment: KotlinCoreEnvironment): Analysis {
116116
val project = coreEnvironment.project
117-
val configuration = JsConfig(
118-
project,
119-
kotlinEnvironment.jsConfiguration,
120-
CompilerEnvironment,
121-
kotlinEnvironment.JS_METADATA_CACHE,
122-
kotlinEnvironment.JS_LIBRARIES.toSet()
123-
)
124-
125117
val mainModule = MainModule.SourceFiles(files)
126118
val sourceModule = ModulesStructure(
127119
project,
@@ -152,7 +144,7 @@ class ErrorAnalyzer(
152144

153145
val context = ContextForNewModule(
154146
projectContext = ProjectContext(project, "COMPILER-SERVER-JS"),
155-
moduleName = Name.special("<" + configuration.moduleId + ">"),
147+
moduleName = Name.special("<" + kotlinEnvironment.jsConfiguration.moduleName + ">"),
156148
builtIns = JsPlatformAnalyzerServices.builtIns, platform = null
157149
)
158150
val dependencies = mutableSetOf(context.module) + mds + JsPlatformAnalyzerServices.builtIns.builtInsModule
@@ -199,14 +191,6 @@ class ErrorAnalyzer(
199191
coreEnvironment: KotlinCoreEnvironment
200192
): Analysis {
201193
val project = coreEnvironment.project
202-
val configuration = JsConfig(
203-
project,
204-
environmentConfiguration,
205-
CompilerEnvironment,
206-
emptyList(),
207-
dependencies.toSet()
208-
)
209-
210194
val mainModule = MainModule.SourceFiles(files)
211195
val sourceModule = ModulesStructure(
212196
project,
@@ -237,7 +221,7 @@ class ErrorAnalyzer(
237221

238222
val context = ContextForNewModule(
239223
projectContext = ProjectContext(project, "COMPILER-SERVER-JS"),
240-
moduleName = Name.special("<" + configuration.moduleId + ">"),
224+
moduleName = Name.special("<" + kotlinEnvironment.jsConfiguration.moduleName + ">"),
241225
builtIns = WasmPlatformAnalyzerServices.builtIns, platform = null
242226
)
243227
val dependenciesDescriptors = mutableSetOf(context.module) + mds + WasmPlatformAnalyzerServices.builtIns.builtInsModule

src/test/kotlin/com/compiler/server/HighlightTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,23 @@ class HighlightTest : BaseExecutorTest() {
8484
fun `highlight Type inference failed`() {
8585
val highlights = highlight("fun main() {\n \"sdf\".to\n}")
8686
Assertions.assertEquals(highlights.size, 2)
87-
errorContains(highlights, "Cannot infer type for this parameter. Please specify it explicitly.")
87+
errorContains(highlights, "Cannot infer type for this parameter. Specify it explicitly.")
8888
errorContains(highlights, "Function invocation 'to(...)' expected")
8989
}
9090

9191
@Test
9292
fun `highlight js Type inference failed`() {
9393
val highlights = highlightJS("fun main() {\n \"sdf\".to\n}")
9494
Assertions.assertEquals(highlights.size, 2)
95-
errorContains(highlights, "Cannot infer type for this parameter. Please specify it explicitly.")
95+
errorContains(highlights, "Cannot infer type for this parameter. Specify it explicitly.")
9696
errorContains(highlights, "Function invocation 'to(...)' expected")
9797
}
9898

9999
@Test
100100
fun `highlight wasm Type inference failed`() {
101101
val highlights = highlightWasm("fun main() {\n \"sdf\".to\n}")
102102
Assertions.assertEquals(highlights.size, 2)
103-
errorContains(highlights, "Cannot infer type for this parameter. Please specify it explicitly.")
103+
errorContains(highlights, "Cannot infer type for this parameter. Specify it explicitly.")
104104
errorContains(highlights, "Function invocation 'to(...)' expected")
105105
}
106106
}

src/test/resources/test-compile-output/js/KotlinByExampleSnippetsTests/01_dynamic/0.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"jsCode":"//region block: polyfills\n(function () {\n if (typeof globalThis === 'object')\n return;\n Object.defineProperty(Object.prototype, '__magic__', {get: function () {\n return this;\n }, configurable: true});\n __magic__.globalThis = __magic__;\n delete Object.prototype.__magic__;\n}());\n//endregion\n(function (factory) {\n if (typeof define === 'function' && define.amd)\n define(['exports'], factory);\n else if (typeof exports === 'object')\n factory(module.exports);\n else\n globalThis.playground = factory(typeof playground === 'undefined' ? {} : playground);\n}(function (_) {\n 'use strict';\n //region block: pre-declaration\n initMetadataForObject(Unit, 'Unit');\n //endregion\n function implement(interfaces) {\n var maxSize = 1;\n var masks = [];\n var inductionVariable = 0;\n var last = interfaces.length;\n while (inductionVariable < last) {\n var i = interfaces[inductionVariable];\n inductionVariable = inductionVariable + 1 | 0;\n var currentSize = maxSize;\n var tmp0_elvis_lhs = i.prototype.$imask$;\n var imask = tmp0_elvis_lhs == null ? i.$imask$ : tmp0_elvis_lhs;\n if (!(imask == null)) {\n masks.push(imask);\n currentSize = imask.length;\n }\n var iid = i.$metadata$.iid;\n var tmp;\n if (iid == null) {\n tmp = null;\n } else {\n // Inline function 'kotlin.let' call\n // Inline function 'kotlin.js.implement.<anonymous>' call\n tmp = bitMaskWith(iid);\n }\n var iidImask = tmp;\n if (!(iidImask == null)) {\n masks.push(iidImask);\n currentSize = Math.max(currentSize, iidImask.length);\n }\n if (currentSize > maxSize) {\n maxSize = currentSize;\n }\n }\n return compositeBitMask(maxSize, masks);\n }\n function bitMaskWith(activeBit) {\n var numberIndex = activeBit >> 5;\n var intArray = new Int32Array(numberIndex + 1 | 0);\n var positionInNumber = activeBit & 31;\n var numberWithSettledBit = 1 << positionInNumber;\n intArray[numberIndex] = intArray[numberIndex] | numberWithSettledBit;\n return intArray;\n }\n function compositeBitMask(capacity, masks) {\n var tmp = 0;\n var tmp_0 = new Int32Array(capacity);\n while (tmp < capacity) {\n var tmp_1 = tmp;\n var result = 0;\n var inductionVariable = 0;\n var last = masks.length;\n while (inductionVariable < last) {\n var mask = masks[inductionVariable];\n inductionVariable = inductionVariable + 1 | 0;\n if (tmp_1 < mask.length) {\n result = result | mask[tmp_1];\n }\n }\n tmp_0[tmp_1] = result;\n tmp = tmp + 1 | 0;\n }\n return tmp_0;\n }\n function defineProp(obj, name, getter, setter) {\n return Object.defineProperty(obj, name, {configurable: true, get: getter, set: setter});\n }\n function objectCreate(proto) {\n proto = proto === VOID ? null : proto;\n return Object.create(proto);\n }\n function equals(obj1, obj2) {\n if (obj1 == null) {\n return obj2 == null;\n }\n if (obj2 == null) {\n return false;\n }\n if (typeof obj1 === 'object' && typeof obj1.equals === 'function') {\n return obj1.equals(obj2);\n }\n if (obj1 !== obj1) {\n return obj2 !== obj2;\n }\n if (typeof obj1 === 'number' && typeof obj2 === 'number') {\n var tmp;\n if (obj1 === obj2) {\n var tmp_0;\n if (obj1 !== 0) {\n tmp_0 = true;\n } else {\n // Inline function 'kotlin.js.asDynamic' call\n var tmp_1 = 1 / obj1;\n // Inline function 'kotlin.js.asDynamic' call\n tmp_0 = tmp_1 === 1 / obj2;\n }\n tmp = tmp_0;\n } else {\n tmp = false;\n }\n return tmp;\n }\n return obj1 === obj2;\n }\n function protoOf(constructor) {\n return constructor.prototype;\n }\n function createMetadata(kind, name, defaultConstructor, associatedObjectKey, associatedObjects, suspendArity) {\n var undef = VOID;\n var iid = kind === 'interface' ? generateInterfaceId() : VOID;\n return {kind: kind, simpleName: name, associatedObjectKey: associatedObjectKey, associatedObjects: associatedObjects, suspendArity: suspendArity, $kClass$: undef, defaultConstructor: defaultConstructor, iid: iid};\n }\n function generateInterfaceId() {\n if (globalInterfaceId === VOID) {\n globalInterfaceId = 0;\n }\n // Inline function 'kotlin.js.unsafeCast' call\n globalInterfaceId = globalInterfaceId + 1 | 0;\n // Inline function 'kotlin.js.unsafeCast' call\n return globalInterfaceId;\n }\n var globalInterfaceId;\n function initMetadataFor(kind, ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects) {\n if (!(parent == null)) {\n ctor.prototype = Object.create(parent.prototype);\n ctor.prototype.constructor = ctor;\n }\n var metadata = createMetadata(kind, name, defaultConstructor, associatedObjectKey, associatedObjects, suspendArity);\n ctor.$metadata$ = metadata;\n if (!(interfaces == null)) {\n var receiver = !equals(metadata.iid, VOID) ? ctor : ctor.prototype;\n receiver.$imask$ = implement(interfaces);\n }\n }\n function initMetadataForObject(ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects) {\n var kind = 'object';\n initMetadataFor(kind, ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects);\n }\n function initMetadataForCompanion(ctor, parent, interfaces, suspendArity) {\n initMetadataForObject(ctor, 'Companion', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function get_VOID() {\n _init_properties_void_kt__3zg9as();\n return VOID;\n }\n var VOID;\n var properties_initialized_void_kt_e4ret2;\n function _init_properties_void_kt__3zg9as() {\n if (!properties_initialized_void_kt_e4ret2) {\n properties_initialized_void_kt_e4ret2 = true;\n VOID = void 0;\n }\n }\n function Unit() {\n }\n var Unit_instance;\n function Unit_getInstance() {\n return Unit_instance;\n }\n function main() {\n alert('alert from Kotlin!');\n }\n function mainWrapper() {\n main();\n }\n //region block: init\n Unit_instance = new Unit();\n //endregion\nif (typeof get_output !== \"undefined\") {\n get_output();\n output = new BufferedOutput();\n _.output = get_output();\n}\n mainWrapper();\n return _;\n}));\nplayground.output?.buffer_1;\n\n","exception":null,"errors":{"File.kt":[]},"text":""}
1+
{"jsCode":"//region block: polyfills\n(function () {\n if (typeof globalThis === 'object')\n return;\n Object.defineProperty(Object.prototype, '__magic__', {get: function () {\n return this;\n }, configurable: true});\n __magic__.globalThis = __magic__;\n delete Object.prototype.__magic__;\n}());\n//endregion\n(function (factory) {\n if (typeof define === 'function' && define.amd)\n define(['exports'], factory);\n else if (typeof exports === 'object')\n factory(module.exports);\n else\n globalThis.playground = factory(typeof playground === 'undefined' ? {} : playground);\n}(function (_) {\n 'use strict';\n //region block: pre-declaration\n initMetadataForObject(Unit, 'Unit');\n //endregion\n function implement(interfaces) {\n var maxSize = 1;\n var masks = [];\n var inductionVariable = 0;\n var last = interfaces.length;\n while (inductionVariable < last) {\n var i = interfaces[inductionVariable];\n inductionVariable = inductionVariable + 1 | 0;\n var currentSize = maxSize;\n var tmp0_elvis_lhs = i.prototype.$imask$;\n var imask = tmp0_elvis_lhs == null ? i.$imask$ : tmp0_elvis_lhs;\n if (!(imask == null)) {\n masks.push(imask);\n currentSize = imask.length;\n }\n var iid = i.$metadata$.iid;\n var tmp;\n if (iid == null) {\n tmp = null;\n } else {\n // Inline function 'kotlin.let' call\n tmp = bitMaskWith(iid);\n }\n var iidImask = tmp;\n if (!(iidImask == null)) {\n masks.push(iidImask);\n currentSize = Math.max(currentSize, iidImask.length);\n }\n if (currentSize > maxSize) {\n maxSize = currentSize;\n }\n }\n return compositeBitMask(maxSize, masks);\n }\n function bitMaskWith(activeBit) {\n var numberIndex = activeBit >> 5;\n var intArray = new Int32Array(numberIndex + 1 | 0);\n var positionInNumber = activeBit & 31;\n var numberWithSettledBit = 1 << positionInNumber;\n intArray[numberIndex] = intArray[numberIndex] | numberWithSettledBit;\n return intArray;\n }\n function compositeBitMask(capacity, masks) {\n var tmp = 0;\n var tmp_0 = new Int32Array(capacity);\n while (tmp < capacity) {\n var tmp_1 = tmp;\n var result = 0;\n var inductionVariable = 0;\n var last = masks.length;\n while (inductionVariable < last) {\n var mask = masks[inductionVariable];\n inductionVariable = inductionVariable + 1 | 0;\n if (tmp_1 < mask.length) {\n result = result | mask[tmp_1];\n }\n }\n tmp_0[tmp_1] = result;\n tmp = tmp + 1 | 0;\n }\n return tmp_0;\n }\n function defineProp(obj, name, getter, setter) {\n return Object.defineProperty(obj, name, {configurable: true, get: getter, set: setter});\n }\n function objectCreate(proto) {\n proto = proto === VOID ? null : proto;\n return Object.create(proto);\n }\n function equals(obj1, obj2) {\n if (obj1 == null) {\n return obj2 == null;\n }\n if (obj2 == null) {\n return false;\n }\n if (typeof obj1 === 'object' && typeof obj1.equals === 'function') {\n return obj1.equals(obj2);\n }\n if (obj1 !== obj1) {\n return obj2 !== obj2;\n }\n if (typeof obj1 === 'number' && typeof obj2 === 'number') {\n var tmp;\n if (obj1 === obj2) {\n var tmp_0;\n if (obj1 !== 0) {\n tmp_0 = true;\n } else {\n // Inline function 'kotlin.js.asDynamic' call\n var tmp_1 = 1 / obj1;\n // Inline function 'kotlin.js.asDynamic' call\n tmp_0 = tmp_1 === 1 / obj2;\n }\n tmp = tmp_0;\n } else {\n tmp = false;\n }\n return tmp;\n }\n return obj1 === obj2;\n }\n function protoOf(constructor) {\n return constructor.prototype;\n }\n function createMetadata(kind, name, defaultConstructor, associatedObjectKey, associatedObjects, suspendArity) {\n var undef = VOID;\n var iid = kind === 'interface' ? generateInterfaceId() : VOID;\n return {kind: kind, simpleName: name, associatedObjectKey: associatedObjectKey, associatedObjects: associatedObjects, suspendArity: suspendArity, $kClass$: undef, defaultConstructor: defaultConstructor, iid: iid};\n }\n function generateInterfaceId() {\n if (globalInterfaceId === VOID) {\n globalInterfaceId = 0;\n }\n // Inline function 'kotlin.js.unsafeCast' call\n globalInterfaceId = globalInterfaceId + 1 | 0;\n // Inline function 'kotlin.js.unsafeCast' call\n return globalInterfaceId;\n }\n var globalInterfaceId;\n function initMetadataFor(kind, ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects) {\n if (!(parent == null)) {\n ctor.prototype = Object.create(parent.prototype);\n ctor.prototype.constructor = ctor;\n }\n var metadata = createMetadata(kind, name, defaultConstructor, associatedObjectKey, associatedObjects, suspendArity);\n ctor.$metadata$ = metadata;\n if (!(interfaces == null)) {\n var receiver = !equals(metadata.iid, VOID) ? ctor : ctor.prototype;\n receiver.$imask$ = implement(interfaces);\n }\n }\n function initMetadataForObject(ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects) {\n var kind = 'object';\n initMetadataFor(kind, ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects);\n }\n function initMetadataForCompanion(ctor, parent, interfaces, suspendArity) {\n initMetadataForObject(ctor, 'Companion', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function get_VOID() {\n _init_properties_void_kt__3zg9as();\n return VOID;\n }\n var VOID;\n var properties_initialized_void_kt_e4ret2;\n function _init_properties_void_kt__3zg9as() {\n if (!properties_initialized_void_kt_e4ret2) {\n properties_initialized_void_kt_e4ret2 = true;\n VOID = void 0;\n }\n }\n function Unit() {\n }\n var Unit_instance;\n function Unit_getInstance() {\n return Unit_instance;\n }\n function main() {\n alert('alert from Kotlin!');\n }\n function mainWrapper() {\n main();\n }\n //region block: init\n Unit_instance = new Unit();\n //endregion\nif (typeof get_output !== \"undefined\") {\n get_output();\n output = new BufferedOutput();\n _.output = get_output();\n}\n mainWrapper();\n return _;\n}));\nplayground.output?.buffer_1;\n\n","exception":null,"errors":{"File.kt":[]},"text":""}

0 commit comments

Comments
 (0)