Auto-imports for operator calls and infix calls

#KT-1613 Fixed
 #KT-4192 Fixed

Enable auto-import fix for "unresolved reference with wrong receiver" diagnostic
This commit is contained in:
Pavel V. Talanov
2013-12-30 18:15:49 +04:00
parent 63abe860d6
commit e693820fb4
29 changed files with 255 additions and 9 deletions
@@ -0,0 +1,10 @@
// "Import" "true"
// ERROR: Unresolved reference: /
import util.div
trait H
fun f(h: H) {
h / 3
}
@@ -0,0 +1,8 @@
// "Import" "true"
// ERROR: Unresolved reference: /
trait H
fun f(h: H) {
h <caret>/ 3
}
@@ -0,0 +1,3 @@
package util
fun H.div(i: Int) = 3
@@ -0,0 +1,10 @@
// "Import" "true"
// ERROR: Unresolved reference: foo
import util.foo
trait H
fun f(h: H) {
h foo h
}
@@ -0,0 +1,8 @@
// "Import" "true"
// ERROR: Unresolved reference: foo
trait H
fun f(h: H) {
h <caret>foo h
}
@@ -0,0 +1,3 @@
package util
fun H.foo(other: H) = ""
@@ -0,0 +1,15 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>internal</b> <b>fun</b> jet.String.minus(str: jet.String): jet.String <i>defined in</i> root package</li><li><b>internal</b> <b>fun</b> jet.String.minus(i: java.lang.Integer): jet.String <i>defined in</i> root package</li></ul></html>
import util.minus
trait H
fun f(h: H?) {
h - "other"
}
fun String.minus(str: String) = ""
fun String.minus(i: Integer) = ""
@@ -0,0 +1,13 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>internal</b> <b>fun</b> jet.String.minus(str: jet.String): jet.String <i>defined in</i> root package</li><li><b>internal</b> <b>fun</b> jet.String.minus(i: java.lang.Integer): jet.String <i>defined in</i> root package</li></ul></html>
trait H
fun f(h: H?) {
h <caret>- "other"
}
fun String.minus(str: String) = ""
fun String.minus(i: Integer) = ""
@@ -0,0 +1,3 @@
package util
fun H?.minus(s: String) = ""
@@ -0,0 +1,10 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> <b>fun</b> jet.String?.plus(other: jet.Any?): jet.String <i>defined in</i> jet</li></ul></html>
import util.plus
trait H
fun f(h: H?) {
h + "other"
}
@@ -0,0 +1,8 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> <b>fun</b> jet.String?.plus(other: jet.Any?): jet.String <i>defined in</i> jet</li></ul></html>
trait H
fun f(h: H?) {
h <caret>+ "other"
}
@@ -0,0 +1,3 @@
package util
fun H?.plus(s: String) = ""
@@ -0,0 +1,11 @@
// "Import" "true"
// ERROR: Unresolved reference: ++
import util.inc
trait H
fun f(h: H?) {
var h1 = h
h1++
}
@@ -0,0 +1,9 @@
// "Import" "true"
// ERROR: Unresolved reference: ++
trait H
fun f(h: H?) {
var h1 = h
h1<caret>++
}
@@ -0,0 +1,4 @@
package util
fun H.inc(): H {
}
@@ -0,0 +1,10 @@
// "Import" "true"
// ERROR: Unresolved reference: *=
import util.timesAssign
trait H
fun f(h: H) {
h *= 3
}
@@ -0,0 +1,8 @@
// "Import" "true"
// ERROR: Unresolved reference: *=
trait H
fun f(h: H) {
h <caret>*= 3
}
@@ -0,0 +1,4 @@
package util
fun H.div(i: Int) = 3
fun H.timesAssign(i: Int) {}
@@ -0,0 +1,10 @@
// "Import" "true"
// ERROR: Unresolved reference: -
import util.minus
trait H
fun f(h: H?) {
-h
}
@@ -0,0 +1,8 @@
// "Import" "true"
// ERROR: Unresolved reference: -
trait H
fun f(h: H?) {
<caret>-h
}
@@ -0,0 +1,3 @@
package util
fun H?.minus() = ""
@@ -0,0 +1,14 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>internal</b> <b>fun</b> A.plus(): jet.Int <i>defined in</i> root package</li><li><b>public</b> <b>fun</b> jet.String?.plus(other: jet.Any?): jet.String <i>defined in</i> jet</li></ul></html>
import util.plus
trait H
fun f(h: H?) {
+h
}
class A()
fun A.plus(): Int = 3
@@ -0,0 +1,12 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>internal</b> <b>fun</b> A.plus(): jet.Int <i>defined in</i> root package</li><li><b>public</b> <b>fun</b> jet.String?.plus(other: jet.Any?): jet.String <i>defined in</i> jet</li></ul></html>
trait H
fun f(h: H?) {
<caret>+h
}
class A()
fun A.plus(): Int = 3
@@ -0,0 +1,3 @@
package util
fun H.plus() = ""