继承冲突

    1. abstract class A{
    2. open fun x(): Int = 5
    3. }
    4. interface B{
    5. fun x(): Int = 1
    6. }
    7. interface C{
    8. fun x(): Int = 0
    9. }
    10. class D(var y: Int = 0): A(), B, C{
    11. override fun x(): Int {
    12. println("call x(): Int in D")
    13. if(y > 0){
    14. return y
    15. }else if(y < -200){
    16. return super<C>.x()
    17. }else if(y < -100){
    18. return super<B>.x()
    19. }else{
    20. return super<A>.x()
    21. }
    22. }
    23. }
    24. fun main(args: Array<String>) {
    25. println(D(3).x())
    26. println(D(-10).x())
    27. println(D(-110).x())
    28. println(D(-10000).x())
    29. }