Android Extensions: Fix compilation when LayoutContainer is used as an interface (KT-19753)
This commit is contained in:
committed by
Yan Zhulanow
parent
eefb490a8a
commit
3f4ddb006a
+2
-1
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.android.synthetic.codegen
|
package org.jetbrains.kotlin.android.synthetic.codegen
|
||||||
|
|
||||||
import kotlinx.android.extensions.CacheImplementation
|
import kotlinx.android.extensions.CacheImplementation
|
||||||
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
import org.jetbrains.kotlin.android.synthetic.AndroidConst
|
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.shouldCacheResource
|
||||||
import org.jetbrains.kotlin.android.synthetic.codegen.AbstractAndroidExtensionsExpressionCodegenExtension.Companion.CACHED_FIND_VIEW_BY_ID_METHOD_NAME
|
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 -> {
|
AndroidContainerType.LAYOUT_CONTAINER -> {
|
||||||
receiver.put(Type.getType("L${containerType.internalClassName};"), v)
|
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)
|
getResourceId(v)
|
||||||
v.invokevirtual("android/view/View", "findViewById", "(I)Landroid/view/View;", false)
|
v.invokevirtual("android/view/View", "findViewById", "(I)Landroid/view/View;", false)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -34,7 +34,7 @@ class ContainerOptionsProxy(val containerType: AndroidContainerType, val cache:
|
|||||||
private val CACHE_NAME = ContainerOptions::cache.name
|
private val CACHE_NAME = ContainerOptions::cache.name
|
||||||
|
|
||||||
fun create(container: ClassDescriptor): ContainerOptionsProxy {
|
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)
|
return ContainerOptionsProxy(AndroidContainerType.UNKNOWN, NO_CACHE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,10 @@ class ContainerOptionsProxy(val containerType: AndroidContainerType, val cache:
|
|||||||
|
|
||||||
if (anno == null) {
|
if (anno == null) {
|
||||||
// Java classes (and Kotlin classes from other modules) does not support cache by default
|
// 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(
|
return ContainerOptionsProxy(
|
||||||
containerType,
|
containerType,
|
||||||
if (supportsCache) null else NO_CACHE) // `null` here means "use global cache implementation setting"
|
if (supportsCache) null else NO_CACHE) // `null` here means "use global cache implementation setting"
|
||||||
|
|||||||
Vendored
+5
-1
@@ -26,8 +26,12 @@ class MyActivity(): Activity() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
val entity2: LayoutContainer = entity
|
||||||
|
|
||||||
public fun box(): String {
|
public fun box(): String {
|
||||||
return if (entity.login.toString() == "Button") "OK" else ""
|
val o = if (entity.login.toString() == "Button") "O" else ""
|
||||||
|
val k = if (entity2.login.toString() == "Button") "K" else ""
|
||||||
|
return o + k // "OK"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user