Safe identifier for the case of no name in PSI moved to 'descriptors' module, to be used in 'descriptor.loader.java'

This commit is contained in:
Andrey Breslav
2014-06-10 12:47:46 +04:00
parent bb581bb645
commit d2ce6f5787
6 changed files with 42 additions and 16 deletions
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.psi.JetNamedDeclarationUtil;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.name.NamePackage;
import org.jetbrains.jet.lang.resolve.name.SpecialNames;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import java.util.Collection;
@@ -36,12 +37,6 @@ import java.util.Collections;
public class ResolveSessionUtils {
// This name is used as a key for the case when something has no name _due to a syntactic error_
// Example: fun (x: Int) = 5
// There's no name for this function in the PSI
// The name contains a GUID to avoid clashes, if a clash happens, it's not a big deal: the code does not compile anyway
public static final Name NO_NAME_FOR_LAZY_RESOLVE = Name.identifier("no_name_in_PSI_for_lazy_resolve_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40");
public static final Predicate<ClassDescriptor> NON_SINGLETON_FILTER = new Predicate<ClassDescriptor>() {
@Override
public boolean apply(@Nullable ClassDescriptor descriptor) {
@@ -148,7 +143,7 @@ public class ResolveSessionUtils {
@NotNull
public static Name safeNameForLazyResolve(@Nullable Name name) {
return name != null && !name.isSpecial() ? name : NO_NAME_FOR_LAZY_RESOLVE;
return SpecialNames.safeIdentifier(name);
}
@Nullable
@@ -0,0 +1,17 @@
// FILE: p/Nameless.java
package p;
public class Nameless {
void () {}
int ;
}
// FILE: k.kt
import p.*
class K : Nameless() {
fun<!SYNTAX!><!> () {}
val<!SYNTAX!><!> : Int = 1
}
@@ -5911,6 +5911,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/recovery"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("namelessInJava.kt")
public void testNamelessInJava() throws Exception {
doTest("compiler/testData/diagnostics/tests/recovery/namelessInJava.kt");
}
@TestMetadata("namelessMembers.kt")
public void testNamelessMembers() throws Exception {
doTest("compiler/testData/diagnostics/tests/recovery/namelessMembers.kt");