Gat Tag
04/06/2024, 4:46 AMConeClassLikeType
that has been created within a session and an array of type arguments.
parent.declarationSymbols.filterIsInstance<FirPropertySymbol>().forEach {
valueParameter(it.name, {typeArgs ->
val type = parent.classId.createConeType(
session,
typeArgs.map { it.symbol.toConeType() }.toTypedArray(),
nullable = false
)
type.createConeTypeOfMember(session, it.name) // <<<----------- Ideally I want something like the following
})
}
If you are wondering what I am trying to accomplish, I would like it so that an interface will automatically have a companion object with an invoke
function that has a parameter for every val
property it or it's super types declare and then returns an instance of the interface. I am struggling to get the types of properties that are constrained by generics to be constrained by the invoke
function's corresponding type parameters.
Such that the following:
interface Foo<V>{
val foo: List<V>
}
interface Bar<T>: Foo<Set<T>>{
val bar: T
val tan: Int
}
Will result in:
interface Foo<V>{
companion object{
operator fun <V> invoke(foo: List<V>): Foo<V> = TODO()
}
val foo: List<V>
}
interface Bar<T>: Foo<Set<T>>{
companion object{
operator fun <T> invoke(bar: T, tan: Int, foo: List<Set<T>>): Bar<V> = TODO()
}
val bar: T
val tan: Int
}
Javier
04/06/2024, 8:02 AMsubstitutorByMap
Gat Tag
04/07/2024, 3:42 AM