Completion: when Unit is expected do not prioritize by return type

Decide on completion order by other factors
Previously would prefer callable that return Unit if Unit is the expected type
    leading to strange completion order

 #KT-25588 Fixed
This commit is contained in:
Pavel V. Talanov
2018-08-07 20:46:13 +02:00
parent 51681d57c8
commit 0c1d25d5ac
13 changed files with 120 additions and 12 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ fun main() {
// ORDER: foo2
// ORDER: foo4
// ORDER: fooloooooong
// ORDER: foo3
// ORDER: foo5
// ORDER: foo3
// ORDER: fooval
// ORDER: foo1
@@ -14,7 +14,7 @@ fun main() {
// ORDER: foo2
// ORDER: foo4
// ORDER: fooloooooong
// ORDER: foo3
// ORDER: foo5
// ORDER: foo3
// ORDER: fooval
// ORDER: foo1
@@ -36,6 +36,6 @@ fun foo1(i: Int) {
}
// ORDER: foo2
// ORDER: foo5
// ORDER: foo10
// ORDER: foo1
// ORDER: foo5
@@ -11,10 +11,10 @@ fun main() {
}
}
// ORDER: foo6
// ORDER: foo2
// ORDER: foo3
// ORDER: foo6
// ORDER: foo4
// ORDER: foo1
// ORDER: fooLocal
// ORDER: foo5
// ORDER: foo1
@@ -0,0 +1,31 @@
// RUNTIME_WITH_SCRIPT_RUNTIME
@DslMarker
annotation class MyDsl
project1 {
<caret>
}
@MyDsl
fun project1(p: Project.() -> Unit) {
Project(p)
}
@MyDsl
fun project2(p: Project.() -> Unit): Project {
return Project(p)
}
@MyDsl
fun Project.buildType(init: BuildType.() -> Unit): BuildType {
return BuildType(this, init)
}
@MyDsl
class Project(init: Project.() -> Unit)
@MyDsl
class BuildType(p: Project, init: BuildType.() -> Unit)
// ORDER: buildType, project1, project2
@@ -0,0 +1,32 @@
// RUNTIME_WITH_SCRIPT_RUNTIME
@DslMarker
annotation class MyDsl
project1 {
<caret>
}
@MyDsl
fun project1(p: Project.() -> Unit): Project {
Project(p)
}
@MyDsl
fun project2(p: Project.() -> Unit) {
Project(p)
}
@MyDsl
class Project(init: Project.() -> Unit) {
@MyDsl
fun buildType(init: BuildType.() -> Unit): BuildType {
return BuildType(this, init)
}
}
@MyDsl
class BuildType(p: Project, init: BuildType.() -> Unit)
// ORDER: buildType, project1, project2
@@ -0,0 +1,29 @@
// RUNTIME
class A {
fun fooA() {
}
}
class B {
fun fooB(): Int {
return 3
}
}
fun <T> myWith(t: T, init: T.() -> Unit) {
}
fun main() {
myWith (A()) {
myWith (B()) {
foo<caret>
}
}
}
// fooB should be first because it's receiver is closer, expected return type is Unit and should be taken into account
// ORDER: fooB, fooA