Prohibit creation of JetLightClass on built-ins

If we allow JetLightClass to be created on built-in types, a normal codegen
would be launched, with a mapping from Kotlin to Java types enabled, every time
IDE requests built-in classes. Codegen would then try to make something
meaningless, e.g. create a class for a primitive type (since our jet.Boolean is
mapped to primitive boolean). This would result in different exceptions when
navigating to built-in library from IDE.

Add a helpful error message to ClassFileFactory if we ever again produce
classes for primitive types.
This commit is contained in:
Alexander Udalov
2012-09-11 16:03:33 +04:00
parent 4eea0cafb9
commit bb92655ecd
11 changed files with 129 additions and 39 deletions
@@ -542,4 +542,13 @@ public class JetStandardClasses {
public static Collection<DeclarationDescriptor> getAllStandardClasses() {
return STANDARD_CLASSES.getAllDescriptors();
}
public static boolean isStandardClass(@NotNull FqName fqName) {
for (DeclarationDescriptor descriptor : getAllStandardClasses()) {
if (DescriptorUtils.getFQName(descriptor).equals(fqName.toUnsafe())) {
return true;
}
}
return false;
}
}