Don't use reflection in JetType.getCapability

This commit is contained in:
Alexander Udalov
2015-06-05 19:07:24 +03:00
parent d4c18b3d55
commit 5394abc83e
6 changed files with 46 additions and 28 deletions
@@ -300,10 +300,11 @@ class LazyJavaTypeResolver(
override val id: String get() = "kotlin.jvm.PlatformType"
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>, jetType: JetType, flexibility: Flexibility): T? {
if (capabilityClass.isAssignableFrom(javaClass<Impl>()))
[suppress("UNCHECKED_CAST")]
return Impl(flexibility) as T
else return null
@suppress("UNCHECKED_CAST")
return when (capabilityClass) {
javaClass<CustomTypeVariable>(), javaClass<Specificity>() -> Impl(flexibility) as T
else -> null
}
}