https://kotlinlang.org logo
Title
a

andym

09/27/2019, 3:01 PM
I should mention this is using Kotlin-1.3.0
k

karelpeeters

09/27/2019, 3:04 PM
Can you post the code?
a

andym

09/27/2019, 3:17 PM
The class itself is just:
inline class LanguageCodeString(val code: String) {
    fun getDisplayName(context: Context): String =
            when {
                Languages.ENGLISH.equals(code, true) -> context.getString(R.string.english_info_label)
                Languages.FRENCH.equals(code, true) -> context.getString(R.string.french_info_label)
                else -> code
            }
}
The usage is:
val language: LanguageCodeString =
        someNullableString?.let { LanguageCodeString(it) }
                ?: LanguageCodeString("")

// ...

processStuff(arg1, arg2, arg3, language, arg4)

// ...

private fun processStuff(
        context: Context,
        arg1: String? = "",
        arg2: String? = "",
        arg3: String? = "",
        language: LanguageCodeString = LanguageCodeString(""),
        arg4: String? = ""
) {
    // ...
    formatted.add(language.getDisplayName(context))
}
Sorry, my mistake! The class is generated, with a member variable (String), but it’s never instantiated. The usages are Strings. Only static methods on the class are called, incude constructor-impl, which threw me off
localObject1 = someNullableString.getLanguage();
String str3;
if (localObject1 != null)
{
  str3 = LanguageCodeString.constructor-impl((String)localObject1);
  if (str3 != null) {}
}
else
{
  str3 = LanguageCodeString.constructor-impl("");
}
I saw the constructor call, but didn’t notice
str3
is a String
and that it’s actually a static method just named
constructor-impl()
to do the null check