Move to constructor: choose property use-site target more precisely
#KT-26015 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
29390dab42
commit
de6fdc5733
@@ -0,0 +1,23 @@
|
||||
annotation class Ann1(val i: Int, val j: Int)
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY)
|
||||
annotation class Ann2(val i: Int, val j: Int)
|
||||
|
||||
@Target(AnnotationTarget.FIELD)
|
||||
annotation class Ann3(val i: Int, val j: Int)
|
||||
|
||||
@Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
|
||||
annotation class Ann4(val i: Int, val j: Int)
|
||||
|
||||
@Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FIELD)
|
||||
annotation class Ann5(val i: Int, val j: Int)
|
||||
|
||||
class Test {
|
||||
@get:Ann1(0, 0)
|
||||
@Ann1(1, 11)
|
||||
@Ann2(2, 22)
|
||||
@Ann3(3, 33)
|
||||
@Ann4(4, 44)
|
||||
@Ann5(5, 55)
|
||||
val <caret>foo = ""
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
annotation class Ann1(val i: Int, val j: Int)
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY)
|
||||
annotation class Ann2(val i: Int, val j: Int)
|
||||
|
||||
@Target(AnnotationTarget.FIELD)
|
||||
annotation class Ann3(val i: Int, val j: Int)
|
||||
|
||||
@Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
|
||||
annotation class Ann4(val i: Int, val j: Int)
|
||||
|
||||
@Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FIELD)
|
||||
annotation class Ann5(val i: Int, val j: Int)
|
||||
|
||||
class Test(@get:Ann1(0, 0) @property:Ann1(1, 11) @Ann2(2, 22) @Ann3(3, 33) @property:Ann4(4, 44) @field:Ann5(5, 55) val foo: String = "") {
|
||||
}
|
||||
+1
-1
@@ -4,5 +4,5 @@ annotation class Annotation3(val a: Int = 0)
|
||||
|
||||
|
||||
class TestClass(@Annotation1(42) @Annotation3(42) initialText: String = "LoremIpsum") {
|
||||
private @Annotation1(42) @property:Annotation2(42) val <caret>text = initialText
|
||||
private @Annotation1(42) @field:Annotation2(42) val <caret>text = initialText
|
||||
}
|
||||
+1
-1
@@ -3,5 +3,5 @@ annotation class Annotation2(val a: Int = 0)
|
||||
annotation class Annotation3(val a: Int = 0)
|
||||
|
||||
|
||||
class TestClass(private @field:Annotation1(42) @property:Annotation2(42) @Annotation1(42) @Annotation3(42) val text: String = "LoremIpsum") {
|
||||
class TestClass(private @property:Annotation1(42) @field:Annotation2(42) @Annotation1(42) @Annotation3(42) val text: String = "LoremIpsum") {
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
public @interface JavaAnn { }
|
||||
+1
@@ -0,0 +1 @@
|
||||
public @interface JavaAnn { }
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
|
||||
@Target({FIELD})
|
||||
public @interface JavaFieldAnn {
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
|
||||
@Target({FIELD})
|
||||
public @interface JavaFieldAnn {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
@JavaAnn
|
||||
@JavaFieldAnn
|
||||
val <caret>foo = ""
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
class Test(@property:JavaAnn @JavaFieldAnn val foo: String = "") {
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
annotation class SuperAnnotation
|
||||
|
||||
class TestClass(@field:SuperAnnotation val text: String) {
|
||||
class TestClass(@property:SuperAnnotation val text: String) {
|
||||
}
|
||||
+1
-1
@@ -4,5 +4,5 @@ annotation class Annotation3(val a: Int = 0)
|
||||
|
||||
|
||||
class TestClass(@Annotation1(42) @Annotation3(42) initialText: String = "LoremIpsum") {
|
||||
private @Annotation1(42) @property:Annotation2(42) val <caret>text = "dolor sit amet"
|
||||
private @Annotation1(42) @field:Annotation2(42) val <caret>text = "dolor sit amet"
|
||||
}
|
||||
+1
-1
@@ -3,5 +3,5 @@ annotation class Annotation2(val a: Int = 0)
|
||||
annotation class Annotation3(val a: Int = 0)
|
||||
|
||||
|
||||
class TestClass(@Annotation1(42) @Annotation3(42) initialText: String = "LoremIpsum", private @field:Annotation1(42) @property:Annotation2(42) val text: String = "dolor sit amet") {
|
||||
class TestClass(@Annotation1(42) @Annotation3(42) initialText: String = "LoremIpsum", private @property:Annotation1(42) @field:Annotation2(42) val text: String = "dolor sit amet") {
|
||||
}
|
||||
Reference in New Issue
Block a user