Create from Usage: Place extension properties after the usage and generate stub getter

#KT-11795 Fixed
This commit is contained in:
Alexey Sedunov
2016-08-18 16:10:17 +03:00
parent 99ba340236
commit c2b38cfa41
23 changed files with 92 additions and 58 deletions
@@ -3,11 +3,14 @@
import package1.A
private val package2.A.foo: Any<caret>
class X {
init {
val y = package2.A()
val foo = y.foo
}
}
}
private val package2.A.foo: Any
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -1,8 +1,11 @@
// "Create extension property 'A.foo'" "true"
// ERROR: Unresolved reference: foo
private val A.foo: String?<caret>
fun test(): String? {
return A().foo
}
}
private val A.foo: String?
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -1,8 +1,11 @@
// "Create extension property 'A.foo'" "true"
// ERROR: Unresolved reference: foo
private val A.foo: String?<caret>
fun test(): String? {
return A().foo
}
}
private val A.foo: String?
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -1,5 +1,4 @@
// "Create extension property 'T.bar'" "true"
// ERROR: Property must be initialized
fun consume(n: Int) {}
fun <T> foo(t: T) {
@@ -1,9 +1,11 @@
// "Create extension property 'T.bar'" "true"
// ERROR: Property must be initialized
fun consume(n: Int) {}
private val <T> T.bar: Int
fun <T> foo(t: T) {
consume(t.bar)
}
}
private val <T> T.bar: Int
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -3,8 +3,8 @@ import kotlin.properties.ReadOnlyProperty
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
val foo: ReadOnlyProperty<Nothing?, Int>
fun test() {
val x: Int by foo
}
val foo: ReadOnlyProperty<Nothing?, Int>
@@ -1,7 +1,7 @@
val `!u00A0`: Int
// "Create property '!u00A0'" "true"
// ERROR: Property must be initialized
fun test() {
val t: Int = `!u00A0`
}
}
val `!u00A0`: Int
@@ -2,8 +2,8 @@
// ERROR: Property must be initialized
class Cyclic<E : Cyclic<E>>
val foo: Cyclic<*>
fun test() {
val c : Cyclic<*> = foo
}
}
val foo: Cyclic<*>
@@ -1,8 +1,8 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
val foo: String
fun test() {
println("a = $foo")
}
}
val foo: String
@@ -1,8 +1,8 @@
// "Create property 'foo'" "true"
// ERROR: Property must be initialized
val foo: Int
fun test(): Int {
return foo
}
val foo: Int
@@ -3,8 +3,8 @@
package foo
val foo: Int
fun test(): Int {
return foo
}
val foo: Int
@@ -1,5 +1,4 @@
// "Create extension property 'Unit.foo'" "true"
// ERROR: Property must be initialized
// WITH_RUNTIME
fun test() {
@@ -1,9 +1,11 @@
// "Create extension property 'Unit.foo'" "true"
// ERROR: Property must be initialized
// WITH_RUNTIME
private val Unit.foo: Int
fun test() {
val a: Int = Unit.foo
}
private val Unit.foo: Int
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -1,5 +1,4 @@
// "Create extension property 'Int.foo'" "true"
// ERROR: Property must be initialized
// WITH_RUNTIME
class A<T>(val n: T)
@@ -1,11 +1,13 @@
// "Create extension property 'Int.foo'" "true"
// ERROR: Property must be initialized
// WITH_RUNTIME
class A<T>(val n: T)
private val Int.foo: A<Int>
fun test() {
val a: A<Int> = 2.foo
}
private val Int.foo: A<Int>
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -1,5 +1,4 @@
// "Create extension property 'Int.foo'" "true"
// ERROR: Property must be initialized
// WITH_RUNTIME
class A<T>(val n: T)
@@ -1,11 +1,15 @@
// "Create extension property 'Int.foo'" "true"
// ERROR: Property must be initialized
// WITH_RUNTIME
class A<T>(val n: T)
private var Int.foo: A<String>
fun test() {
2.foo = A("2")
}
private var Int.foo: A<String>
get() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
set() {
}