Tests for abstract functions with default arguments
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
abstract class Base {
|
||||
abstract fun foo(a: String = "abc"): String
|
||||
}
|
||||
|
||||
class Derived: Base() {
|
||||
override fun foo(a: String): String {
|
||||
return a
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = Derived().foo()
|
||||
if (result != "abc") return "Fail: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
trait Base {
|
||||
fun bar(a: String = "abc"): String = a + " from trait"
|
||||
}
|
||||
|
||||
class Derived: Base {
|
||||
override fun bar(a: String): String = a + " from class"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = Derived().bar()
|
||||
if (result != "abc from class") return "Fail: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user