Improve error message on error types in JetTypeMapper
#KT-6684
This commit is contained in:
@@ -352,26 +352,34 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private String generateErrorMessageForErrorType(@NotNull JetType type, @NotNull DeclarationDescriptor descriptor) {
|
private static String generateErrorMessageForErrorType(@NotNull JetType type, @NotNull DeclarationDescriptor descriptor) {
|
||||||
PsiElement declarationElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
PsiElement declarationElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||||
PsiElement parentDeclarationElement = null;
|
|
||||||
if (declarationElement != null) {
|
if (declarationElement == null) {
|
||||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
return String.format(
|
||||||
if (containingDeclaration != null) {
|
"Error type encountered: %s (%s). " +
|
||||||
parentDeclarationElement = DescriptorToSourceUtils.descriptorToDeclaration(containingDeclaration);
|
"One of the possible reasons may be that this type is not directly accessible from this module. " +
|
||||||
}
|
"To workaround this error, try adding an explicit dependency on the module or library which contains this type " +
|
||||||
|
"to the classpath",
|
||||||
|
type,
|
||||||
|
type.getClass().getSimpleName()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.format("Error types are not allowed when classBuilderMode = %s. " +
|
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||||
"Type: %s (%s). Descriptor: %s. For declaration %s:%s in %s:%s",
|
PsiElement parentDeclarationElement =
|
||||||
classBuilderMode,
|
containingDeclaration != null ? DescriptorToSourceUtils.descriptorToDeclaration(containingDeclaration) : null;
|
||||||
type,
|
|
||||||
type.getClass().getSimpleName(),
|
return String.format(
|
||||||
descriptor,
|
"Error type encountered: %s (%s). Descriptor: %s. For declaration %s:%s in %s:%s",
|
||||||
declarationElement,
|
type,
|
||||||
declarationElement != null ? declarationElement.getText() : "null",
|
type.getClass().getSimpleName(),
|
||||||
parentDeclarationElement,
|
descriptor,
|
||||||
parentDeclarationElement != null ? parentDeclarationElement.getText() : "null");
|
declarationElement,
|
||||||
|
declarationElement.getText(),
|
||||||
|
parentDeclarationElement,
|
||||||
|
parentDeclarationElement != null ? parentDeclarationElement.getText() : "null"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeGenericType(
|
private void writeGenericType(
|
||||||
|
|||||||
Reference in New Issue
Block a user