[JVM IR] Stabilize accesor names in IR Backend
- introduce a scoped counter instead of a global one for name
generation for accessors. Naive solution not working.
- Introduced hardcoded "jd" suffix for accessors on interfaces, under
the assumption that the only such accessors are due to JvmDefault
and their bridges from `$DefaultImpls`. Removed all associated
templated tests, so the old and IR backend correspond on this matter
again.
- Respecialized writeFlags from regexps to string-equality: we are
going for exact matches now!
- Fixed package calculation in `IrUtils.kt`.
- Accessors for static members must be due to accessing super
classes. Actual super-qualified calls are naturally also accessing
super classes. Hence the `$s+{hashcode(superClassName)}`
suffix. Added test to affirm this naming scheme.
- Field getters/setters for static fields must be companion accessors,
otherwise just labelled as accessors. They are also tagged with `s`
suffix when accessing static fields.
- For naming of accessors to coincide with the old backend, field
renaming to avoid JVM signature clashes must be done _after_
generation of accessors for those fields.
This commit is contained in:
committed by
max-kammerer
parent
d1c2862e27
commit
6f8682c950
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// Checks that methods 'access$getMy$p' and 'getMy' are not generated and
|
||||
// that backed field 'my' is accessed through 'access$getMy$cp'
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// Checks that accessor methods are always used due to the overriding of the default setter of 'my' property.
|
||||
|
||||
class My {
|
||||
@@ -19,11 +18,17 @@ class My {
|
||||
// GETSTATIC My.my into 'access$getMy$cp'
|
||||
}
|
||||
|
||||
// 2 GETSTATIC My.my
|
||||
// 2 PUTSTATIC My.my
|
||||
// 0 INVOKESTATIC My\$Companion.access\$getMy\$p
|
||||
// 1 INVOKESTATIC My\$Companion.access\$setMy\$p
|
||||
// 1 INVOKESTATIC My.access\$setMy\$cp
|
||||
// 1 INVOKESPECIAL My\$Companion.setMy
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 2 GETSTATIC My.my
|
||||
// 1 INVOKESTATIC My\$Companion.access\$setMy\$p
|
||||
// 1 INVOKESTATIC My.access\$getMy\$cp
|
||||
// 1 INVOKESPECIAL My\$Companion.getMy
|
||||
// 1 INVOKESPECIAL My\$Companion.setMy
|
||||
|
||||
// IR only generates the accessors actually needed
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 GETSTATIC My.my
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// Checks that accessor 'I$Companion.access$getBar\$p' is always used because the property is kept
|
||||
// into the companion object.
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ interface KInterface {
|
||||
}
|
||||
}
|
||||
|
||||
// 1 INVOKESTATIC KInterface.access\$test\$
|
||||
// 1 INVOKESTATIC KInterface.access\$test\$jd
|
||||
// 1 INVOKESTATIC KInterface.test\$default
|
||||
|
||||
// from $default
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ interface KInterface2 : KInterface {
|
||||
|
||||
}
|
||||
|
||||
// 1 INVOKESTATIC KInterface2.access\$test2\$
|
||||
// 1 INVOKESTATIC KInterface.access\$test2\$
|
||||
// 1 INVOKESTATIC KInterface2.access\$test2\$jd
|
||||
// 1 INVOKESTATIC KInterface.access\$test2\$jd
|
||||
|
||||
// 1 INVOKESPECIAL KInterface2.test2
|
||||
// 1 INVOKESPECIAL KInterface.test2
|
||||
|
||||
+6
-6
@@ -13,11 +13,11 @@ interface KInterface2 : KInterface {
|
||||
abstract override fun test2(): String
|
||||
}
|
||||
|
||||
// 1 INVOKESTATIC KInterface.access\$test2\$jd
|
||||
// +
|
||||
// 0 INVOKESTATIC KInterface2.access\$test2\$jd
|
||||
// =
|
||||
// 1 INVOKESTATIC KInterface
|
||||
|
||||
// 1 INVOKESPECIAL KInterface.test2
|
||||
// 0 INVOKESPECIAL KInterface2.test2
|
||||
|
||||
// 1 INVOKESTATIC KInterface.access\$test2\$
|
||||
// +
|
||||
// 0 INVOKESTATIC KInterface2.access\$test2\$
|
||||
// =
|
||||
// 1 INVOKESTATIC KInterface
|
||||
+4
-4
@@ -13,10 +13,10 @@ interface KInterface2 : KInterface {
|
||||
|
||||
}
|
||||
|
||||
// 1 INVOKESTATIC KInterface2.access\$getBar\$
|
||||
// 1 INVOKESTATIC KInterface2.access\$setBar\$
|
||||
// 1 INVOKESTATIC KInterface.access\$getBar\$
|
||||
// 1 INVOKESTATIC KInterface.access\$setBar\$
|
||||
// 1 INVOKESTATIC KInterface2.access\$getBar\$jd
|
||||
// 1 INVOKESTATIC KInterface2.access\$setBar\$jd
|
||||
// 1 INVOKESTATIC KInterface.access\$getBar\$jd
|
||||
// 1 INVOKESTATIC KInterface.access\$setBar\$jd
|
||||
|
||||
// 1 INVOKESPECIAL KInterface2.getBar
|
||||
// 1 INVOKESPECIAL KInterface2.setBar
|
||||
|
||||
Reference in New Issue
Block a user