Android Kotlin - Classifier 'Activity' 没有伴随对象,因此必须在这里初始化

Android Kotlin - Classifier 'Activity' does not have a companion object, and thus must be initialized here

        var acct = Activity

        when {
            activityName.contains("MainActivity", true) -> {
                acct = (context as MainActivity)

            }
            activityName.contains("UserMemes", true) -> {
                acct = (context as UserMemes)

            }
            activityName.contains("SearchShow", true) -> {
                acct = (context as SearchShow)

            }
        }

        acct.memeIdAndLastPos[meme.id] = scrollY

Classifier 'Activity' does not have a companion object, and thus must be initialized hereActivity

当我改为 Activity() 时错误消失,但我不能再使用 memeIdAndLastPos

如何修复?

val acct: Activity = when { 
  activityName.contains("MainActivity", true) ->  context as MainActivity
  activityName.contains("UserMemes", true) ->  context as UserMemes
  activityName.contains("SearchShow", true) -> context as SearchShow  
}

acct.memeIdAndLastPos[meme.id] = scrollY