I can't find a solution to this problem
data class Data(val s: String)
sealed class Base<T>(val t: T, val f: Base<T>.() -> Unit)
class A(data: Data, f: A.() -> Unit) : Base<Data>(data, f)
Type mismatch.Required:Base<Data>.() → Unit Found: A.() → Unit
Please tell me what should be the correct usage
The problem has nothing to do with sealed classes, and nothing to do with generics. It is the same problem as the following:
As you can see from the above simplification of your problem, the reason for the error is that you can't pass a
Subclass.() -> Unitblock to something that expects aBase.() -> Unitblock. If it were possible, then you would be able to callfdwith a block that acts on anIntbutfbpasses it aBigDecimalinstead. So you need to change your class A to: