-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Wasm] Fix equality checks for non-capturing property references
#KT-71474 Fixed
- Loading branch information
1 parent
2eea913
commit d0c7346
Showing
26 changed files
with
704 additions
and
41 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...s/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
...vel/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
...n/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
...sts-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
compiler/testData/codegen/box/callableReference/equality/kproperty.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// IGNORE_BACKEND: JS, JS_IR | ||
// IGNORE_BACKEND: JS_IR_ES6 | ||
// WITH_STDLIB | ||
// FILE: test.kt | ||
|
||
import kotlin.test.assertEquals | ||
|
||
val topLevelVal = "" | ||
var topLevelVar = "" | ||
|
||
val String.bar get() = "top" | ||
val Foo.baz get() = "top" | ||
|
||
class Foo { | ||
val memberVal = "" | ||
var memberVar = "" | ||
|
||
val bar = "member" | ||
private val baz = "member" | ||
|
||
companion object { | ||
fun referenceToMemberBaz() = Foo::baz | ||
} | ||
} | ||
|
||
fun box(): String { | ||
checkEqual(::topLevelVal, ::topLevelVal) | ||
checkEqual(::topLevelVar, ::topLevelVar) | ||
checkEqual(::topLevelVal, referenceTopLevelValFromOtherFile()) | ||
checkEqual(::topLevelVar, referenceTopLevelVarFromOtherFile()) | ||
|
||
checkEqual(Foo::memberVal, Foo::memberVal) | ||
checkEqual(Foo::memberVar, Foo::memberVar) | ||
checkEqual(Foo::memberVal, referenceMemberValFromOtherFile()) | ||
checkEqual(Foo::memberVar, referenceMemberVarFromOtherFile()) | ||
|
||
checkNotEqual(String::bar, Foo::bar) | ||
assertEquals("top", String::bar.get("")) | ||
assertEquals("member", Foo::bar.get(Foo())) | ||
|
||
checkNotEqual(Foo::baz, Foo.referenceToMemberBaz()) | ||
assertEquals("top", Foo::baz.get(Foo())) | ||
assertEquals("member", Foo.referenceToMemberBaz().get(Foo())) | ||
|
||
return "OK" | ||
} | ||
|
||
fun checkEqual(x: Any, y: Any) { | ||
if (x != y || y != x) throw AssertionError("$x and $y should be equal") | ||
if (x.hashCode() != y.hashCode()) throw AssertionError("$x and $y should have the same hash code") | ||
} | ||
|
||
fun checkNotEqual(x: Any, y: Any) { | ||
if (x == y || y == x) throw AssertionError("$x and $y should NOT be equal") | ||
} | ||
|
||
// FILE: otherFile.kt | ||
|
||
fun referenceTopLevelValFromOtherFile() = ::topLevelVal | ||
fun referenceTopLevelVarFromOtherFile() = ::topLevelVar | ||
fun referenceMemberValFromOtherFile() = Foo::memberVal | ||
fun referenceMemberVarFromOtherFile() = Foo::memberVar | ||
|
40 changes: 40 additions & 0 deletions
40
compiler/testData/codegen/box/callableReference/equality/kpropertyWithCapturingEquality.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// IGNORE_BACKEND: WASM | ||
// WASM_MUTE_REASON: FAILS_IN_JS_IR | ||
// IGNORE_BACKEND: JS, JS_IR | ||
// IGNORE_BACKEND: JS_IR_ES6 | ||
// FILE: test.kt | ||
|
||
val topLevelVal = "" | ||
var topLevelVar = "" | ||
|
||
class Foo { | ||
val memberVal = "" | ||
var memberVar = "" | ||
} | ||
|
||
fun box(): String { | ||
val foo0 = Foo() | ||
val foo1 = Foo() | ||
|
||
checkEqual(foo0::memberVal, foo0::memberVal) | ||
checkEqual(foo0::memberVal, referenceMemberValFromOtherFile(foo0)) | ||
checkEqual(foo0::memberVar, foo0::memberVar) | ||
checkEqual(foo0::memberVar, referenceMemberVarFromOtherFile(foo0)) | ||
|
||
return "OK" | ||
} | ||
|
||
fun checkEqual(x: Any, y: Any) { | ||
if (x != y || y != x) throw AssertionError("$x and $y should be equal") | ||
if (x.hashCode() != y.hashCode()) throw AssertionError("$x and $y should have the same hash code") | ||
} | ||
|
||
fun checkNotEqual(x: Any, y: Any) { | ||
if (x == y || y == x) throw AssertionError("$x and $y should NOT be equal") | ||
} | ||
|
||
// FILE: otherFile.kt | ||
|
||
fun referenceMemberValFromOtherFile(foo: Foo) = foo::memberVal | ||
fun referenceMemberVarFromOtherFile(foo: Foo) = foo::memberVar | ||
|
31 changes: 31 additions & 0 deletions
31
compiler/testData/codegen/box/callableReference/equality/kpropertyWithCapturingInequality.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// IGNORE_BACKEND: JS | ||
// FILE: test.kt | ||
|
||
val topLevelVal = "" | ||
var topLevelVar = "" | ||
|
||
class Foo { | ||
val memberVal = "" | ||
var memberVar = "" | ||
} | ||
|
||
fun box(): String { | ||
val foo0 = Foo() | ||
val foo1 = Foo() | ||
|
||
checkNotEqual(foo0::memberVal, Foo::memberVal) | ||
checkNotEqual(foo0::memberVal, foo1::memberVal) | ||
checkNotEqual(foo0::memberVar, Foo::memberVar) | ||
checkNotEqual(foo0::memberVar, foo1::memberVar) | ||
|
||
return "OK" | ||
} | ||
|
||
fun checkEqual(x: Any, y: Any) { | ||
if (x != y || y != x) throw AssertionError("$x and $y should be equal") | ||
if (x.hashCode() != y.hashCode()) throw AssertionError("$x and $y should have the same hash code") | ||
} | ||
|
||
fun checkNotEqual(x: Any, y: Any) { | ||
if (x == y || y == x) throw AssertionError("$x and $y should NOT be equal") | ||
} |
Oops, something went wrong.