Skip to content

Commit c8a4ba1

Browse files
AlexK0Space Team
authored andcommitted
[JS IR] Don't check an interface method default impl during JS translation
We do not need to check a default implementation of the interface during the translation to JS because it must be checked before. Moreover, this check breaks the produced JS code if IR is partial loaded, e.g. during the incremental rebuild. ^KT-55716 Fixed
1 parent eaa61d2 commit c8a4ba1

File tree

20 files changed

+281
-2
lines changed

20 files changed

+281
-2
lines changed

compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/jsAstUtils.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ fun translateCall(
162162
Pair(function, superQualifier.owner)
163163
}
164164

165-
val callRef = if (klass.isInterface && target.body != null) {
166-
JsNameRef(Namer.CALL_FUNCTION, JsNameRef(context.getNameForStaticDeclaration(target)))
165+
val callRef = if (klass.isInterface) {
166+
val nameForStaticDeclaration = context.getNameForStaticDeclaration(target)
167+
JsNameRef(Namer.CALL_FUNCTION, JsNameRef(nameForStaticDeclaration))
167168
} else {
168169
val qualifierName = context.getNameForClass(klass).makeRef()
169170
val targetName = context.getNameForMemberFunction(target)

js/js.tests/tests-gen/org/jetbrains/kotlin/incremental/InvalidationTestGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class ClassA : Interface {
2+
override var someVar: Int?
3+
get() = super.someVar
4+
set(value) {
5+
super.someVar = value
6+
}
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class ClassA : Interface {
2+
override var someVar: Int?
3+
get() = 1
4+
set(value) {
5+
super.someVar = value
6+
}
7+
8+
override val someValue: Int
9+
get() = super.someValue
10+
11+
override fun someFunction(): Int = super.someFunction()
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class ClassB : Interface {
2+
override var someVar: Int?
3+
get() = super.someVar
4+
set(value) {
5+
super.someVar = value
6+
}
7+
8+
val x = 1
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ClassB : Interface {
2+
val x = 3
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class ClassB : Interface {
2+
val x = 3
3+
4+
override val someValue: Int
5+
get() = super.someValue + 1
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class ClassB : Interface {
2+
val x = 3
3+
4+
override val someValue: Int
5+
get() = super.someValue + 1
6+
7+
override fun someFunction(): Int = super.someFunction() + 1
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
private var myProperty: Int? = null
2+
3+
interface Interface {
4+
var someVar: Int?
5+
get() = myProperty
6+
set(value) {
7+
myProperty = value
8+
}
9+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
private var myProperty: Int? = null
2+
3+
interface Interface {
4+
var someVar: Int?
5+
get() = myProperty?.let {
6+
if (it == 1) {
7+
it + 1
8+
} else {
9+
it
10+
}
11+
}
12+
set(value) {
13+
myProperty = value
14+
}
15+
}

0 commit comments

Comments
 (0)