Kotlinx从错误的布局注入视图

我有一段代码检查视图是否可见

import kotlinx.android.synthetic.main.activity_layout.* val isOverflowPanelShown: Boolean get() = overflow_panel.visibility != View.GONE 

以前的代码会抛出exception

 java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.widget.ScrollView at com.company.app.Activity.isOverflowPanelShown(Activity.kt:362) 

该视图是ScrollView类的实例,但是kotlin认为它是一个FrameLayout 。 调用findViewById()在相同的地方作为错误被抛出正确返回ScrollView。 我发现在应用程序的不同布局中, 在相同的ID下有一个FrameLayout

我正在充气下面的布局

activity_layout

  

在另一个布局中,我使用完全不同的地方,有一个不同的视图,具有相同的ID。

form_component_main

  

为什么不给他们不同的ID?

 overflow_panel_scroll overflow_panel_frame 

或者是对他们实际做什么更具描述性。

更新:多一点解释,因为这个投票。 ID应该是唯一的。

Android文档说,如果ID不是唯一的,那么可能会有冲突: An ID need not be unique throughout the entire tree, but it should be unique within the part of the tree you are searching (which may often be the entire tree, so it's best to be completely unique when possible). (来自http://developer.android.com/guide/topics/ui/declaring-layout.html )

Kotlin合成产品是由IntelliJ插件生成的。 没有这些ID是唯一的,看起来这个插件目前不能正确匹配ID到正确的视图。 它可能期望唯一的ID。