From 2acb6ea065712b950ef15c63c34177449fc02221 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Mon, 18 Nov 2024 14:56:34 +0100 Subject: [PATCH 1/2] Updated Kotlin version to 2.1.0-RC2 --- gradle/libs.versions.toml | 2 +- .../js/KotlinByExampleSnippetsTests/01_dynamic/0.json | 2 +- .../js/KotlinByExampleSnippetsTests/02_js_function/1.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6bae7623..4f08328c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "2.1.0-RC" +kotlin = "2.1.0-RC2" kotlinIdeVersion = "1.9.20-506" kotlinIdeVersionWithSuffix = "231-1.9.20-506-IJ8109.175" spring-boot = "2.7.10" diff --git a/src/test/resources/test-compile-output/js/KotlinByExampleSnippetsTests/01_dynamic/0.json b/src/test/resources/test-compile-output/js/KotlinByExampleSnippetsTests/01_dynamic/0.json index 75014903..f981c91d 100644 --- a/src/test/resources/test-compile-output/js/KotlinByExampleSnippetsTests/01_dynamic/0.json +++ b/src/test/resources/test-compile-output/js/KotlinByExampleSnippetsTests/01_dynamic/0.json @@ -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 initMetadataForClass(Number_0, 'Number');\n initMetadataForClass(Long, 'Long', VOID, Number_0);\n initMetadataForObject(Unit, 'Unit');\n initMetadataForClass(BaseOutput, 'BaseOutput');\n initMetadataForClass(NodeJsOutput, 'NodeJsOutput', VOID, BaseOutput);\n initMetadataForClass(BufferedOutput, 'BufferedOutput', BufferedOutput, BaseOutput);\n initMetadataForClass(BufferedOutputToConsoleLog, 'BufferedOutputToConsoleLog', BufferedOutputToConsoleLog, BufferedOutput);\n initMetadataForClass(Exception, 'Exception', Exception_init_$Create$, Error);\n initMetadataForClass(RuntimeException, 'RuntimeException', RuntimeException_init_$Create$, Exception);\n initMetadataForClass(IllegalArgumentException, 'IllegalArgumentException', IllegalArgumentException_init_$Create$, RuntimeException);\n //endregion\n function Number_0() {\n }\n function _Char___init__impl__6a9atx(value) {\n return value;\n }\n function _get_value__a43j40($this) {\n return $this;\n }\n function _Char___init__impl__6a9atx_0(code) {\n // Inline function 'kotlin.UShort.toInt' call\n var tmp$ret$0 = _UShort___get_data__impl__g0245(code) & 65535;\n return _Char___init__impl__6a9atx(tmp$ret$0);\n }\n function Char__toInt_impl_vasixd($this) {\n return _get_value__a43j40($this);\n }\n function toString($this) {\n // Inline function 'kotlin.js.unsafeCast' call\n return String.fromCharCode(_get_value__a43j40($this));\n }\n function Long() {\n }\n protoOf(Long).toInt_1tsl84_k$ = function () {\n return this.low_1;\n };\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.' 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 charSequenceGet(a, index) {\n var tmp;\n if (isString(a)) {\n // Inline function 'kotlin.js.asDynamic' call\n // Inline function 'kotlin.js.unsafeCast' call\n // Inline function 'kotlin.Char' call\n var code = a.charCodeAt(index);\n var tmp_0;\n // Inline function 'kotlin.code' call\n var this_0 = _Char___init__impl__6a9atx(0);\n if (code < Char__toInt_impl_vasixd(this_0)) {\n tmp_0 = true;\n } else {\n // Inline function 'kotlin.code' call\n var this_1 = _Char___init__impl__6a9atx(65535);\n tmp_0 = code > Char__toInt_impl_vasixd(this_1);\n }\n if (tmp_0) {\n throw IllegalArgumentException_init_$Create$_0('Invalid Char code: ' + code);\n }\n tmp = numberToChar(code);\n } else {\n tmp = a.get_kdzpvg_k$(index);\n }\n return tmp;\n }\n function isString(a) {\n return typeof a === 'string';\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 captureStack(instance, constructorFunction) {\n if (Error.captureStackTrace != null) {\n Error.captureStackTrace(instance, constructorFunction);\n } else {\n // Inline function 'kotlin.js.asDynamic' call\n instance.stack = (new Error()).stack;\n }\n }\n function protoOf(constructor) {\n return constructor.prototype;\n }\n function extendThrowable(this_, message, cause) {\n Error.call(this_);\n setPropertiesToThrowableInstance(this_, message, cause);\n }\n function setPropertiesToThrowableInstance(this_, message, cause) {\n var errorInfo = calculateErrorInfo(Object.getPrototypeOf(this_));\n if ((errorInfo & 1) === 0) {\n var tmp;\n if (message == null) {\n var tmp_0;\n if (!(message === null)) {\n var tmp1_elvis_lhs = cause == null ? null : cause.toString();\n tmp_0 = tmp1_elvis_lhs == null ? VOID : tmp1_elvis_lhs;\n } else {\n tmp_0 = VOID;\n }\n tmp = tmp_0;\n } else {\n tmp = message;\n }\n this_.message = tmp;\n }\n if ((errorInfo & 2) === 0) {\n this_.cause = cause;\n }\n this_.name = Object.getPrototypeOf(this_).constructor.name;\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 initMetadataForClass(ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects) {\n var kind = 'class';\n initMetadataFor(kind, ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects);\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 initMetadataForLambda(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'Lambda', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForCoroutine(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'Coroutine', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForFunctionReference(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'FunctionReference', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForCompanion(ctor, parent, interfaces, suspendArity) {\n initMetadataForObject(ctor, 'Companion', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function numberToInt(a) {\n var tmp;\n if (a instanceof Long) {\n tmp = a.toInt_1tsl84_k$();\n } else {\n tmp = doubleToInt(a);\n }\n return tmp;\n }\n function doubleToInt(a) {\n var tmp;\n if (a > 2147483647) {\n tmp = 2147483647;\n } else if (a < -2147483648) {\n tmp = -2147483648;\n } else {\n // Inline function 'kotlin.js.jsBitwiseOr' call\n tmp = a | 0;\n }\n return tmp;\n }\n function toShort(a) {\n // Inline function 'kotlin.js.unsafeCast' call\n return a << 16 >> 16;\n }\n function numberToChar(a) {\n // Inline function 'kotlin.toUShort' call\n var this_0 = numberToInt(a);\n var tmp$ret$0 = _UShort___init__impl__jigrne(toShort(this_0));\n return _Char___init__impl__6a9atx_0(tmp$ret$0);\n }\n function calculateErrorInfo(proto) {\n var tmp0_safe_receiver = proto.constructor;\n var metadata = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.$metadata$;\n var tmp2_safe_receiver = metadata == null ? null : metadata.errorInfo;\n if (tmp2_safe_receiver == null)\n null;\n else {\n // Inline function 'kotlin.let' call\n return tmp2_safe_receiver;\n }\n var result = 0;\n if (hasProp(proto, 'message'))\n result = result | 1;\n if (hasProp(proto, 'cause'))\n result = result | 2;\n if (!(result === 3)) {\n var parentProto = getPrototypeOf(proto);\n if (parentProto != Error.prototype) {\n result = result | calculateErrorInfo(parentProto);\n }\n }\n if (!(metadata == null)) {\n metadata.errorInfo = result;\n }\n return result;\n }\n function hasProp(proto, propName) {\n return proto.hasOwnProperty(propName);\n }\n function getPrototypeOf(obj) {\n return Object.getPrototypeOf(obj);\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 protoOf(Unit).toString = function () {\n return 'kotlin.Unit';\n };\n var Unit_instance;\n function Unit_getInstance() {\n return Unit_instance;\n }\n function get_output() {\n _init_properties_console_kt__rfg7jv();\n return output;\n }\n var output;\n function BaseOutput() {\n }\n protoOf(BaseOutput).println_uvj9r3_k$ = function () {\n this.print_o1pwgy_k$('\\n');\n };\n protoOf(BaseOutput).println_ghnc0w_k$ = function (message) {\n this.print_o1pwgy_k$(message);\n this.println_uvj9r3_k$();\n };\n function NodeJsOutput(outputStream) {\n BaseOutput.call(this);\n this.outputStream_1 = outputStream;\n }\n protoOf(NodeJsOutput).print_o1pwgy_k$ = function (message) {\n // Inline function 'kotlin.io.String' call\n var messageString = String(message);\n this.outputStream_1.write(messageString);\n };\n function BufferedOutputToConsoleLog() {\n BufferedOutput.call(this);\n }\n protoOf(BufferedOutputToConsoleLog).print_o1pwgy_k$ = function (message) {\n // Inline function 'kotlin.io.String' call\n var s = String(message);\n // Inline function 'kotlin.text.nativeLastIndexOf' call\n // Inline function 'kotlin.js.asDynamic' call\n var i = s.lastIndexOf('\\n', 0);\n if (i >= 0) {\n var tmp = this;\n var tmp_0 = this.buffer_1;\n // Inline function 'kotlin.text.substring' call\n // Inline function 'kotlin.js.asDynamic' call\n tmp.buffer_1 = tmp_0 + s.substring(0, i);\n this.flush_shahbo_k$();\n var tmp6 = s;\n // Inline function 'kotlin.text.substring' call\n var startIndex = i + 1 | 0;\n // Inline function 'kotlin.js.asDynamic' call\n s = tmp6.substring(startIndex);\n }\n this.buffer_1 = this.buffer_1 + s;\n };\n protoOf(BufferedOutputToConsoleLog).flush_shahbo_k$ = function () {\n console.log(this.buffer_1);\n this.buffer_1 = '';\n };\n function BufferedOutput() {\n BaseOutput.call(this);\n this.buffer_1 = '';\n }\n protoOf(BufferedOutput).print_o1pwgy_k$ = function (message) {\n var tmp = this;\n var tmp_0 = this.buffer_1;\n // Inline function 'kotlin.io.String' call\n tmp.buffer_1 = tmp_0 + String(message);\n };\n function println(message) {\n _init_properties_console_kt__rfg7jv();\n get_output().println_ghnc0w_k$(message);\n }\n var properties_initialized_console_kt_gll9dl;\n function _init_properties_console_kt__rfg7jv() {\n if (!properties_initialized_console_kt_gll9dl) {\n properties_initialized_console_kt_gll9dl = true;\n // Inline function 'kotlin.run' call\n // Inline function 'kotlin.io.output.' call\n var isNode = typeof process !== 'undefined' && process.versions && !!process.versions.node;\n output = isNode ? new NodeJsOutput(process.stdout) : new BufferedOutputToConsoleLog();\n }\n }\n function Exception_init_$Init$($this) {\n extendThrowable($this);\n Exception.call($this);\n return $this;\n }\n function Exception_init_$Create$() {\n var tmp = Exception_init_$Init$(objectCreate(protoOf(Exception)));\n captureStack(tmp, Exception_init_$Create$);\n return tmp;\n }\n function Exception_init_$Init$_0(message, $this) {\n extendThrowable($this, message);\n Exception.call($this);\n return $this;\n }\n function Exception() {\n captureStack(this, Exception);\n }\n function IllegalArgumentException_init_$Init$($this) {\n RuntimeException_init_$Init$($this);\n IllegalArgumentException.call($this);\n return $this;\n }\n function IllegalArgumentException_init_$Create$() {\n var tmp = IllegalArgumentException_init_$Init$(objectCreate(protoOf(IllegalArgumentException)));\n captureStack(tmp, IllegalArgumentException_init_$Create$);\n return tmp;\n }\n function IllegalArgumentException_init_$Init$_0(message, $this) {\n RuntimeException_init_$Init$_0(message, $this);\n IllegalArgumentException.call($this);\n return $this;\n }\n function IllegalArgumentException_init_$Create$_0(message) {\n var tmp = IllegalArgumentException_init_$Init$_0(message, objectCreate(protoOf(IllegalArgumentException)));\n captureStack(tmp, IllegalArgumentException_init_$Create$_0);\n return tmp;\n }\n function IllegalArgumentException() {\n captureStack(this, IllegalArgumentException);\n }\n function RuntimeException_init_$Init$($this) {\n Exception_init_$Init$($this);\n RuntimeException.call($this);\n return $this;\n }\n function RuntimeException_init_$Create$() {\n var tmp = RuntimeException_init_$Init$(objectCreate(protoOf(RuntimeException)));\n captureStack(tmp, RuntimeException_init_$Create$);\n return tmp;\n }\n function RuntimeException_init_$Init$_0(message, $this) {\n Exception_init_$Init$_0(message, $this);\n RuntimeException.call($this);\n return $this;\n }\n function RuntimeException() {\n captureStack(this, RuntimeException);\n }\n function _UShort___init__impl__jigrne(data) {\n return data;\n }\n function _UShort___get_data__impl__g0245($this) {\n return $this;\n }\n function main() {\n var a = 'abc';\n var b = a;\n println(toString(main$firstChar(a)) + ' == ' + toString(main$firstChar(b)));\n println('' + a.charCodeAt(0, 'dummy argument') + ' == ' + Char__toInt_impl_vasixd(charSequenceGet(b, 0)));\n println(a.charAt(1).repeat(3));\n println('2 + 2 = ' + main$plus(2));\n println(\"'2' + 2 = \" + main$plus('2'));\n }\n function main$firstChar(s) {\n return charSequenceGet(s, 0);\n }\n function main$plus(v) {\n return v + 2;\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":[{"interval":{"start":{"line":9,"ch":58},"end":{"line":9,"ch":63}},"message":"[DEPRECATION] 'fun toInt(): Int' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead.","severity":"WARNING","className":"WARNING"},{"interval":{"start":{"line":9,"ch":58},"end":{"line":9,"ch":63}},"message":"'fun toInt(): Int' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead.","severity":"WARNING","className":"WARNING"}]},"text":""} \ No newline at end of file +{"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}());\nif (typeof ArrayBuffer.isView === 'undefined') {\n ArrayBuffer.isView = function (a) {\n return a != null && a.__proto__ != null && a.__proto__.__proto__ === Int8Array.prototype.__proto__;\n };\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: imports\n var isView = ArrayBuffer.isView;\n //endregion\n //region block: pre-declaration\n initMetadataForClass(Number_0, 'Number');\n initMetadataForClass(Long, 'Long', VOID, Number_0);\n initMetadataForObject(Unit, 'Unit');\n initMetadataForClass(BaseOutput, 'BaseOutput');\n initMetadataForClass(NodeJsOutput, 'NodeJsOutput', VOID, BaseOutput);\n initMetadataForClass(BufferedOutput, 'BufferedOutput', BufferedOutput, BaseOutput);\n initMetadataForClass(BufferedOutputToConsoleLog, 'BufferedOutputToConsoleLog', BufferedOutputToConsoleLog, BufferedOutput);\n initMetadataForClass(Exception, 'Exception', Exception_init_$Create$, Error);\n initMetadataForClass(RuntimeException, 'RuntimeException', RuntimeException_init_$Create$, Exception);\n initMetadataForClass(IllegalArgumentException, 'IllegalArgumentException', IllegalArgumentException_init_$Create$, RuntimeException);\n //endregion\n function Number_0() {\n }\n function _Char___init__impl__6a9atx(value) {\n return value;\n }\n function _get_value__a43j40($this) {\n return $this;\n }\n function _Char___init__impl__6a9atx_0(code) {\n // Inline function 'kotlin.UShort.toInt' call\n var tmp$ret$0 = _UShort___get_data__impl__g0245(code) & 65535;\n return _Char___init__impl__6a9atx(tmp$ret$0);\n }\n function Char__toInt_impl_vasixd($this) {\n return _get_value__a43j40($this);\n }\n function toString($this) {\n // Inline function 'kotlin.js.unsafeCast' call\n return String.fromCharCode(_get_value__a43j40($this));\n }\n function Long() {\n }\n protoOf(Long).toInt_1tsl84_k$ = function () {\n return this.low_1;\n };\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.' 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 charSequenceGet(a, index) {\n var tmp;\n if (isString(a)) {\n // Inline function 'kotlin.js.asDynamic' call\n // Inline function 'kotlin.js.unsafeCast' call\n // Inline function 'kotlin.Char' call\n var code = a.charCodeAt(index);\n var tmp_0;\n // Inline function 'kotlin.code' call\n var this_0 = _Char___init__impl__6a9atx(0);\n if (code < Char__toInt_impl_vasixd(this_0)) {\n tmp_0 = true;\n } else {\n // Inline function 'kotlin.code' call\n var this_1 = _Char___init__impl__6a9atx(65535);\n tmp_0 = code > Char__toInt_impl_vasixd(this_1);\n }\n if (tmp_0) {\n throw IllegalArgumentException_init_$Create$_0('Invalid Char code: ' + code);\n }\n tmp = numberToChar(code);\n } else {\n tmp = a.get_kdzpvg_k$(index);\n }\n return tmp;\n }\n function isString(a) {\n return typeof a === 'string';\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 toString_0(o) {\n var tmp;\n if (o == null) {\n tmp = 'null';\n } else if (isArrayish(o)) {\n tmp = '[...]';\n } else if (!(typeof o.toString === 'function')) {\n tmp = anyToString(o);\n } else {\n // Inline function 'kotlin.js.unsafeCast' call\n tmp = o.toString();\n }\n return tmp;\n }\n function anyToString(o) {\n return Object.prototype.toString.call(o);\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 captureStack(instance, constructorFunction) {\n if (Error.captureStackTrace != null) {\n Error.captureStackTrace(instance, constructorFunction);\n } else {\n // Inline function 'kotlin.js.asDynamic' call\n instance.stack = (new Error()).stack;\n }\n }\n function protoOf(constructor) {\n return constructor.prototype;\n }\n function extendThrowable(this_, message, cause) {\n Error.call(this_);\n setPropertiesToThrowableInstance(this_, message, cause);\n }\n function setPropertiesToThrowableInstance(this_, message, cause) {\n var errorInfo = calculateErrorInfo(Object.getPrototypeOf(this_));\n if ((errorInfo & 1) === 0) {\n var tmp;\n if (message == null) {\n var tmp_0;\n if (!(message === null)) {\n var tmp1_elvis_lhs = cause == null ? null : cause.toString();\n tmp_0 = tmp1_elvis_lhs == null ? VOID : tmp1_elvis_lhs;\n } else {\n tmp_0 = VOID;\n }\n tmp = tmp_0;\n } else {\n tmp = message;\n }\n this_.message = tmp;\n }\n if ((errorInfo & 2) === 0) {\n this_.cause = cause;\n }\n this_.name = Object.getPrototypeOf(this_).constructor.name;\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 initMetadataForClass(ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects) {\n var kind = 'class';\n initMetadataFor(kind, ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects);\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 initMetadataForLambda(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'Lambda', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForCoroutine(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'Coroutine', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForFunctionReference(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'FunctionReference', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForCompanion(ctor, parent, interfaces, suspendArity) {\n initMetadataForObject(ctor, 'Companion', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function numberToInt(a) {\n var tmp;\n if (a instanceof Long) {\n tmp = a.toInt_1tsl84_k$();\n } else {\n tmp = doubleToInt(a);\n }\n return tmp;\n }\n function doubleToInt(a) {\n var tmp;\n if (a > 2147483647) {\n tmp = 2147483647;\n } else if (a < -2147483648) {\n tmp = -2147483648;\n } else {\n // Inline function 'kotlin.js.jsBitwiseOr' call\n tmp = a | 0;\n }\n return tmp;\n }\n function toShort(a) {\n // Inline function 'kotlin.js.unsafeCast' call\n return a << 16 >> 16;\n }\n function numberToChar(a) {\n // Inline function 'kotlin.toUShort' call\n var this_0 = numberToInt(a);\n var tmp$ret$0 = _UShort___init__impl__jigrne(toShort(this_0));\n return _Char___init__impl__6a9atx_0(tmp$ret$0);\n }\n function isJsArray(obj) {\n // Inline function 'kotlin.js.unsafeCast' call\n return Array.isArray(obj);\n }\n function isArrayish(o) {\n return isJsArray(o) || isView(o);\n }\n function calculateErrorInfo(proto) {\n var tmp0_safe_receiver = proto.constructor;\n var metadata = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.$metadata$;\n var tmp2_safe_receiver = metadata == null ? null : metadata.errorInfo;\n if (tmp2_safe_receiver == null)\n null;\n else {\n // Inline function 'kotlin.let' call\n return tmp2_safe_receiver;\n }\n var result = 0;\n if (hasProp(proto, 'message'))\n result = result | 1;\n if (hasProp(proto, 'cause'))\n result = result | 2;\n if (!(result === 3)) {\n var parentProto = getPrototypeOf(proto);\n if (parentProto != Error.prototype) {\n result = result | calculateErrorInfo(parentProto);\n }\n }\n if (!(metadata == null)) {\n metadata.errorInfo = result;\n }\n return result;\n }\n function hasProp(proto, propName) {\n return proto.hasOwnProperty(propName);\n }\n function getPrototypeOf(obj) {\n return Object.getPrototypeOf(obj);\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 protoOf(Unit).toString = function () {\n return 'kotlin.Unit';\n };\n var Unit_instance;\n function Unit_getInstance() {\n return Unit_instance;\n }\n function get_output() {\n _init_properties_console_kt__rfg7jv();\n return output;\n }\n var output;\n function BaseOutput() {\n }\n protoOf(BaseOutput).println_uvj9r3_k$ = function () {\n this.print_o1pwgy_k$('\\n');\n };\n protoOf(BaseOutput).println_ghnc0w_k$ = function (message) {\n this.print_o1pwgy_k$(message);\n this.println_uvj9r3_k$();\n };\n function NodeJsOutput(outputStream) {\n BaseOutput.call(this);\n this.outputStream_1 = outputStream;\n }\n protoOf(NodeJsOutput).print_o1pwgy_k$ = function (message) {\n // Inline function 'kotlin.io.String' call\n var tmp1_elvis_lhs = message == null ? null : toString_0(message);\n var messageString = tmp1_elvis_lhs == null ? 'null' : tmp1_elvis_lhs;\n this.outputStream_1.write(messageString);\n };\n function BufferedOutputToConsoleLog() {\n BufferedOutput.call(this);\n }\n protoOf(BufferedOutputToConsoleLog).print_o1pwgy_k$ = function (message) {\n // Inline function 'kotlin.io.String' call\n var tmp1_elvis_lhs = message == null ? null : toString_0(message);\n var s = tmp1_elvis_lhs == null ? 'null' : tmp1_elvis_lhs;\n // Inline function 'kotlin.text.nativeLastIndexOf' call\n // Inline function 'kotlin.js.asDynamic' call\n var i = s.lastIndexOf('\\n', 0);\n if (i >= 0) {\n var tmp = this;\n var tmp_0 = this.buffer_1;\n // Inline function 'kotlin.text.substring' call\n // Inline function 'kotlin.js.asDynamic' call\n tmp.buffer_1 = tmp_0 + s.substring(0, i);\n this.flush_shahbo_k$();\n var tmp6 = s;\n // Inline function 'kotlin.text.substring' call\n var startIndex = i + 1 | 0;\n // Inline function 'kotlin.js.asDynamic' call\n s = tmp6.substring(startIndex);\n }\n this.buffer_1 = this.buffer_1 + s;\n };\n protoOf(BufferedOutputToConsoleLog).flush_shahbo_k$ = function () {\n console.log(this.buffer_1);\n this.buffer_1 = '';\n };\n function BufferedOutput() {\n BaseOutput.call(this);\n this.buffer_1 = '';\n }\n protoOf(BufferedOutput).print_o1pwgy_k$ = function (message) {\n var tmp = this;\n var tmp_0 = this.buffer_1;\n // Inline function 'kotlin.io.String' call\n var tmp1_elvis_lhs = message == null ? null : toString_0(message);\n tmp.buffer_1 = tmp_0 + (tmp1_elvis_lhs == null ? 'null' : tmp1_elvis_lhs);\n };\n function println(message) {\n _init_properties_console_kt__rfg7jv();\n get_output().println_ghnc0w_k$(message);\n }\n var properties_initialized_console_kt_gll9dl;\n function _init_properties_console_kt__rfg7jv() {\n if (!properties_initialized_console_kt_gll9dl) {\n properties_initialized_console_kt_gll9dl = true;\n // Inline function 'kotlin.run' call\n // Inline function 'kotlin.io.output.' call\n var isNode = typeof process !== 'undefined' && process.versions && !!process.versions.node;\n output = isNode ? new NodeJsOutput(process.stdout) : new BufferedOutputToConsoleLog();\n }\n }\n function Exception_init_$Init$($this) {\n extendThrowable($this);\n Exception.call($this);\n return $this;\n }\n function Exception_init_$Create$() {\n var tmp = Exception_init_$Init$(objectCreate(protoOf(Exception)));\n captureStack(tmp, Exception_init_$Create$);\n return tmp;\n }\n function Exception_init_$Init$_0(message, $this) {\n extendThrowable($this, message);\n Exception.call($this);\n return $this;\n }\n function Exception() {\n captureStack(this, Exception);\n }\n function IllegalArgumentException_init_$Init$($this) {\n RuntimeException_init_$Init$($this);\n IllegalArgumentException.call($this);\n return $this;\n }\n function IllegalArgumentException_init_$Create$() {\n var tmp = IllegalArgumentException_init_$Init$(objectCreate(protoOf(IllegalArgumentException)));\n captureStack(tmp, IllegalArgumentException_init_$Create$);\n return tmp;\n }\n function IllegalArgumentException_init_$Init$_0(message, $this) {\n RuntimeException_init_$Init$_0(message, $this);\n IllegalArgumentException.call($this);\n return $this;\n }\n function IllegalArgumentException_init_$Create$_0(message) {\n var tmp = IllegalArgumentException_init_$Init$_0(message, objectCreate(protoOf(IllegalArgumentException)));\n captureStack(tmp, IllegalArgumentException_init_$Create$_0);\n return tmp;\n }\n function IllegalArgumentException() {\n captureStack(this, IllegalArgumentException);\n }\n function RuntimeException_init_$Init$($this) {\n Exception_init_$Init$($this);\n RuntimeException.call($this);\n return $this;\n }\n function RuntimeException_init_$Create$() {\n var tmp = RuntimeException_init_$Init$(objectCreate(protoOf(RuntimeException)));\n captureStack(tmp, RuntimeException_init_$Create$);\n return tmp;\n }\n function RuntimeException_init_$Init$_0(message, $this) {\n Exception_init_$Init$_0(message, $this);\n RuntimeException.call($this);\n return $this;\n }\n function RuntimeException() {\n captureStack(this, RuntimeException);\n }\n function _UShort___init__impl__jigrne(data) {\n return data;\n }\n function _UShort___get_data__impl__g0245($this) {\n return $this;\n }\n function main() {\n var a = 'abc';\n var b = a;\n println(toString(main$firstChar(a)) + ' == ' + toString(main$firstChar(b)));\n println('' + a.charCodeAt(0, 'dummy argument') + ' == ' + Char__toInt_impl_vasixd(charSequenceGet(b, 0)));\n println(a.charAt(1).repeat(3));\n println('2 + 2 = ' + main$plus(2));\n println(\"'2' + 2 = \" + main$plus('2'));\n }\n function main$firstChar(s) {\n return charSequenceGet(s, 0);\n }\n function main$plus(v) {\n return v + 2;\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":[{"interval":{"start":{"line":9,"ch":58},"end":{"line":9,"ch":63}},"message":"[DEPRECATION] 'fun toInt(): Int' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead.","severity":"WARNING","className":"WARNING"},{"interval":{"start":{"line":9,"ch":58},"end":{"line":9,"ch":63}},"message":"'fun toInt(): Int' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead.","severity":"WARNING","className":"WARNING"}]},"text":""} \ No newline at end of file diff --git a/src/test/resources/test-compile-output/js/KotlinByExampleSnippetsTests/02_js_function/1.json b/src/test/resources/test-compile-output/js/KotlinByExampleSnippetsTests/02_js_function/1.json index 350ea63d..22c9d3b0 100644 --- a/src/test/resources/test-compile-output/js/KotlinByExampleSnippetsTests/02_js_function/1.json +++ b/src/test/resources/test-compile-output/js/KotlinByExampleSnippetsTests/02_js_function/1.json @@ -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 initMetadataForClass(BaseOutput, 'BaseOutput');\n initMetadataForClass(NodeJsOutput, 'NodeJsOutput', VOID, BaseOutput);\n initMetadataForClass(BufferedOutput, 'BufferedOutput', BufferedOutput, BaseOutput);\n initMetadataForClass(BufferedOutputToConsoleLog, 'BufferedOutputToConsoleLog', BufferedOutputToConsoleLog, BufferedOutput);\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.' 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 initMetadataForClass(ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects) {\n var kind = 'class';\n initMetadataFor(kind, ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects);\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 initMetadataForLambda(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'Lambda', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForCoroutine(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'Coroutine', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForFunctionReference(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'FunctionReference', VOID, parent, interfaces, suspendArity, VOID, VOID);\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 protoOf(Unit).toString = function () {\n return 'kotlin.Unit';\n };\n var Unit_instance;\n function Unit_getInstance() {\n return Unit_instance;\n }\n function get_output() {\n _init_properties_console_kt__rfg7jv();\n return output;\n }\n var output;\n function BaseOutput() {\n }\n protoOf(BaseOutput).println_uvj9r3_k$ = function () {\n this.print_o1pwgy_k$('\\n');\n };\n protoOf(BaseOutput).println_ghnc0w_k$ = function (message) {\n this.print_o1pwgy_k$(message);\n this.println_uvj9r3_k$();\n };\n function NodeJsOutput(outputStream) {\n BaseOutput.call(this);\n this.outputStream_1 = outputStream;\n }\n protoOf(NodeJsOutput).print_o1pwgy_k$ = function (message) {\n // Inline function 'kotlin.io.String' call\n var messageString = String(message);\n this.outputStream_1.write(messageString);\n };\n function BufferedOutputToConsoleLog() {\n BufferedOutput.call(this);\n }\n protoOf(BufferedOutputToConsoleLog).print_o1pwgy_k$ = function (message) {\n // Inline function 'kotlin.io.String' call\n var s = String(message);\n // Inline function 'kotlin.text.nativeLastIndexOf' call\n // Inline function 'kotlin.js.asDynamic' call\n var i = s.lastIndexOf('\\n', 0);\n if (i >= 0) {\n var tmp = this;\n var tmp_0 = this.buffer_1;\n // Inline function 'kotlin.text.substring' call\n // Inline function 'kotlin.js.asDynamic' call\n tmp.buffer_1 = tmp_0 + s.substring(0, i);\n this.flush_shahbo_k$();\n var tmp6 = s;\n // Inline function 'kotlin.text.substring' call\n var startIndex = i + 1 | 0;\n // Inline function 'kotlin.js.asDynamic' call\n s = tmp6.substring(startIndex);\n }\n this.buffer_1 = this.buffer_1 + s;\n };\n protoOf(BufferedOutputToConsoleLog).flush_shahbo_k$ = function () {\n console.log(this.buffer_1);\n this.buffer_1 = '';\n };\n function BufferedOutput() {\n BaseOutput.call(this);\n this.buffer_1 = '';\n }\n protoOf(BufferedOutput).print_o1pwgy_k$ = function (message) {\n var tmp = this;\n var tmp_0 = this.buffer_1;\n // Inline function 'kotlin.io.String' call\n tmp.buffer_1 = tmp_0 + String(message);\n };\n function println(message) {\n _init_properties_console_kt__rfg7jv();\n get_output().println_ghnc0w_k$(message);\n }\n var properties_initialized_console_kt_gll9dl;\n function _init_properties_console_kt__rfg7jv() {\n if (!properties_initialized_console_kt_gll9dl) {\n properties_initialized_console_kt_gll9dl = true;\n // Inline function 'kotlin.run' call\n // Inline function 'kotlin.io.output.' call\n var isNode = typeof process !== 'undefined' && process.versions && !!process.versions.node;\n output = isNode ? new NodeJsOutput(process.stdout) : new BufferedOutputToConsoleLog();\n }\n }\n function main() {\n var json = {};\n json.name = 'Jane';\n json.hobby = 'movies';\n println(JSON.stringify(json));\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":""} \ No newline at end of file +{"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}());\nif (typeof ArrayBuffer.isView === 'undefined') {\n ArrayBuffer.isView = function (a) {\n return a != null && a.__proto__ != null && a.__proto__.__proto__ === Int8Array.prototype.__proto__;\n };\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: imports\n var isView = ArrayBuffer.isView;\n //endregion\n //region block: pre-declaration\n initMetadataForObject(Unit, 'Unit');\n initMetadataForClass(BaseOutput, 'BaseOutput');\n initMetadataForClass(NodeJsOutput, 'NodeJsOutput', VOID, BaseOutput);\n initMetadataForClass(BufferedOutput, 'BufferedOutput', BufferedOutput, BaseOutput);\n initMetadataForClass(BufferedOutputToConsoleLog, 'BufferedOutputToConsoleLog', BufferedOutputToConsoleLog, BufferedOutput);\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.' 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 toString(o) {\n var tmp;\n if (o == null) {\n tmp = 'null';\n } else if (isArrayish(o)) {\n tmp = '[...]';\n } else if (!(typeof o.toString === 'function')) {\n tmp = anyToString(o);\n } else {\n // Inline function 'kotlin.js.unsafeCast' call\n tmp = o.toString();\n }\n return tmp;\n }\n function anyToString(o) {\n return Object.prototype.toString.call(o);\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 initMetadataForClass(ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects) {\n var kind = 'class';\n initMetadataFor(kind, ctor, name, defaultConstructor, parent, interfaces, suspendArity, associatedObjectKey, associatedObjects);\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 initMetadataForLambda(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'Lambda', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForCoroutine(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'Coroutine', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForFunctionReference(ctor, parent, interfaces, suspendArity) {\n initMetadataForClass(ctor, 'FunctionReference', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function initMetadataForCompanion(ctor, parent, interfaces, suspendArity) {\n initMetadataForObject(ctor, 'Companion', VOID, parent, interfaces, suspendArity, VOID, VOID);\n }\n function isJsArray(obj) {\n // Inline function 'kotlin.js.unsafeCast' call\n return Array.isArray(obj);\n }\n function isArrayish(o) {\n return isJsArray(o) || isView(o);\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 protoOf(Unit).toString = function () {\n return 'kotlin.Unit';\n };\n var Unit_instance;\n function Unit_getInstance() {\n return Unit_instance;\n }\n function get_output() {\n _init_properties_console_kt__rfg7jv();\n return output;\n }\n var output;\n function BaseOutput() {\n }\n protoOf(BaseOutput).println_uvj9r3_k$ = function () {\n this.print_o1pwgy_k$('\\n');\n };\n protoOf(BaseOutput).println_ghnc0w_k$ = function (message) {\n this.print_o1pwgy_k$(message);\n this.println_uvj9r3_k$();\n };\n function NodeJsOutput(outputStream) {\n BaseOutput.call(this);\n this.outputStream_1 = outputStream;\n }\n protoOf(NodeJsOutput).print_o1pwgy_k$ = function (message) {\n // Inline function 'kotlin.io.String' call\n var tmp1_elvis_lhs = message == null ? null : toString(message);\n var messageString = tmp1_elvis_lhs == null ? 'null' : tmp1_elvis_lhs;\n this.outputStream_1.write(messageString);\n };\n function BufferedOutputToConsoleLog() {\n BufferedOutput.call(this);\n }\n protoOf(BufferedOutputToConsoleLog).print_o1pwgy_k$ = function (message) {\n // Inline function 'kotlin.io.String' call\n var tmp1_elvis_lhs = message == null ? null : toString(message);\n var s = tmp1_elvis_lhs == null ? 'null' : tmp1_elvis_lhs;\n // Inline function 'kotlin.text.nativeLastIndexOf' call\n // Inline function 'kotlin.js.asDynamic' call\n var i = s.lastIndexOf('\\n', 0);\n if (i >= 0) {\n var tmp = this;\n var tmp_0 = this.buffer_1;\n // Inline function 'kotlin.text.substring' call\n // Inline function 'kotlin.js.asDynamic' call\n tmp.buffer_1 = tmp_0 + s.substring(0, i);\n this.flush_shahbo_k$();\n var tmp6 = s;\n // Inline function 'kotlin.text.substring' call\n var startIndex = i + 1 | 0;\n // Inline function 'kotlin.js.asDynamic' call\n s = tmp6.substring(startIndex);\n }\n this.buffer_1 = this.buffer_1 + s;\n };\n protoOf(BufferedOutputToConsoleLog).flush_shahbo_k$ = function () {\n console.log(this.buffer_1);\n this.buffer_1 = '';\n };\n function BufferedOutput() {\n BaseOutput.call(this);\n this.buffer_1 = '';\n }\n protoOf(BufferedOutput).print_o1pwgy_k$ = function (message) {\n var tmp = this;\n var tmp_0 = this.buffer_1;\n // Inline function 'kotlin.io.String' call\n var tmp1_elvis_lhs = message == null ? null : toString(message);\n tmp.buffer_1 = tmp_0 + (tmp1_elvis_lhs == null ? 'null' : tmp1_elvis_lhs);\n };\n function println(message) {\n _init_properties_console_kt__rfg7jv();\n get_output().println_ghnc0w_k$(message);\n }\n var properties_initialized_console_kt_gll9dl;\n function _init_properties_console_kt__rfg7jv() {\n if (!properties_initialized_console_kt_gll9dl) {\n properties_initialized_console_kt_gll9dl = true;\n // Inline function 'kotlin.run' call\n // Inline function 'kotlin.io.output.' call\n var isNode = typeof process !== 'undefined' && process.versions && !!process.versions.node;\n output = isNode ? new NodeJsOutput(process.stdout) : new BufferedOutputToConsoleLog();\n }\n }\n function main() {\n var json = {};\n json.name = 'Jane';\n json.hobby = 'movies';\n println(JSON.stringify(json));\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":""} \ No newline at end of file From cf12b1e29cbd1c5880cb9c959411affe72181933 Mon Sep 17 00:00:00 2001 From: Dmitrii Krasnov Date: Wed, 27 Nov 2024 15:22:19 +0100 Subject: [PATCH 2/2] Updated Kotlin version to 2.1.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4f08328c..bd068fda 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "2.1.0-RC2" +kotlin = "2.1.0" kotlinIdeVersion = "1.9.20-506" kotlinIdeVersionWithSuffix = "231-1.9.20-506-IJ8109.175" spring-boot = "2.7.10"