IR/Android: place the cache field first
to avoid NPEs if it is used during instance initialization.
This commit is contained in:
+2
-1
@@ -201,7 +201,8 @@ private class AndroidIrTransformer(val extension: AndroidIrExtension, val plugin
|
||||
return super.visitClassNew(declaration)
|
||||
|
||||
if ((containerOptions.cache ?: extension.getGlobalCacheImpl(declaration)).hasCache) {
|
||||
declaration.declarations += declaration.getCacheField()
|
||||
// Place the field first so that it is initialized before any init blocks.
|
||||
declaration.declarations.add(0, declaration.getCacheField())
|
||||
declaration.declarations += declaration.getClearCacheFun()
|
||||
declaration.declarations += declaration.getCachedFindViewByIdFun()
|
||||
}
|
||||
|
||||
Vendored
+3
-1
@@ -33,9 +33,11 @@ class MyActivity(): Activity() {
|
||||
} as T?
|
||||
}
|
||||
|
||||
private val textViewString = textView1.toString()
|
||||
|
||||
public fun box(): String {
|
||||
val result = when {
|
||||
textView1.toString() == "TextView" && password.toString() == "EditText" && login.toString() == "Button" -> "OK"
|
||||
textViewString == "TextView" && password.toString() == "EditText" && login.toString() == "Button" -> "OK"
|
||||
else -> ""
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user