From 744db5c5a111d68c30302deae8b4ba1ea9355603 Mon Sep 17 00:00:00 2001 From: Yigit Boyar Date: Thu, 21 Dec 2017 10:00:25 -0800 Subject: Fix kotlin.Unit method references in binding layouts. When there is a binding adapter that receives a kotlin function which does not return, Kotlin converts it to Function0. But if there is a kotlin class with a method that does not return value, kotlin converts it to void. This becomes a problem for data binding because it cannot match the two when using function references. We cannot simply convert kotlin.Unit to void because we still generate code in java so we have to return a value in the implementation. Instead, this CL changes function matcher to accept the two as equals and also changes the code generators to handle the case manually. Also added a kotlin test app (finally). Bug: 70915745 Bug: 78662035 Test: KotlinTestApp Change-Id: I019ee7eb1dd635b12efd7725ccc22f0c63dc2d72 --- .../src/main/java/android/databinding/tool/reflection/ModelClass.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'compiler/src/main/java/android/databinding/tool/reflection') diff --git a/compiler/src/main/java/android/databinding/tool/reflection/ModelClass.java b/compiler/src/main/java/android/databinding/tool/reflection/ModelClass.java index 10218782..557ad25a 100644 --- a/compiler/src/main/java/android/databinding/tool/reflection/ModelClass.java +++ b/compiler/src/main/java/android/databinding/tool/reflection/ModelClass.java @@ -698,4 +698,8 @@ public abstract class ModelClass { } return false; } + + public boolean isKotlinUnit() { + return "kotlin.Unit".equals(getTypeName().toString()); + } } -- cgit v1.2.3