[FIR] KT-58460: Report a return type mismatch diagnostic
^KT-58460 Fixed
This commit is contained in:
committed by
Space Team
parent
ff61f70dd0
commit
c0ce37a271
+10
@@ -86,6 +86,16 @@ object FirFunctionReturnTypeMismatchChecker : FirReturnExpressionChecker() {
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if (resultExpression.source?.kind == KtFakeSourceElementKind.ImplicitUnit && !functionReturnType.isUnit) {
|
||||
reporter.reportOn(
|
||||
resultExpression.source,
|
||||
RETURN_TYPE_MISMATCH,
|
||||
functionReturnType,
|
||||
returnExpressionType,
|
||||
targetElement,
|
||||
false,
|
||||
context
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ fun unitEmpty() : Unit {}
|
||||
fun unitEmptyReturn() : Unit {return}
|
||||
fun unitIntReturn() : Unit {return <!RETURN_TYPE_MISMATCH!>1<!>}
|
||||
fun unitUnitReturn() : Unit {return Unit}
|
||||
fun test1() : Any = {<!RETURN_NOT_ALLOWED!>return<!>}
|
||||
fun test1() : Any = {<!RETURN_NOT_ALLOWED, RETURN_TYPE_MISMATCH!>return<!>}
|
||||
fun test2() : Any = a@ {return@a 1}
|
||||
fun test3() : Any { return }
|
||||
fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> }
|
||||
fun test4(): ()-> Unit = { <!RETURN_NOT_ALLOWED, RETURN_TYPE_MISMATCH!>return@test4<!> }
|
||||
fun test5(): Any = l@{ return@l }
|
||||
fun test6(): Any = {<!RETURN_NOT_ALLOWED!>return<!> 1}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
// ISSUE: KT-58460
|
||||
|
||||
fun someFunction() : Any {
|
||||
return
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-58460
|
||||
|
||||
fun someFunction() : Any {
|
||||
|
||||
Reference in New Issue
Block a user