实际typealias' applicationContext'没有相应的预期声明
我在尝试为 kotlin 多平台
Actual typealias 'ApplicationContext' has no corresponding expected declaration
The following declaration is incompatible because modality is different:
public final expect class ApplicationContext
androidMain
import android.app.Application
actual typealias ApplicationContext = Application
commonMain
expect class ApplicationContext
iosMain
import platform.UIKit.UIView
actual typealias ApplicationContext = UIView
I got this issue when trying to custom context for kotlin multiplatform
Actual typealias 'ApplicationContext' has no corresponding expected declaration
The following declaration is incompatible because modality is different:
public final expect class ApplicationContext
androidMain
import android.app.Application
actual typealias ApplicationContext = Application
commonMain
expect class ApplicationContext
iosMain
import platform.UIKit.UIView
actual typealias ApplicationContext = UIView
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
期望
类结构应与您要打字的类匹配。Android的
上下文
类是摘要
类,因此模态错误来自那里。
您可能需要
期望
类是摘要
,以解决该特定错误abract>摘要将破坏
uiview 不是
摘要
。因此,您要做的事情是直接的。您需要考虑要实现目标的不同策略。
The
expect
class structure should match the class you're typealiasing to.Android's
context
class is anabstract
classSo the modality error comes from there.
You would need the
expect
class to beabstract
as well to fix that particular errorMaking it
abstract
would break modality forUIView
as it's notabstract
. So what you're trying to do is not possible in a straightforward manner.You would need to think about a different strategy for what you're trying to achieve.