[FIR] add RedundantReturnUnitTypeChecker
This commit is contained in:
committed by
Mikhail Glukhikh
parent
5c88b1e80a
commit
275ce16faa
+46
@@ -0,0 +1,46 @@
|
||||
class A {
|
||||
fun foo(): <!REDUNDANT_RETURN_UNIT_TYPE!>Unit<!>
|
||||
{
|
||||
}
|
||||
|
||||
fun bar(): <!REDUNDANT_RETURN_UNIT_TYPE!>Unit<!>
|
||||
{
|
||||
return Unit
|
||||
}
|
||||
|
||||
fun baz(): Unit = bar()
|
||||
|
||||
fun f1(): Int = 1
|
||||
|
||||
fun f2(): <!REDUNDANT_RETURN_UNIT_TYPE!>Unit<!>
|
||||
{
|
||||
throw UnsupportedOperationException("")
|
||||
}
|
||||
|
||||
fun f3(): Unit = throw UnsupportedOperationException("")
|
||||
}
|
||||
|
||||
class B {
|
||||
fun <T> run(f: () -> T) = f()
|
||||
|
||||
fun foo(): Unit = run {
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar() = 1
|
||||
|
||||
fun call(f: () -> Unit) = f()
|
||||
|
||||
fun boo(): Unit = call {
|
||||
baz()
|
||||
}
|
||||
|
||||
fun baz() {}
|
||||
|
||||
fun <T, R> T.let(f: (T) -> R) = f(this)
|
||||
|
||||
fun goo(): Unit = 1.let {
|
||||
bar()
|
||||
}
|
||||
}
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
FILE: RedundantReturnUnitTypeChecker.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final fun bar(): R|kotlin/Unit| {
|
||||
^bar Q|kotlin/Unit|
|
||||
}
|
||||
|
||||
public final fun baz(): R|kotlin/Unit| {
|
||||
^baz this@R|/A|.R|/A.bar|()
|
||||
}
|
||||
|
||||
public final fun f1(): R|kotlin/Int| {
|
||||
^f1 Int(1)
|
||||
}
|
||||
|
||||
public final fun f2(): R|kotlin/Unit| {
|
||||
throw R|java/lang/UnsupportedOperationException.UnsupportedOperationException|(String())
|
||||
}
|
||||
|
||||
public final fun f3(): R|kotlin/Unit| {
|
||||
^f3 throw R|java/lang/UnsupportedOperationException.UnsupportedOperationException|(String())
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|kotlin/Any| {
|
||||
public constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun <T> run(f: R|() -> T|): R|T| {
|
||||
^run R|<local>/f|.R|FakeOverride<kotlin/Function0.invoke: R|T|>|()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
^foo this@R|/B|.R|/B.run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| {
|
||||
^ this@R|/B|.R|/B.bar|()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public final fun bar(): R|kotlin/Int| {
|
||||
^bar Int(1)
|
||||
}
|
||||
|
||||
public final fun call(f: R|() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
^call R|<local>/f|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
|
||||
}
|
||||
|
||||
public final fun boo(): R|kotlin/Unit| {
|
||||
^boo this@R|/B|.R|/B.call|(<L> = call@fun <anonymous>(): R|kotlin/Unit| {
|
||||
this@R|/B|.R|/B.baz|()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public final fun baz(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final fun <T, R> R|T|.let(f: R|(T) -> R|): R|R| {
|
||||
^let R|<local>/f|.R|FakeOverride<kotlin/Function1.invoke: R|R|>|(this@R|/B.let|)
|
||||
}
|
||||
|
||||
public final fun goo(): R|kotlin/Unit| {
|
||||
^goo (this@R|/B|, Int(1)).R|/B.let|<R|kotlin/Int|, R|kotlin/Int|>(<L> = let@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| {
|
||||
^ this@R|/B|.R|/B.bar|()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user