Fix local delegated property smartcast usage

This commit is contained in:
Ilya Gorbunov
2018-06-22 20:49:52 +03:00
parent 80f022c3d5
commit bed26dc700
3 changed files with 11 additions and 12 deletions
@@ -124,15 +124,14 @@ class BasicLookupElementFactory(
includeClassTypeArguments: Boolean, includeClassTypeArguments: Boolean,
parametersAndTypeGrayed: Boolean parametersAndTypeGrayed: Boolean
): LookupElement { ): LookupElement {
val declarationLazy by lazy { DescriptorToSourceUtilsIde.getAnyDeclaration(project, descriptor) } if (descriptor is JavaClassDescriptor) {
val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, descriptor)
if (descriptor is JavaClassDescriptor && if (declaration is PsiClass && declaration !is KtLightClass) {
declarationLazy is PsiClass && // for java classes we create special lookup elements
declarationLazy !is KtLightClass) { // because they must be equal to ones created in TypesCompletion
// for java classes we create special lookup elements // otherwise we may have duplicates
// because they must be equal to ones created in TypesCompletion return createLookupElementForJavaClass(declaration, qualifyNestedClasses, includeClassTypeArguments)
// otherwise we may have duplicates }
return createLookupElementForJavaClass(declarationLazy, qualifyNestedClasses, includeClassTypeArguments)
} }
if (descriptor is PackageViewDescriptor) { if (descriptor is PackageViewDescriptor) {
@@ -182,10 +182,10 @@ fun KtElement.processInternalReferencesToUpdateOnPackageNameChange(
val isImported = isImported(descriptor) val isImported = isImported(descriptor)
if (isImported && this is KtFile) return null if (isImported && this is KtFile) return null
if (declaration == null) return null val declarationNotNull = declaration ?: return null
if (isExtension || containerFqName != null || isImported) return { if (isExtension || containerFqName != null || isImported) return {
createMoveUsageInfoIfPossible(it.mainReference, declaration, false, true) createMoveUsageInfoIfPossible(it.mainReference, declarationNotNull, false, true)
} }
return null return null
@@ -793,7 +793,7 @@ class ClassFileToSourceStubConverter(
private fun convertAnnotationArgument(constantValue: Any?, value: ResolvedValueArgument?): JCExpression? { private fun convertAnnotationArgument(constantValue: Any?, value: ResolvedValueArgument?): JCExpression? {
val args = value?.arguments?.mapNotNull { it.getArgumentExpression() } ?: emptyList() val args = value?.arguments?.mapNotNull { it.getArgumentExpression() } ?: emptyList()
val singleArg by lazy { args.singleOrNull() } val singleArg = args.singleOrNull()
if (constantValue.isOfPrimiviteType()) { if (constantValue.isOfPrimiviteType()) {
// Do not inline primitive constants // Do not inline primitive constants