Files
kotlin/compiler/testData/writeFlags/protectedAccessToBaseMethodDifferentPackage.kt
Kristoffer Andersen 6f8682c950 [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.
2019-12-02 08:19:52 +01:00

38 lines
885 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// FILE: Base.java
public class Base {
protected static String BASE_ONLY = "BASE";
protected static String baseOnly() {
return BASE_ONLY;
}
public static class Derived extends Base {
}
}
// FILE: Kotlin.kt
package differentPackage;
import Base.Derived
import Base
class Kotlin : Base.Derived() {
fun doTest(): String {
if ({ Base.baseOnly() }() != "BASE") return "fail 8"
if ({ baseOnly() }() != "BASE") return "fail 10"
return "FAIL"
}
}
// TESTED_OBJECT_KIND: function
// TESTED_OBJECTS: differentPackage/Kotlin, access$baseOnly$s2063089
// FLAGS: ACC_PUBLIC, ACC_STATIC, ACC_FINAL, ACC_SYNTHETIC
// TESTED_OBJECT_KIND: function
// TESTED_OBJECTS: differentPackage/Kotlin, access$baseOnly$s-1074188803
// FLAGS: ACC_PUBLIC, ACC_STATIC, ACC_FINAL, ACC_SYNTHETIC