Skip to content

Commit 34e8264

Browse files
committed
Adapt serialization exceptions constructor calls in legacy JS
to signature change (see Kotlin/kotlinx.serialization#1054 and commit eea4ff3) (cherry picked from commit f671c27)
1 parent 3bcba53 commit 34e8264

File tree

1 file changed

+5
-15
lines changed
  • plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/js

1 file changed

+5
-15
lines changed

plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/js/SerializableJsTranslator.kt

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
/*
2-
* Copyright 2010-2017 JetBrains s.r.o.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
2+
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
154
*/
165

176
package org.jetbrains.kotlinx.serialization.compiler.backend.js
@@ -50,7 +39,8 @@ class SerializableJsTranslator(
5039
override fun generateInternalConstructor(constructorDescriptor: ClassConstructorDescriptor) {
5140

5241
val missingExceptionClassRef = serializableDescriptor.getClassFromSerializationPackage(MISSING_FIELD_EXC)
53-
.let { context.translateQualifiedReference(it) }
42+
.constructors.single { it.valueParameters.size == 1 }
43+
.let { context.getInnerNameForDescriptor(it).makeRef() }
5444

5545
val f = context.buildFunction(constructorDescriptor) { jsFun, context ->
5646
val thiz = jsFun.scope.declareName(Namer.ANOTHER_THIS_PARAMETER_NAME).makeRef()
@@ -98,7 +88,7 @@ class SerializableJsTranslator(
9888
val initExpr = Translation.translateAsExpression(initializer, context)
9989
TranslationUtils.assignmentToBackingField(context, prop.descriptor, initExpr).makeStmt()
10090
} else {
101-
JsThrow(JsNew(missingExceptionClassRef, listOf(JsStringLiteral(prop.name))))
91+
JsThrow(JsInvocation(missingExceptionClassRef, listOf(JsStringLiteral(prop.name))))
10292
}
10393
// (seen & 1 << i == 0) -- not seen
10494
val notSeenTest = propNotSeenTest(seenVars[bitMaskSlotAt(index)], index)

0 commit comments

Comments
 (0)