From ba9ea75f9ece85c8d4820ee739a9c01da474df82 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 10 Jan 2014 17:26:41 +0400 Subject: [PATCH] Change workaround for redeclaration problem Without this hack, redeclarations are reported when you try to rewrite *Range classes to Kotlin --- .../jet/lang/resolve/DeclarationResolver.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java index 04d77e86797..2fb1c74abf1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java @@ -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 simpleNameDescriptors = packageFragment.getMemberScope().getDeclaredDescriptorsAccessibleBySimpleName(); @@ -357,16 +366,7 @@ public class DeclarationResolver { Collection 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() {