Passing DataFlowInfo to local classes/objects
#KT-2835 In Progress #KT-2225 In Progress #KT-338 In Progress
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
open class Base(x: String, y: Int)
|
||||
|
||||
fun test(x: Any, y: Int?) {
|
||||
if (x !is String) return
|
||||
if (y == null) return
|
||||
|
||||
class Local: Base(x, y) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test(x: Any) {
|
||||
if (x !is String) return
|
||||
|
||||
class Local(s: String = x) {
|
||||
fun foo(s: String = x): String = s
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
class Del {
|
||||
fun get(<!UNUSED_PARAMETER!>_this<!>: Any?, <!UNUSED_PARAMETER!>p<!>: PropertyMetadata): Int = 0
|
||||
}
|
||||
|
||||
fun df(del: Del): Del = del
|
||||
|
||||
|
||||
fun test(del: Any?) {
|
||||
if (del !is Del) return
|
||||
|
||||
class Local {
|
||||
val delegatedVal by df(del)
|
||||
val delegatedVal1: Int by df(del)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
trait D {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun test(d: Any?) {
|
||||
if (d !is D) return
|
||||
|
||||
class Local : D by d {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
trait D {
|
||||
fun foo(): String = ""
|
||||
}
|
||||
|
||||
fun test(d: Any?) {
|
||||
if (d !is D) return
|
||||
|
||||
class Local {
|
||||
fun f() {
|
||||
d.foo()
|
||||
}
|
||||
|
||||
fun f1() = d.foo()
|
||||
|
||||
fun f2(): String = d.foo()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
fun test(x: Any) {
|
||||
if (x !is String) return
|
||||
|
||||
class LocalOuter {
|
||||
fun foo(y: Any) {
|
||||
if (y !is String) return
|
||||
class Local {
|
||||
{
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -1,9 +1,12 @@
|
||||
fun test(x: Any?) {
|
||||
if (x !is String) return
|
||||
|
||||
class C {
|
||||
val v = x.length
|
||||
}
|
||||
object {
|
||||
val v = x.length
|
||||
|
||||
val vGet: Int
|
||||
get() = x.length
|
||||
|
||||
val s: String = x
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fun test(x: Any) {
|
||||
if (x !is String) return
|
||||
|
||||
class LocalOuter {
|
||||
inner class Local {
|
||||
{
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1471,9 +1471,44 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/kt2835.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LocalClass.kt")
|
||||
public void testLocalClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/LocalClass.kt");
|
||||
@TestMetadata("LocalClassBase.kt")
|
||||
public void testLocalClassBase() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/LocalClassBase.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LocalClassDefaultParameters.kt")
|
||||
public void testLocalClassDefaultParameters() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDefaultParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LocalClassDelegatedProperties.kt")
|
||||
public void testLocalClassDelegatedProperties() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegatedProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LocalClassDelegation.kt")
|
||||
public void testLocalClassDelegation() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LocalClassFunctions.kt")
|
||||
public void testLocalClassFunctions() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/LocalClassFunctions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LocalClassInMemberOfLocalClass.kt")
|
||||
public void testLocalClassInMemberOfLocalClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LocalClassInitializer.kt")
|
||||
public void testLocalClassInitializer() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LocalClassProperty.kt")
|
||||
public void testLocalClassProperty() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LocalObject.kt")
|
||||
@@ -1486,9 +1521,9 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/LocalObjectDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("PropertyInLocalClass.kt")
|
||||
public void testPropertyInLocalClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/PropertyInLocalClass.kt");
|
||||
@TestMetadata("NestedLocalClass.kt")
|
||||
public void testNestedLocalClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user