JVM_IR KT-44744 check accessibility of enum entry 'this'
This commit is contained in:
committed by
TeamCityServer
parent
14cb762133
commit
e630e00e99
+22
@@ -0,0 +1,22 @@
|
||||
enum class ContentType {
|
||||
|
||||
PLAIN_TEXT {
|
||||
override fun convert(text: String, targetType: ContentType): String {
|
||||
return text
|
||||
}
|
||||
},
|
||||
|
||||
MARKDOWN {
|
||||
override fun convert(text: String, targetType: ContentType): String {
|
||||
return when (targetType) {
|
||||
MARKDOWN -> text
|
||||
PLAIN_TEXT -> ""
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
abstract fun convert(text: String, targetType: ContentType): String
|
||||
}
|
||||
|
||||
fun box() =
|
||||
ContentType.PLAIN_TEXT.convert("OK", ContentType.PLAIN_TEXT)
|
||||
@@ -0,0 +1,27 @@
|
||||
interface IFoo {
|
||||
fun foo(e: En): String
|
||||
}
|
||||
|
||||
enum class En {
|
||||
TEST {
|
||||
inner class Nested : IFoo {
|
||||
private val ee = TEST
|
||||
|
||||
override fun foo(e: En): String {
|
||||
return if (e == ee) e.ok else "Failed"
|
||||
}
|
||||
}
|
||||
|
||||
override val ok: String get() = "OK"
|
||||
override fun foo(): IFoo = Nested()
|
||||
},
|
||||
OTHER {
|
||||
override val ok: String get() = throw AssertionError()
|
||||
override fun foo(): IFoo = throw AssertionError()
|
||||
};
|
||||
|
||||
abstract val ok: String
|
||||
abstract fun foo(): IFoo
|
||||
}
|
||||
|
||||
fun box() = En.TEST.foo().foo(En.TEST)
|
||||
Reference in New Issue
Block a user