Return error class in case we are not able to find class for object property
This commit is contained in:
+6
-2
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.storage.StorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -201,8 +202,11 @@ public class DescriptorDeserializer {
|
||||
FqNameUnsafe fqName = DescriptorUtils.getFQName(containingDeclaration).child(name);
|
||||
ClassId objectId = ClassId.fromFqNameAndContainingDeclaration(fqName, (ClassOrNamespaceDescriptor) containingDeclaration);
|
||||
ClassDescriptor objectClass = typeDeserializer.getDescriptorFinder().findClass(objectId);
|
||||
assert objectClass != null : "Object for property not found: " + name;
|
||||
|
||||
if (objectClass == null) {
|
||||
// if we are not able to find the class for object property
|
||||
// then something bad has happened since they should be in the same jar
|
||||
objectClass = ErrorUtils.createErrorClass(objectId.asSingleFqName().asString());
|
||||
}
|
||||
return new PropertyDescriptorForObjectImpl(containingDeclaration, annotations, visibility, name, objectClass);
|
||||
}
|
||||
|
||||
|
||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
package test
|
||||
+13
@@ -43,4 +43,17 @@ public final class CompileKotlinAgainstBinariesCustomTest extends AbstractCompil
|
||||
Assert.assertFalse("Object property should have valid class", ErrorUtils.isError(((VariableDescriptorForObject) descriptor).getObjectClass()));
|
||||
}
|
||||
}
|
||||
|
||||
public void testBrokenJarWithNoClassForObjectProperty() throws Exception {
|
||||
BindingContext context = analyzeFile(new File(
|
||||
"compiler/testData/compileKotlinAgainstBinariesCustom/brokenJarWithNoClassForObjectProperty/brokenJarWithNoClassForObjectProperty.kt"));
|
||||
NamespaceDescriptor namespaceDescriptor = context.get(FQNAME_TO_NAMESPACE_DESCRIPTOR, TEST_PACKAGE_FQNAME);
|
||||
assert namespaceDescriptor != null;
|
||||
Collection<DeclarationDescriptor> allDescriptors = namespaceDescriptor.getMemberScope().getAllDescriptors();
|
||||
Assert.assertEquals(allDescriptors.size(), 1);
|
||||
DeclarationDescriptor descriptor = allDescriptors.iterator().next();
|
||||
Assert.assertTrue(descriptor.getName().asString().equals("Lol"));
|
||||
Assert.assertTrue(descriptor instanceof VariableDescriptorForObject);
|
||||
Assert.assertTrue("Object property should have an error class", ErrorUtils.isError(((VariableDescriptorForObject) descriptor).getObjectClass()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user