I am converting a Java Android project to Kotlin.
I use the API.AI client , which has two classes AIConfiguration:
Super class
package ai.api;
public class AIConfiguration implements Cloneable {
public static enum SupportedLanguages {
English("en"),
}
}
Subclass
package ai.api.android;
public class AIConfiguration extends ai.api.AIConfiguration {
public enum RecognitionEngine {
}
In my Java code, I created an instance of a subclass, as recommended in the api manual:
final AIConfiguration config = new AIConfiguration("TOKEN",
AIConfiguration.SupportedLanguages.English,
AIConfiguration.RecognitionEngine.System);
After converting to Kotlin, it looks like this:
val config = AIConfiguration("TOKEN",
AIConfiguration.SupportedLanguages.English,
AIConfiguration.RecognitionEngine.System)
... which causes . Unresolved reference: SupportedLanguages
- I can update the link to
ai.api.AIConfiguration.SupportedLanguages.Englishthat compiles successfully. - I can import the superclass with
import ai.api.AIConfiguration as SuperAIConfigurationand use SuperAIConfiguration.SupportedLanguages, but I would rather refer to the enumeration directly to the subclass.
I do not understand: why is this link valid in Java, but not in Kotlin?
source
share