Compiler seems to fail to infer a type based on the inference of another type. IntelliJ IDEA handles this fine. Example:
object InterfaceParser {
fun parseInterfaces(dataInput: DataInputStream): Array<ConstantPoolReference<ClassConstant>> {
val numInterfaces = dataInput.u2()
return Array(numInterfaces) {
ConstantPoolReference(dataInput.u2())
}
}
}
No errors are shown in intellij, which correctly inferes the generic type of ConstantPoolReference.
Compiler throws error:
e: InterfaceParser.kt: (12, 4): Type inference failed: Not enough information to infer parameter T in constructor ConstantPoolReference<T : Constant>(index: Int)
Please specify it explicitly.
Expected behaviour:
Since the method returns an array of constant pool references of type classconstant, in the array constructor the compiler should infer that the constant pool reference should have generic type classconstant.