[K2] isUsedAsExpression analysis
This commit is contained in:
committed by
teamcity
parent
d9701c71b7
commit
f765457e51
analysis/analysis-api/testData/components/expressionInfoProvider/isUsedAsExpression/annotatedExpr.kt
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
val x = args + (<expr>@OptIn(Deprecated::class) args</expr>)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: ANNOTATED_EXPRESSION
|
||||
text: @OptIn(Deprecated::class) args
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
val x = args + (@<expr>OptIn</expr>(Deprecated::class) args)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: CONSTRUCTOR_CALLEE
|
||||
text: OptIn
|
||||
isUsedAsExpression: false
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
val x = args + (@OptIn(Deprecated::class) <expr>args</expr>)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: args
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
(@OptIn(Deprecated::class) <expr>args</expr>)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: args
|
||||
isUsedAsExpression: false
|
||||
analysis/analysis-api/testData/components/expressionInfoProvider/isUsedAsExpression/annotationArg.kt
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
@OptIn(Deprecated::class, <expr>Deprecated::class</expr>)
|
||||
@SuppressWarnings(["unsued", "foo"])
|
||||
fun test() {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: CLASS_LITERAL_EXPRESSION
|
||||
text: Deprecated::class
|
||||
isUsedAsExpression: true
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
@OptIn(Deprecated::class, Deprecated::class)
|
||||
@SuppressWarnings(<expr>["unsued", "foo"]</expr>)
|
||||
fun test() {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: COLLECTION_LITERAL_EXPRESSION
|
||||
text: ["unsued", "foo"]
|
||||
isUsedAsExpression: true
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
@OptIn(Deprecated::class, Deprecated::class)
|
||||
@SuppressWarnings(["unsued", <expr>"foo"</expr>])
|
||||
fun test() {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: STRING_TEMPLATE
|
||||
text: "foo"
|
||||
isUsedAsExpression: true
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
@OptIn(Deprecated::class, Deprecated::class)
|
||||
@<expr>SuppressWarnings</expr>(["unsued", "foo"])
|
||||
fun test() {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: CONSTRUCTOR_CALLEE
|
||||
text: SuppressWarnings
|
||||
isUsedAsExpression: false
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
fun println(x: Boolean) {}
|
||||
|
||||
fun test(b: Boolean): Int {
|
||||
println(<expr>b</expr>)
|
||||
return 54
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: b
|
||||
isUsedAsExpression: true
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
val s = <expr>args[0]</expr>
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
expression: ARRAY_ACCESS_EXPRESSION
|
||||
text: args[0]
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>, i: Int) {
|
||||
val s = <expr>args[i + i]</expr>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: ARRAY_ACCESS_EXPRESSION
|
||||
text: args[i + i]
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>, i: Int) {
|
||||
val s = args[<expr>i + i</expr>]
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: BINARY_EXPRESSION
|
||||
text: i + i
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
val s = args[<expr>0</expr>]
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: INTEGER_CONSTANT
|
||||
text: 0
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
val s = <expr>args</expr>[0]
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: args
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(a: Array<Int>) {
|
||||
<expr>(a + a)[0]++</expr>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: POSTFIX_EXPRESSION
|
||||
text: (a + a)[0]++
|
||||
isUsedAsExpression: false
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(a: Array<Int>) {
|
||||
<expr>(a + a)</expr>[0]++
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: PARENTHESIZED
|
||||
text: (a + a)
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(a: Array<Int>) {
|
||||
(<expr>a + a</expr>)[0]++
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: BINARY_EXPRESSION
|
||||
text: a + a
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(a: Array<Int>) {
|
||||
<expr>a[0]</expr>++
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: ARRAY_ACCESS_EXPRESSION
|
||||
text: a[0]
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
<expr>args[0]</expr>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: ARRAY_ACCESS_EXPRESSION
|
||||
text: args[0]
|
||||
isUsedAsExpression: false
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
<expr>(v as String)</expr>.length
|
||||
}
|
||||
analysis/analysis-api/testData/components/expressionInfoProvider/isUsedAsExpression/asExpression.txt
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
expression: PARENTHESIZED
|
||||
text: (v as String)
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
<expr>(v as String)?.length</expr>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: SAFE_ACCESS_EXPRESSION
|
||||
text: (v as String)?.length
|
||||
isUsedAsExpression: false
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
<expr>(v as String)</expr>?.length
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: PARENTHESIZED
|
||||
text: (v as String)
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
(v as String)?.<expr>length</expr>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: length
|
||||
isUsedAsExpression: false
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
val x = (v as String)?.<expr>length</expr>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: length
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
val x = <expr>(v as String)?.length</expr>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: SAFE_ACCESS_EXPRESSION
|
||||
text: (v as String)?.length
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
(<expr>v as String</expr>).length
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: BINARY_WITH_TYPE
|
||||
text: v as String
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
(<expr>v</expr> as String).length
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: v
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
<expr>(v as? String)</expr>?.length
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: PARENTHESIZED
|
||||
text: (v as? String)
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
(<expr>v as? String</expr>)?.length
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: BINARY_WITH_TYPE
|
||||
text: v as? String
|
||||
isUsedAsExpression: true
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(v: Any?) {
|
||||
(v as? String)?.<expr>let {
|
||||
it.length
|
||||
}</expr>
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: CALL_EXPRESSION
|
||||
text: let {
|
||||
it.length
|
||||
}
|
||||
isUsedAsExpression: false
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(v: Any?) {
|
||||
(v as? String)?.let <expr>{
|
||||
it.length
|
||||
}</expr>
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: LAMBDA_EXPRESSION
|
||||
text: {
|
||||
it.length
|
||||
}
|
||||
isUsedAsExpression: true
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(v: Any?) {
|
||||
val x = (v as? String)?.let <expr>{
|
||||
it.length
|
||||
}</expr>
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: LAMBDA_EXPRESSION
|
||||
text: {
|
||||
it.length
|
||||
}
|
||||
isUsedAsExpression: true
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(v: Any?) {
|
||||
(v as? String)?.let { <expr>it</expr> ->
|
||||
it.length
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: VALUE_PARAMETER
|
||||
text: it
|
||||
isUsedAsExpression: false
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(v: Any?) {
|
||||
(v as? String)?.let{
|
||||
<expr>it</expr>.length
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: it
|
||||
isUsedAsExpression: true
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(v: Any?) {
|
||||
(v as? String)?.<expr>let</expr> {
|
||||
it.length
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: let
|
||||
isUsedAsExpression: false
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(v: Any?) {
|
||||
val x = (v as? String)?.<expr>let {
|
||||
it.length
|
||||
}</expr>
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: CALL_EXPRESSION
|
||||
text: let {
|
||||
it.length
|
||||
}
|
||||
isUsedAsExpression: true
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
(v as <expr>String</expr>).length
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: String
|
||||
isUsedAsExpression: false
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test(v: Any?) {
|
||||
val x = <expr>(v as String)</expr>.length
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: PARENTHESIZED
|
||||
text: (v as String)
|
||||
isUsedAsExpression: true
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
<expr>val names: List<String> // clearly tells the type of the property upfront
|
||||
field: MutableList<String> = mutableListOf()</expr>
|
||||
}
|
||||
analysis/analysis-api/testData/components/expressionInfoProvider/isUsedAsExpression/backingField.txt
Vendored
+4
@@ -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
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
val names: List<String> // clearly tells the type of the property upfront
|
||||
<expr>field: MutableList<String> = mutableListOf()</expr>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: BACKING_FIELD
|
||||
text: field: MutableList<String> = mutableListOf()
|
||||
isUsedAsExpression: false
|
||||
+7
@@ -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
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: CALL_EXPRESSION
|
||||
text: mutableListOf()
|
||||
isUsedAsExpression: true
|
||||
analysis/analysis-api/testData/components/expressionInfoProvider/isUsedAsExpression/boolean_else.txt
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
expression: WHEN
|
||||
text: when(b) {
|
||||
else -> {}
|
||||
}
|
||||
isUsedAsExpression: false
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
fun test(b: Boolean) {
|
||||
while (true) {
|
||||
if (<expr>break</expr>) {
|
||||
"OK"
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
expression: BREAK
|
||||
text: break
|
||||
isUsedAsExpression: false
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
fun test(b: Boolean): Int {
|
||||
val n: Int = <expr>b</expr>.hashCode()
|
||||
return n * 2
|
||||
}
|
||||
analysis/analysis-api/testData/components/expressionInfoProvider/isUsedAsExpression/callReceiver.txt
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: b
|
||||
isUsedAsExpression: true
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun test(b: Boolean): Int {
|
||||
val n: Int = (<expr>b</expr>).hashCode()
|
||||
return n * 2
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: b
|
||||
isUsedAsExpression: true
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun test(b: Boolean): Int {
|
||||
val n: Int = <expr>(b)</expr>.hashCode()
|
||||
return n * 2
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: PARENTHESIZED
|
||||
text: (b)
|
||||
isUsedAsExpression: true
|
||||
+6
@@ -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()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: CALLABLE_REFERENCE_EXPRESSION
|
||||
text: s::length
|
||||
isUsedAsExpression: true
|
||||
+6
@@ -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()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: CALLABLE_REFERENCE_EXPRESSION
|
||||
text: s::length
|
||||
isUsedAsExpression: true
|
||||
+6
@@ -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()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: g
|
||||
isUsedAsExpression: true
|
||||
+6
@@ -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()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: REFERENCE_EXPRESSION
|
||||
text: s
|
||||
isUsedAsExpression: true
|
||||
+6
@@ -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
Reference in New Issue
Block a user