所遇问题
今天在 IDEA 调试代码时,遇到了一个问题,IDEA 编写时代码也没有标红报错,但运行和编译后,都会失败,并报错:
Kotlin: [Internal Error] org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
我的部分代码如下:
fun main() {
}
class Solution {
if (word == "") {
return true
}
if (board.size == 0 || board[0].size == 0) {
return false
}
for (x in 0..board.size - 1) {
for (y in 0..board[0].size - 1) {
if (board[x][y] == word.get(0)) {
if (exist(board, word, 0, Array(board.size){BooleanArray(board[0].size, return false)}, x, y)) { return true }
}
}
}
return false
}
fun exist(board: Array<CharArray>, word: String, index : Int, hasInclude : Array<BooleanArray>, x : Int, y : Int) : Boolean {
if (index == word.length) {
return true
}
if (x < 0 || x >= board.size || y < 0 || y >= board[0].size || hasInclude[x][y]) {
return false
}
if (board[x][y] == word.get(index)) {
hasInclude[x][y] = true
val ans = exist(board, word, index + 1, hasInclude, x + 1, y) || exist(board, word, index + 1, hasInclude, x - 1, y) || exist(board, word, index + 1, hasInclude, x, y + 1) || exist(board, word, index + 1, hasInclude, x, y - 1)
hasInclude[x][y] = false
return ans
}
return false
}
}
解决问题
问题出在函数式接口的使用错误(楼主不会使用函数式子,但猜着写了,同时 IDEA 没有报错,还以为自己写对了。。。运行报错也不是报的这里代码书写有误。。。),**错误如下所示:**
修改示例:
|