Add more tests for PropertyAccessorDescriptor.isDeafult() usages
This commit is contained in:
committed by
Nikolay Krasko
parent
c936b3f3e0
commit
eee45e91ce
@@ -14,7 +14,13 @@ class My {
|
||||
field = value + if (w == "") 1 else 0
|
||||
}
|
||||
|
||||
var m: Int = 2
|
||||
set
|
||||
|
||||
init {
|
||||
<!DEBUG_INFO_LEAKING_THIS!>x<!> = 3
|
||||
<!DEBUG_INFO_LEAKING_THIS!>m<!> = 6
|
||||
|
||||
// Writing properties using setters is dangerous
|
||||
<!DEBUG_INFO_LEAKING_THIS!>y<!> = 4
|
||||
this.<!DEBUG_INFO_LEAKING_THIS!>z<!> = 5
|
||||
|
||||
@@ -2,6 +2,7 @@ package
|
||||
|
||||
public final class My {
|
||||
public constructor My()
|
||||
public final var m: kotlin.Int
|
||||
public final val w: kotlin.String = "6"
|
||||
public final var x: kotlin.Int
|
||||
public final var y: kotlin.Int
|
||||
|
||||
@@ -8,7 +8,16 @@ class My(var x: String) {
|
||||
|
||||
val z: String
|
||||
|
||||
var d: String = ""
|
||||
get
|
||||
set
|
||||
|
||||
val z1: String
|
||||
|
||||
init {
|
||||
<!DEBUG_INFO_LEAKING_THIS!>d<!> = "d"
|
||||
if (<!DEBUG_INFO_LEAKING_THIS!>d<!> != "") z1 = this.<!DEBUG_INFO_LEAKING_THIS!>d<!> else z1 = <!DEBUG_INFO_LEAKING_THIS!>d<!>
|
||||
|
||||
// Dangerous: setter!
|
||||
<!DEBUG_INFO_LEAKING_THIS!>y<!> = "x"
|
||||
// Dangerous: getter!
|
||||
|
||||
@@ -2,9 +2,11 @@ package
|
||||
|
||||
public final class My {
|
||||
public constructor My(/*0*/ x: kotlin.String)
|
||||
public final var d: kotlin.String
|
||||
public final var x: kotlin.String
|
||||
public final var y: kotlin.String
|
||||
public final val z: kotlin.String
|
||||
public final val z1: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
@@ -44,6 +44,9 @@ const val delegated: Int <!CONST_VAL_WITH_DELEGATE!>by Delegate()<!>
|
||||
const val withGetter: Int
|
||||
<!CONST_VAL_WITH_GETTER!>get() = 13<!>
|
||||
|
||||
const val withExplicitDefaultGetter: Int = 1
|
||||
<!CONST_VAL_WITH_GETTER!>get<!>
|
||||
|
||||
fun foo(): Int {
|
||||
<!WRONG_MODIFIER_TARGET!>const<!> val local: Int = 14
|
||||
return 15
|
||||
|
||||
@@ -11,6 +11,7 @@ private val privateTopLevel: kotlin.Int = 3
|
||||
public const var topLeveLVar: kotlin.Int
|
||||
public const val topLevel: kotlin.Int = 0
|
||||
public const val topLevelInferred: kotlin.Int = 1
|
||||
public const val withExplicitDefaultGetter: kotlin.Int = 1
|
||||
public const val withGetter: kotlin.Int
|
||||
public fun foo(): kotlin.Int
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class ExplicitAccessorForAnnotation {
|
||||
val tt: String? = "good"
|
||||
get
|
||||
|
||||
fun foo(): String {
|
||||
if (tt is String) {
|
||||
return <!SMARTCAST_IMPOSSIBLE!>tt<!>
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public final class ExplicitAccessorForAnnotation {
|
||||
public constructor ExplicitAccessorForAnnotation()
|
||||
public final val tt: kotlin.String? = "good"
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+18
@@ -4,6 +4,8 @@ fun foo() {
|
||||
<!WRONG_ANNOTATION_TARGET!>@kotlin.jvm.JvmField<!> val x = "A"
|
||||
}
|
||||
|
||||
annotation class DemoAnnotation
|
||||
|
||||
<!WRONG_ANNOTATION_TARGET!>@JvmField<!>
|
||||
abstract class C : I{
|
||||
|
||||
@@ -23,6 +25,22 @@ abstract class C : I{
|
||||
val customGetter: String = ""
|
||||
get() = field
|
||||
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
val explicitDefaultGetter: String = ""
|
||||
get
|
||||
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
var explicitDefaultSetter: String = ""
|
||||
set
|
||||
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
val explicitDefaultAnnotatedGetter: String = ""
|
||||
@DemoAnnotation get
|
||||
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
var explicitDefaultAnnotatedSetter: String = ""
|
||||
@DemoAnnotation set
|
||||
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!>
|
||||
var customSetter: String = ""
|
||||
set(s) {
|
||||
|
||||
Vendored
+11
@@ -14,6 +14,10 @@ package
|
||||
@kotlin.jvm.JvmField() public abstract val c: kotlin.Int
|
||||
@kotlin.jvm.JvmField() public final val customGetter: kotlin.String = ""
|
||||
@kotlin.jvm.JvmField() public final var customSetter: kotlin.String
|
||||
@kotlin.jvm.JvmField() public final val explicitDefaultAnnotatedGetter: kotlin.String = ""
|
||||
@kotlin.jvm.JvmField() public final var explicitDefaultAnnotatedSetter: kotlin.String
|
||||
@kotlin.jvm.JvmField() public final val explicitDefaultGetter: kotlin.String = ""
|
||||
@kotlin.jvm.JvmField() public final var explicitDefaultSetter: kotlin.String
|
||||
@kotlin.jvm.JvmField() public final val noBackingField: kotlin.String
|
||||
@kotlin.jvm.JvmField() private final val private: kotlin.Int = 3
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@@ -22,6 +26,13 @@ package
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final annotation class DemoAnnotation : kotlin.Annotation {
|
||||
public constructor DemoAnnotation()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class G {
|
||||
public constructor G()
|
||||
@kotlin.jvm.JvmField() public final lateinit var lateInit: kotlin.String
|
||||
|
||||
@@ -16953,6 +16953,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("explicitDefaultGetter.kt")
|
||||
public void testExplicitDefaultGetter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/explicitDefaultGetter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionSafeCall.kt")
|
||||
public void testExtensionSafeCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/extensionSafeCall.kt");
|
||||
|
||||
+12
@@ -266,3 +266,15 @@ fun inForLoop(x: Any?) {
|
||||
}
|
||||
for (i in <error descr="[ITERATOR_MISSING] For-loop range must have an 'iterator()' method">x</error>) {}
|
||||
}
|
||||
|
||||
class ExplicitAccessorForAnnotation {
|
||||
val tt: String? = "good"
|
||||
<info descr="null">get</info>
|
||||
|
||||
fun foo(): String {
|
||||
if (tt is String) {
|
||||
return <error descr="[SMARTCAST_IMPOSSIBLE] Smart cast to 'String' is impossible, because 'tt' is a property that has open or custom getter">tt</error>
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
var serial: String = ""
|
||||
get
|
||||
set
|
||||
var name: String = ""
|
||||
get
|
||||
<caret>
|
||||
}
|
||||
|
||||
// FORCED
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
class Test {
|
||||
var serial: String = ""
|
||||
get
|
||||
set
|
||||
var name: String = ""
|
||||
get
|
||||
|
||||
override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
return 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// FORCED
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
var serial: String = ""
|
||||
get
|
||||
set
|
||||
var name: String = ""
|
||||
get
|
||||
<caret>
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
var serial: String = ""
|
||||
get
|
||||
set
|
||||
var name: String = ""
|
||||
get
|
||||
|
||||
override fun toString(): String{
|
||||
return "Test()"
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
LineBreakpoint created at privatePropertyWithExplicitDefaultGetter.kt:7
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! privatePropertyWithExplicitDefaultGetter.PrivatePropertyWithExplicitDefaultGetterKt
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
privatePropertyWithExplicitDefaultGetter.kt:7
|
||||
Compile bytecode for base.a
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package privatePropertyWithExplicitDefaultGetter
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val base = Some()
|
||||
|
||||
//Breakpoint!
|
||||
args.size
|
||||
}
|
||||
|
||||
annotation class Small
|
||||
|
||||
class Some {
|
||||
private val a: Int = 1
|
||||
@Small get
|
||||
|
||||
}
|
||||
// EXPRESSION: base.a
|
||||
// RESULT: java.lang.NoSuchMethodError : Method not found: MemberDescription(ownerInternalName = privatePropertyWithExplicitDefaultGetter/Some, name = getA, desc = ()I, isStatic = false)
|
||||
+6
@@ -65,6 +65,12 @@ public class GenerateHashCodeAndEqualsActionTestGenerated extends AbstractGenera
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("explicitDefaultAccessors.kt")
|
||||
public void testExplicitDefaultAccessors() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/equalsWithHashCode/explicitDefaultAccessors.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("genericClass.kt")
|
||||
public void testGenericClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/equalsWithHashCode/genericClass.kt");
|
||||
|
||||
+6
@@ -139,6 +139,12 @@ public class GenerateToStringActionTestGenerated extends AbstractGenerateToStrin
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("explicitDefaultAccessors.kt")
|
||||
public void testExplicitDefaultAccessors() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/singleTemplate/explicitDefaultAccessors.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multipleVars.kt")
|
||||
public void testMultipleVars() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/singleTemplate/multipleVars.kt");
|
||||
|
||||
+6
@@ -313,6 +313,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
||||
doSingleBreakpointTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("privatePropertyWithExplicitDefaultGetter.kt")
|
||||
public void testPrivatePropertyWithExplicitDefaultGetter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/privatePropertyWithExplicitDefaultGetter.kt");
|
||||
doSingleBreakpointTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("protectedMember.kt")
|
||||
public void testProtectedMember() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/protectedMember.kt");
|
||||
|
||||
Reference in New Issue
Block a user