Change workaround for redeclaration problem
Without this hack, redeclarations are reported when you try to rewrite *Range classes to Kotlin
This commit is contained in:
@@ -319,6 +319,15 @@ public class DeclarationResolver {
|
||||
|
||||
private void checkRedeclarationsInNamespaces() {
|
||||
for (MutablePackageFragmentDescriptor packageFragment : Sets.newHashSet(context.getPackageFragments().values())) {
|
||||
if (KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(packageFragment.getFqName())) {
|
||||
// TODO: drop this after built-ins are fully rewritten to Kotlin
|
||||
// At the moment, there are Java classes for ranges (e.g. IntRange.java) which contain static members. If someone tries to
|
||||
// rewrite IntRange to Kotlin, redeclaration will be reported because there are both class (from the Kotlin sources) and
|
||||
// package (from static members of Java class present in kotlin-runtime.jar) for FQ name "jet.IntRange".
|
||||
// Will be safe to drop once there are no Java classes duplicating sources of Kotlin built-ins
|
||||
continue;
|
||||
}
|
||||
|
||||
PackageViewDescriptor packageView = packageFragment.getContainingDeclaration().getPackage(packageFragment.getFqName());
|
||||
JetScope packageViewScope = packageView.getMemberScope();
|
||||
Multimap<Name, DeclarationDescriptor> simpleNameDescriptors = packageFragment.getMemberScope().getDeclaredDescriptorsAccessibleBySimpleName();
|
||||
@@ -357,16 +366,7 @@ public class DeclarationResolver {
|
||||
Collection<JetFile> files = trace.get(BindingContext.PACKAGE_TO_FILES, aPackage.getFqName());
|
||||
|
||||
if (files == null) {
|
||||
// TODO: uncomment this after built-ins are fully rewritten to Kotlin
|
||||
// At the moment, there are Java classes for ranges (e.g. IntRange.java) which contain static members. If someone tries to
|
||||
// rewrite IntRange to Kotlin, this exception will be thrown because there are both class (from the Kotlin sources) and
|
||||
// package (from static members of Java class present in kotlin-runtime.jar) for FQ name "jet.IntRange", but no sources
|
||||
// correspond to the package.
|
||||
// Will be safe to uncomment once there are no Java classes duplicating sources of Kotlin built-ins
|
||||
|
||||
// throw new IllegalStateException("declarations corresponding to " + aPackage + " are not found");
|
||||
|
||||
return Collections.emptySet();
|
||||
throw new IllegalStateException("declarations corresponding to " + aPackage + " are not found");
|
||||
}
|
||||
|
||||
declarations = Collections2.transform(files, new Function<JetFile, PsiElement>() {
|
||||
|
||||
Reference in New Issue
Block a user