Closed PkmX closed 8 years ago
Thanks for reporting. I didn't know about this issue.
org.scaloid.common.Logger.debug
gets => String
as a parameter. Normally, passing Int
value (e.g. debug(1)
) should not be passed it to Scaloid debug function. However, that Int
value is implicitly converted by ResourceConversion.r2String
. Definitely, it is a problem. Excessively converting Int
to other resource type would cause confusions like this situation. I am consider reimplementing ConversionImplicits.Int2resource
with macros to distinguish the Int
number is a resource ID or not (e.g. resource IDs has R.
on its parameter names). I am not sure it is possible, because I am not Scala macro expert. Any other suggestions are welcome.
I was misunderstood the problem. I thought ViewGroup.debug
is shadowed by scaloid.common.debug
.
But, the actual problem is the opposite case. This is relatively easy. Use r2String
to explicitly convert a resource id to the corresponding String resource.
debug(R.string.mystr.r2String) \\ will call org.scaloid.common.debug
Converting to String
would not work as org.scaloid.common.debug
is still shadowed by ViewGroup.debug
, so it is not considered for overloading at all. It will just give an error saying that it is given a String
while expecting an Int
. The issue only arise when we define UI with anonymous classes (new SLinearLayout { ... }
, etc), which brings ViewGroup.debug
into scope in the body as it is protected
.
I added an overloading function on TraitViewGroup
.
def debug(str: String)(implicit tag: LoggerTag)
This causes inconveniences when calling
debug
to write strings to logcat in the DSL, as we will have to qualify theorg.scaloid.common.debug
.