[K2] isUsedAsExpression analysis

This commit is contained in:
Kristoffer Andersen
2022-08-01 17:46:54 +02:00
committed by teamcity
parent d9701c71b7
commit f765457e51
673 changed files with 11862 additions and 10 deletions
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
val x = args + (<expr>@OptIn(Deprecated::class) args</expr>)
}
@@ -0,0 +1,3 @@
expression: ANNOTATED_EXPRESSION
text: @OptIn(Deprecated::class) args
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
val x = args + (@<expr>OptIn</expr>(Deprecated::class) args)
}
@@ -0,0 +1,3 @@
expression: CONSTRUCTOR_CALLEE
text: OptIn
isUsedAsExpression: false
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
val x = args + (@OptIn(Deprecated::class) <expr>args</expr>)
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: args
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
(@OptIn(Deprecated::class) <expr>args</expr>)
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: args
isUsedAsExpression: false
@@ -0,0 +1,5 @@
@OptIn(Deprecated::class, <expr>Deprecated::class</expr>)
@SuppressWarnings(["unsued", "foo"])
fun test() {
}
@@ -0,0 +1,3 @@
expression: CLASS_LITERAL_EXPRESSION
text: Deprecated::class
isUsedAsExpression: true
@@ -0,0 +1,5 @@
@OptIn(Deprecated::class, Deprecated::class)
@SuppressWarnings(<expr>["unsued", "foo"]</expr>)
fun test() {
}
@@ -0,0 +1,3 @@
expression: COLLECTION_LITERAL_EXPRESSION
text: ["unsued", "foo"]
isUsedAsExpression: true
@@ -0,0 +1,5 @@
@OptIn(Deprecated::class, Deprecated::class)
@SuppressWarnings(["unsued", <expr>"foo"</expr>])
fun test() {
}
@@ -0,0 +1,3 @@
expression: STRING_TEMPLATE
text: "foo"
isUsedAsExpression: true
@@ -0,0 +1,5 @@
@OptIn(Deprecated::class, Deprecated::class)
@<expr>SuppressWarnings</expr>(["unsued", "foo"])
fun test() {
}
@@ -0,0 +1,3 @@
expression: CONSTRUCTOR_CALLEE
text: SuppressWarnings
isUsedAsExpression: false
@@ -0,0 +1,6 @@
fun println(x: Boolean) {}
fun test(b: Boolean): Int {
println(<expr>b</expr>)
return 54
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: b
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
val s = <expr>args[0]</expr>
}
@@ -0,0 +1,3 @@
expression: ARRAY_ACCESS_EXPRESSION
text: args[0]
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun main(args: Array<String>, i: Int) {
val s = <expr>args[i + i]</expr>
}
@@ -0,0 +1,3 @@
expression: ARRAY_ACCESS_EXPRESSION
text: args[i + i]
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun main(args: Array<String>, i: Int) {
val s = args[<expr>i + i</expr>]
}
@@ -0,0 +1,3 @@
expression: BINARY_EXPRESSION
text: i + i
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
val s = args[<expr>0</expr>]
}
@@ -0,0 +1,3 @@
expression: INTEGER_CONSTANT
text: 0
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
val s = <expr>args</expr>[0]
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: args
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(a: Array<Int>) {
<expr>(a + a)[0]++</expr>
}
@@ -0,0 +1,3 @@
expression: POSTFIX_EXPRESSION
text: (a + a)[0]++
isUsedAsExpression: false
@@ -0,0 +1,3 @@
fun test(a: Array<Int>) {
<expr>(a + a)</expr>[0]++
}
@@ -0,0 +1,3 @@
expression: PARENTHESIZED
text: (a + a)
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(a: Array<Int>) {
(<expr>a + a</expr>)[0]++
}
@@ -0,0 +1,3 @@
expression: BINARY_EXPRESSION
text: a + a
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(a: Array<Int>) {
<expr>a[0]</expr>++
}
@@ -0,0 +1,3 @@
expression: ARRAY_ACCESS_EXPRESSION
text: a[0]
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
<expr>args[0]</expr>
}
@@ -0,0 +1,3 @@
expression: ARRAY_ACCESS_EXPRESSION
text: args[0]
isUsedAsExpression: false
@@ -0,0 +1,3 @@
fun test(v: Any?) {
<expr>(v as String)</expr>.length
}
@@ -0,0 +1,3 @@
expression: PARENTHESIZED
text: (v as String)
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(v: Any?) {
<expr>(v as String)?.length</expr>
}
@@ -0,0 +1,3 @@
expression: SAFE_ACCESS_EXPRESSION
text: (v as String)?.length
isUsedAsExpression: false
@@ -0,0 +1,3 @@
fun test(v: Any?) {
<expr>(v as String)</expr>?.length
}
@@ -0,0 +1,3 @@
expression: PARENTHESIZED
text: (v as String)
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(v: Any?) {
(v as String)?.<expr>length</expr>
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: length
isUsedAsExpression: false
@@ -0,0 +1,3 @@
fun test(v: Any?) {
val x = (v as String)?.<expr>length</expr>
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: length
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(v: Any?) {
val x = <expr>(v as String)?.length</expr>
}
@@ -0,0 +1,3 @@
expression: SAFE_ACCESS_EXPRESSION
text: (v as String)?.length
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(v: Any?) {
(<expr>v as String</expr>).length
}
@@ -0,0 +1,3 @@
expression: BINARY_WITH_TYPE
text: v as String
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(v: Any?) {
(<expr>v</expr> as String).length
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: v
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(v: Any?) {
<expr>(v as? String)</expr>?.length
}
@@ -0,0 +1,3 @@
expression: PARENTHESIZED
text: (v as? String)
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(v: Any?) {
(<expr>v as? String</expr>)?.length
}
@@ -0,0 +1,3 @@
expression: BINARY_WITH_TYPE
text: v as? String
isUsedAsExpression: true
@@ -0,0 +1,5 @@
fun test(v: Any?) {
(v as? String)?.<expr>let {
it.length
}</expr>
}
@@ -0,0 +1,5 @@
expression: CALL_EXPRESSION
text: let {
it.length
}
isUsedAsExpression: false
@@ -0,0 +1,5 @@
fun test(v: Any?) {
(v as? String)?.let <expr>{
it.length
}</expr>
}
@@ -0,0 +1,5 @@
expression: LAMBDA_EXPRESSION
text: {
it.length
}
isUsedAsExpression: true
@@ -0,0 +1,5 @@
fun test(v: Any?) {
val x = (v as? String)?.let <expr>{
it.length
}</expr>
}
@@ -0,0 +1,5 @@
expression: LAMBDA_EXPRESSION
text: {
it.length
}
isUsedAsExpression: true
@@ -0,0 +1,5 @@
fun test(v: Any?) {
(v as? String)?.let { <expr>it</expr> ->
it.length
}
}
@@ -0,0 +1,3 @@
expression: VALUE_PARAMETER
text: it
isUsedAsExpression: false
@@ -0,0 +1,5 @@
fun test(v: Any?) {
(v as? String)?.let{
<expr>it</expr>.length
}
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: it
isUsedAsExpression: true
@@ -0,0 +1,5 @@
fun test(v: Any?) {
(v as? String)?.<expr>let</expr> {
it.length
}
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: let
isUsedAsExpression: false
@@ -0,0 +1,5 @@
fun test(v: Any?) {
val x = (v as? String)?.<expr>let {
it.length
}</expr>
}
@@ -0,0 +1,5 @@
expression: CALL_EXPRESSION
text: let {
it.length
}
isUsedAsExpression: true
@@ -0,0 +1,3 @@
fun test(v: Any?) {
(v as <expr>String</expr>).length
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: String
isUsedAsExpression: false
@@ -0,0 +1,3 @@
fun test(v: Any?) {
val x = <expr>(v as String)</expr>.length
}
@@ -0,0 +1,3 @@
expression: PARENTHESIZED
text: (v as String)
isUsedAsExpression: true
@@ -0,0 +1,4 @@
class C {
<expr>val names: List<String> // clearly tells the type of the property upfront
field: MutableList<String> = mutableListOf()</expr>
}
@@ -0,0 +1,4 @@
expression: PROPERTY
text: val names: List<String> // clearly tells the type of the property upfront
field: MutableList<String> = mutableListOf()
isUsedAsExpression: false
@@ -0,0 +1,4 @@
class C {
val names: List<String> // clearly tells the type of the property upfront
<expr>field: MutableList<String> = mutableListOf()</expr>
}
@@ -0,0 +1,3 @@
expression: BACKING_FIELD
text: field: MutableList<String> = mutableListOf()
isUsedAsExpression: false
@@ -0,0 +1,7 @@
class C {
val names: List<String> // clearly tells the type of the property upfront
field: MutableList<String> = <expr>mutableListOf()</expr>
}
// IGNORE_FE10
// RHS of initializer is deemed unused by FE1.0
@@ -0,0 +1,3 @@
expression: CALL_EXPRESSION
text: mutableListOf()
isUsedAsExpression: true
@@ -0,0 +1,5 @@
expression: WHEN
text: when(b) {
else -> {}
}
isUsedAsExpression: false
@@ -0,0 +1,9 @@
fun test(b: Boolean) {
while (true) {
if (<expr>break</expr>) {
"OK"
} else {
continue
}
}
}
@@ -0,0 +1,3 @@
expression: BREAK
text: break
isUsedAsExpression: false
@@ -0,0 +1,4 @@
fun test(b: Boolean): Int {
val n: Int = <expr>b</expr>.hashCode()
return n * 2
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: b
isUsedAsExpression: true
@@ -0,0 +1,4 @@
fun test(b: Boolean): Int {
val n: Int = (<expr>b</expr>).hashCode()
return n * 2
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: b
isUsedAsExpression: true
@@ -0,0 +1,4 @@
fun test(b: Boolean): Int {
val n: Int = <expr>(b)</expr>.hashCode()
return n * 2
}
@@ -0,0 +1,3 @@
expression: PARENTHESIZED
text: (b)
isUsedAsExpression: true
@@ -0,0 +1,6 @@
fun test() {
val f = String::length
val s = "hello"
val g = <expr>s::length</expr>
f(s) + g() + String::length.invoke(s) + s::length.invoke()
}
@@ -0,0 +1,3 @@
expression: CALLABLE_REFERENCE_EXPRESSION
text: s::length
isUsedAsExpression: true
@@ -0,0 +1,6 @@
fun test() {
val f = String::length
val s = "hello"
val g = s::length
f(s) + g() + String::length.invoke(s) + <expr>s::length</expr>.invoke()
}
@@ -0,0 +1,3 @@
expression: CALLABLE_REFERENCE_EXPRESSION
text: s::length
isUsedAsExpression: true
@@ -0,0 +1,6 @@
fun test() {
val f = String::length
val s = "hello"
val g = s::length
f(s) + <expr>g</expr>() + String::length.invoke(s) + s::length.invoke()
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: g
isUsedAsExpression: true
@@ -0,0 +1,6 @@
fun test() {
val f = String::length
val s = "hello"
val g = <expr>s</expr>::length
f() + g() + String::length.invoke(s) + s::length.invoke()
}
@@ -0,0 +1,3 @@
expression: REFERENCE_EXPRESSION
text: s
isUsedAsExpression: true
@@ -0,0 +1,6 @@
fun test() {
val f = String::length
val s = "hello"
val g = s::<expr>length</expr>
f() + g() + String::length.invoke(s) + s::length.invoke()
}

Some files were not shown because too many files have changed in this diff Show More