Files
kotlin-fork/compiler/testData/diagnostics/tests/recovery/namelessInJava.kt
T
Dmitry Savvinov bd9254597d Fix testdata after switching idea version to 182
The source of testdata change is following commit from the
intellij-community repo:

d2bfe3d14bfa48af585f1faddc9a0c37dc05e724

It changes how Java-resolution resolves constructors:
- before, *any* PsiMethod without type reference was treated as
constructor
- now, PsiMethod without type reference is treated as constructor
only if their *names also match*

In particular, in this test, 'void () {}', surprisingly, doesn't have a
type reference ('void' is parsed as PsiErrorElement:Identifier
expected), its name is '<unnamed>', and its visibility is
'package-private' (!)

Therefore, previously we thought that 'Nameless' has package-private
constructor and were reporting INVISIBLE_MEMBER.
Now we don't see any constructor so we add default constructor, which has
public-visibility -> error is gone.

Note that this change affects behavior only when "red" code is already
present in the project (for "green" code, assumption "method without type
reference is a constructor" is indeed correct).
2018-08-07 10:18:25 +03:00

18 lines
240 B
Kotlin
Vendored

// JAVAC_SKIP
// FILE: p/Nameless.java
package p;
public class Nameless {
void () {}
int ;
}
// FILE: k.kt
import p.*
class K : Nameless() {
<!FUNCTION_DECLARATION_WITH_NO_NAME!>fun ()<!> {}
val<!SYNTAX!><!> : Int = 1
}