【发布时间】:2019-10-19 02:47:35
【问题描述】:
我在FirebaseUserAuth 类中有两个构造函数,它给出了一个错误:声明具有相同的 java 签名。构造函数的参数不同。为什么它给出相同的签名错误?
如何解决?
class FirebaseUserAuth(private val auth: FirebaseAuth,
private val loginCallBack: ((LoginAuthData) -> Unit)?,
private val registerVM_CallBack: ((RegisterAuthData) -> Unit)?)
{
constructor(auth: FirebaseAuth, loginCallBack: (LoginAuthData) -> Unit): this(auth, loginCallBack, null)
constructor(auth: FirebaseAuth, registerCallBack: (RegisterAuthData) -> Unit): this(auth, null, registerCallBack)
}
错误
> Platform declaration clash:The following declarations have the same JVM
> signature (Lcom/google/fireBase/auth/FirebaseAuth;Lkotlin/jvm/
> functions/Function1;)V):
>
> • public constructor FirebaseUserAuth(auth: FirebaseAuth,
> loginCallBack: (LoginAuthData) -> Unit) defined.
> com.examgle.data.FirebaseUserAuth
>
> • public constructor FirebaseUserAuth(auth: FirebaseAuth,
> registerCallBack: (RegisterAuthData) -> Unit) defined.
> com.examgle.data.FirebaseUserAuth
【问题讨论】:
-
使用具有泛型函数参数的单个构造函数..
-
@ADM 谢谢!!!我使用了通用类型及其工作
标签: android kotlin higher-order-functions constructor-overloading multiple-constructors