Auto-imports for index functions, += like operators, invoke, delegates and components
#KT-9482 Fixed #KT-9397 Fixed #KT-8060 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
0f85d770dd
commit
2f26480e6b
@@ -0,0 +1,37 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Missing 'getValue(testing.BigTest, kotlin.PropertyMetadata)' method on delegate of type 'some.DelegateImpl<kotlin.Int>'
|
||||
|
||||
package testing
|
||||
|
||||
import some.DelegateImpl
|
||||
|
||||
class BigTest {
|
||||
val a by <caret>DelegateImpl<Int>()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
class DelegateImpl<T> {
|
||||
val value: T = null!!
|
||||
}
|
||||
|
||||
public fun <T> DelegateImpl<T>.getValue(thisRef: Any?, property: PropertyMetadata): T = value
|
||||
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Missing 'getValue(testing.BigTest, kotlin.PropertyMetadata)' method on delegate of type 'some.DelegateImpl<kotlin.Int>'
|
||||
|
||||
package testing
|
||||
|
||||
import some.DelegateImpl
|
||||
import some.getValue
|
||||
|
||||
class BigTest {
|
||||
val a by <caret>DelegateImpl<Int>()
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Missing 'setValue(testing.BigTest, kotlin.PropertyMetadata, kotlin.Int)' method on delegate of type 'some.DelegateImpl<kotlin.Int>'
|
||||
|
||||
package testing
|
||||
|
||||
import some.DelegateImpl
|
||||
import some.getValue
|
||||
|
||||
class BigTest {
|
||||
var a by <caret>DelegateImpl<Int>()
|
||||
}
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
class DelegateImpl<T> {
|
||||
val value: T = null!!
|
||||
}
|
||||
|
||||
public fun <T> DelegateImpl<T>.getValue(thisRef: Any?, property: PropertyMetadata): T = value
|
||||
public fun <T> DelegateImpl<T>.setValue(thisRef: Any, propertyMetadata: PropertyMetadata, t: T) {}
|
||||
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Missing 'setValue(testing.BigTest, kotlin.PropertyMetadata, kotlin.Int)' method on delegate of type 'some.DelegateImpl<kotlin.Int>'
|
||||
|
||||
package testing
|
||||
|
||||
import some.DelegateImpl
|
||||
import some.getValue
|
||||
import some.setValue
|
||||
|
||||
class BigTest {
|
||||
var a by <caret>DelegateImpl<Int>()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: foo()["str"]
|
||||
// ERROR: No get method providing array access
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
|
||||
fun foo(): Some = Some()
|
||||
|
||||
fun testing() {
|
||||
foo()<caret>["str"]
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
operator fun Some.get(s: String) {}
|
||||
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: foo()["str"]
|
||||
// ERROR: No get method providing array access
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.get
|
||||
|
||||
fun foo(): Some = Some()
|
||||
|
||||
fun testing() {
|
||||
foo()<caret>["str"]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "false"
|
||||
// ERROR: Unresolved reference: foo()["str"]
|
||||
// ERROR: No get method providing array access
|
||||
// ACTION: Create extension function 'get'
|
||||
// ACTION: Create member function 'get'
|
||||
// ACTION: Replace overloaded operator with function call
|
||||
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
|
||||
fun foo(): Some = Some()
|
||||
|
||||
fun testing() {
|
||||
foo()<caret>["str"]
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
fun Some.get(s: String) {}
|
||||
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: foo()["str"]
|
||||
// ERROR: No get method providing array access
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.get
|
||||
|
||||
fun foo(): Some = Some()
|
||||
|
||||
fun testing() {
|
||||
foo()<caret>["str"]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: foo()["other"]
|
||||
// ERROR: No set method providing array access
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
|
||||
fun foo(): Some = Some()
|
||||
|
||||
fun testing() {
|
||||
foo()<caret>["other"] = 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
operator fun Some.set(s: String) {}
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: foo()["other"]
|
||||
// ERROR: No set method providing array access
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.set
|
||||
|
||||
fun foo(): Some = Some()
|
||||
|
||||
fun testing() {
|
||||
foo()<caret>["other"] = 1
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "false"
|
||||
// ERROR: Unresolved reference: foo()["str"]
|
||||
// ERROR: No set method providing array access
|
||||
// ACTION: Create extension function 'set'
|
||||
// ACTION: Create member function 'set'
|
||||
// ACTION: Replace overloaded operator with function call
|
||||
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
|
||||
fun foo(): Some = Some()
|
||||
|
||||
fun testing() {
|
||||
foo()<caret>["str"] = 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
operator fun Some.get(s: String) {}
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// Empty File
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "false"
|
||||
// ERROR: Unresolved reference: foo()["str"]
|
||||
// ERROR: No get method providing array access
|
||||
// ACTION: Create extension function 'get'
|
||||
// ACTION: Create member function 'get'
|
||||
// ACTION: Replace overloaded operator with function call
|
||||
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
|
||||
fun foo(): Some = Some()
|
||||
|
||||
fun testing() {
|
||||
foo()<caret>["str"]
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
operator fun Some.set(s: String) {}
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// Empty File
|
||||
@@ -0,0 +1,41 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Expression 'Some()' of type 'some.Some' cannot be invoked as a function. The function invoke() is not found
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
|
||||
fun testing() {
|
||||
<caret>Some()("str")
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Expression 'Some()' of type 'some.Some' cannot be invoked as a function. The function invoke() is not found
|
||||
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
operator fun Some.invoke(s: String) {}
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Expression 'Some()' of type 'some.Some' cannot be invoked as a function. The function invoke() is not found
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.invoke
|
||||
|
||||
fun testing() {
|
||||
<caret>Some()("str")
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "false"
|
||||
// ERROR: Expression 'Some()' of type 'some.Some' cannot be invoked as a function. The function invoke() is not found
|
||||
// ACTION: Create extension function 'invoke'
|
||||
// ACTION: Create member function 'invoke'
|
||||
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
|
||||
fun testing() {
|
||||
<caret>Some()("str")
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Expression 'Some()' of type 'some.Some' cannot be invoked as a function. The function invoke() is not found
|
||||
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
fun Some.invoke(s: String) {}
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Expression 'Some()' of type 'some.Some' cannot be invoked as a function. The function invoke() is not found
|
||||
// ACTION: Create extension function 'invoke'
|
||||
// ACTION: Create member function 'invoke'
|
||||
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.invoke
|
||||
|
||||
fun testing() {
|
||||
<caret>Some()("str")
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.component2
|
||||
|
||||
fun testing() {
|
||||
val (a, b) = <caret>Some()
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
operator fun Some.component1() = 1
|
||||
operator fun Some.component2() = 3
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.component1
|
||||
import some.component2
|
||||
|
||||
fun testing() {
|
||||
val (a, b) = <caret>Some()
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Multi-declaration initializer of type some.Some must have a 'component2()' function
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.component1
|
||||
|
||||
fun testing() {
|
||||
val (a, b) = <caret>Some()
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
operator fun Some.component1() = 1
|
||||
operator fun Some.component2() = 3
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: Multi-declaration initializer of type some.Some must have a 'component2()' function
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.component1
|
||||
import some.component2
|
||||
|
||||
fun testing() {
|
||||
val (a, b) = <caret>Some()
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "false"
|
||||
// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function
|
||||
// ACTION: Create extension function 'component1'
|
||||
// ACTION: Create member function 'component1'
|
||||
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.component2
|
||||
|
||||
fun testing() {
|
||||
val (a, b) = <caret>Some()
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
fun Some.component1() = 1
|
||||
operator fun Some.component2() = 3
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// -- Empty file --
|
||||
@@ -0,0 +1,39 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "true"
|
||||
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
|
||||
fun testing() {
|
||||
var s = Some()
|
||||
s <caret>+= 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
operator fun Some.plus(i: Int) : Some = this
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.plus
|
||||
|
||||
fun testing() {
|
||||
var s = Some()
|
||||
s <caret>+= 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "true"
|
||||
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
|
||||
fun testing() {
|
||||
var s = Some()
|
||||
s <caret>+= 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
operator fun Some.plusAssign(i: Int) {}
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.plusAssign
|
||||
|
||||
fun testing() {
|
||||
var s = Some()
|
||||
s <caret>+= 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import" "true"
|
||||
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
|
||||
fun testing() {
|
||||
var s = Some()
|
||||
s <caret>+= 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: second.kt
|
||||
package some
|
||||
|
||||
public class Some
|
||||
|
||||
operator fun Some.plusAssign(i: Int) {}
|
||||
|
||||
// FILE: second.kt
|
||||
// Lexicography is before "some"
|
||||
package aaa
|
||||
|
||||
import some.Some
|
||||
|
||||
operator fun Some.plus(i: Int) : Some = this
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import" "true"
|
||||
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
|
||||
|
||||
package testing
|
||||
|
||||
import some.Some
|
||||
import some.plusAssign
|
||||
|
||||
fun testing() {
|
||||
var s = Some()
|
||||
s <caret>+= 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user