Android Extensions: Fix compilation when LayoutContainer is used as an interface (KT-19753)

This commit is contained in:
Yan Zhulanow
2017-08-21 19:00:55 +03:00
committed by Yan Zhulanow
parent eefb490a8a
commit 3f4ddb006a
3 changed files with 12 additions and 4 deletions
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.android.synthetic.codegen
import kotlinx.android.extensions.CacheImplementation
import kotlinx.android.extensions.LayoutContainer
import org.jetbrains.kotlin.android.synthetic.AndroidConst
import org.jetbrains.kotlin.android.synthetic.codegen.AbstractAndroidExtensionsExpressionCodegenExtension.Companion.shouldCacheResource
import org.jetbrains.kotlin.android.synthetic.codegen.AbstractAndroidExtensionsExpressionCodegenExtension.Companion.CACHED_FIND_VIEW_BY_ID_METHOD_NAME
@@ -78,7 +79,7 @@ class ResourcePropertyStackValue(
}
AndroidContainerType.LAYOUT_CONTAINER -> {
receiver.put(Type.getType("L${containerType.internalClassName};"), v)
v.invokevirtual(containerType.internalClassName, "getEntityView", "()Landroid/view/View;", false)
v.invokeinterface(Type.getType(LayoutContainer::class.java).internalName, "getContainerView", "()Landroid/view/View;")
getResourceId(v)
v.invokevirtual("android/view/View", "findViewById", "(I)Landroid/view/View;", false)
}
@@ -34,7 +34,7 @@ class ContainerOptionsProxy(val containerType: AndroidContainerType, val cache:
private val CACHE_NAME = ContainerOptions::cache.name
fun create(container: ClassDescriptor): ContainerOptionsProxy {
if (container.kind != ClassKind.CLASS) {
if (container.kind != ClassKind.CLASS && container.kind != ClassKind.INTERFACE) {
return ContainerOptionsProxy(AndroidContainerType.UNKNOWN, NO_CACHE)
}
@@ -44,7 +44,10 @@ class ContainerOptionsProxy(val containerType: AndroidContainerType, val cache:
if (anno == null) {
// Java classes (and Kotlin classes from other modules) does not support cache by default
val supportsCache = container.source is KotlinSourceElement && containerType.doesSupportCache
val supportsCache = container.kind == ClassKind.CLASS
&& container.source is KotlinSourceElement
&& containerType.doesSupportCache
return ContainerOptionsProxy(
containerType,
if (supportsCache) null else NO_CACHE) // `null` here means "use global cache implementation setting"