Report incomplete hierarchy error

This is the case when you reference a Java class in Kotlin whose superclass is
not resolved. Previously this fact was swallowed by LazyJavaClassDescriptor
leading to mysterious compilation errors

 #KT-5129 Fixed
This commit is contained in:
Alexander Udalov
2015-02-09 17:28:02 +03:00
parent 28d8c8906a
commit 4128655893
12 changed files with 111 additions and 23 deletions
@@ -104,12 +104,16 @@ public final class AnalyzerWithCompilerReport {
private void reportIncompleteHierarchies() {
assert analysisResult != null;
Collection<ClassDescriptor> incompletes = analysisResult.getBindingContext().getKeys(BindingContext.INCOMPLETE_HIERARCHY);
if (!incompletes.isEmpty()) {
BindingContext bindingContext = analysisResult.getBindingContext();
Collection<ClassDescriptor> classes = bindingContext.getKeys(TraceBasedErrorReporter.INCOMPLETE_HIERARCHY);
if (!classes.isEmpty()) {
StringBuilder message = new StringBuilder("The following classes have incomplete hierarchies:\n");
for (ClassDescriptor incomplete : incompletes) {
String fqName = DescriptorUtils.getFqName(incomplete).asString();
message.append(" ").append(fqName).append("\n");
for (ClassDescriptor descriptor : classes) {
String fqName = DescriptorUtils.getFqName(descriptor).asString();
List<String> unresolved = bindingContext.get(TraceBasedErrorReporter.INCOMPLETE_HIERARCHY, descriptor);
assert unresolved != null && !unresolved.isEmpty() :
"Incomplete hierarchy should be reported with names of unresolved superclasses: " + fqName;
message.append(" ").append(fqName).append(", unresolved: ").append(unresolved).append("\n");
}
messageCollectorWrapper.report(CompilerMessageSeverity.ERROR, message.toString(), CompilerMessageLocation.NO_LOCATION);
}