Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.
This repository was archived by the owner on May 15, 2024. It is now read-only.

interface 注解遇到 operator 关键字生成错误 #18

@onXoot

Description

@onXoot

ktorm-ksp version: 1.0.0-RC3
ktorm version: 3.5.0

code

@org.ktorm.ksp.api.Table("test")
interface TestOperator: org.ktorm.entity.Entity<TestOperator> {
    @org.ktorm.ksp.api.PrimaryKey
    var id: Long
    var operator: String
}

自动生成的代码

@Suppress("FunctionName")
public fun TestOperator(id: Long? = undefined(), operator_: String = undefined()): TestOperator {
    val entity = Entity.create<TestOperator>()
    if (id !== undefined<Long?>()) {
        entity.id = id ?: error("`entity` should not be null.")
    }
    if (operator !== undefined<String>()) {
        entity.operator = operator
    }
    return entity
}

public fun TestOperator.copy(id: Long? = undefined(), operator_: String = undefined()):
        TestOperator {
    val entity = this.copy()
    if (id !== undefined<Long?>()) {
        entity.id = id ?: error("`entity` should not be null.")
    }
    if (operator !== undefined<String>()) {
        entity.operator = operator
    }
    return entity
}

operator 在参数上自动加了个下划线,但是下面使用的时候没加 导致编译失败

使用实体类形式可以编译成功

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions