Files
kotlin-fork/compiler/testData/diagnostics/tests/inline/unsupportedConstruction.kt
T
Svetlana Isakova 9d366cb896 Prohibit local objects and enum classes
#KT-5402 Fixed
  #KT-4838 Fixed

Resolve type of object inside local object as special, not supertype('Any').
Changed visibility of constructor of anonymous object to 'internal' to be able to resolve the following:
fun box(): String {
    var foo = object {
        val bar = object {
            val baz = "ok"
        }
    }
    return foo.bar.baz
}
The containing declaration of property initializers is constructor, so 'baz' was invisible inside private constructor.
2014-09-01 12:32:52 +04:00

32 lines
678 B
Kotlin

// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline fun unsupported() {
<!NOT_YET_SUPPORTED_IN_INLINE!>class A {
fun a() {
class AInner {}
}
}<!>
<!LOCAL_OBJECT_NOT_ALLOWED!>object B<!>{
<!LOCAL_OBJECT_NOT_ALLOWED!>object BInner<!> {}
}
<!NOT_YET_SUPPORTED_IN_INLINE!>fun local() {
fun localInner() {}
}<!>
}
inline fun unsupportedDefault(<!NOT_YET_SUPPORTED_IN_INLINE!>s : ()->Unit = {}<!>) {
}
open class Base {
open fun foo(a: Int = 1) {}
}
class Derived: Base() {
inline final override fun foo(<!NOT_YET_SUPPORTED_IN_INLINE!>a: Int<!>) {
}
}