Add diagnostic on calling inner classes constructors without receiver

Otherwise there will be just an unresolved reference that doesn't give
any useful information

 #KT-8959 Fixed
This commit is contained in:
Denis Zharkov
2017-02-28 15:28:20 +03:00
parent 1e0ae04aba
commit a7fc32c8da
17 changed files with 133 additions and 37 deletions
@@ -0,0 +1,43 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// SKIP_TXT
// FILE: Outer.kt
package abc
class Outer {
inner class Inner() {
constructor(x: Int) : this() {}
}
companion object {
fun Inner(x: String) {}
fun baz() {
// Diagnostic here could be better (why can't I call the constructor above?)
Inner(<!NO_VALUE_FOR_PARAMETER!>)<!>
Inner(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
Inner("")
}
}
}
fun foo() {
Outer.Inner(<!NO_VALUE_FOR_PARAMETER!>)<!>
Outer.Inner(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
Outer.Inner("")
}
// FILE: imported.kt
import abc.Outer
import abc.Outer.Inner
import abc.Outer.Companion.Inner
fun bar() {
Inner(<!NO_VALUE_FOR_PARAMETER!>)<!>
Inner(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
Inner("")
with(Outer()) {
Inner()
Inner(1)
Inner("")
}
}