我试图让Room(https://developer.android.com/topic/libraries/architecture/room)与Kotlin的内联类一起工作,如Jake Whartons文章内联类使数据库ID大:
@Entity
data class MyEntity(
    @PrimaryKey val id: ID,
    val title: String
)
inline class ID(val value: String)编译此房间时抱怨
实体和Pojos必须具有可用的公共构造函数。您可以有一个空的构造函数或一个其参数与字段匹配的构造函数(按名称和类型)。
查看生成的Java代码,我发现:
private MyEntity(String id, String title) {
      this.id = id;
      this.title = title;
}
// $FF: synthetic method
public MyEntity(String id, String title, DefaultConstructorMarker $constructor_marker) {
      this(id, title);
}奇怪的是,默认构造函数现在是私有的。
当String用作id(或typealias)的类型时,生成的Java类构造函数看起来像预期的那样:
public MyEntity(@NotNull String id, @NotNull String title) {
  Intrinsics.checkParameterIsNotNull(id, "id");
  Intrinsics.checkParameterIsNotNull(title, "title");
  super();
  this.id = id;
  this.title = title;
}现在有人在将内联类用作数据实体属性时如何使默认构造函数公开吗?
                  您是否在某个问题跟踪器上为此提出了问题?我猜想这需要确定
                
                
                  
                    —
                    -K.Os,