Change Signature: Consider default value context an initial type context. Use parameter list as a type context for bodyless function
#KT-12413 Fixed (cherry picked from commit f417b05)
This commit is contained in:
@@ -113,6 +113,12 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
|||||||
- [`KT-13037`](https://youtrack.jetbrains.com/issue/KT-13037) Fix possible deadlock in debugger in 2016.1 and exception in 2016.2
|
- [`KT-13037`](https://youtrack.jetbrains.com/issue/KT-13037) Fix possible deadlock in debugger in 2016.1 and exception in 2016.2
|
||||||
- [`KT-12651`](https://youtrack.jetbrains.com/issue/KT-12651) Fix exception in evaluate expression when bad identifier is used for marking object
|
- [`KT-12651`](https://youtrack.jetbrains.com/issue/KT-12651) Fix exception in evaluate expression when bad identifier is used for marking object
|
||||||
|
|
||||||
|
#### Refactorings
|
||||||
|
|
||||||
|
###### Issues fixed
|
||||||
|
|
||||||
|
- [`KT-12413`](https://youtrack.jetbrains.com/issue/KT-12413) Change Signature: Fix bogus warning about unresolved type parameters/invalid functional type replacement
|
||||||
|
|
||||||
## 1.0.3
|
## 1.0.3
|
||||||
|
|
||||||
### Compiler
|
### Compiler
|
||||||
|
|||||||
+7
-7
@@ -72,7 +72,7 @@ class CodeFragmentAnalyzer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: this code should be moved into debugger which should set correct context for its code fragment
|
//TODO: this code should be moved into debugger which should set correct context for its code fragment
|
||||||
private fun KtExpression.correctContextForExpression(): KtExpression {
|
private fun KtElement.correctContextForElement(): KtElement {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is KtProperty -> this.delegateExpressionOrInitializer
|
is KtProperty -> this.delegateExpressionOrInitializer
|
||||||
is KtFunctionLiteral -> this.bodyExpression?.statements?.lastOrNull()
|
is KtFunctionLiteral -> this.bodyExpression?.statements?.lastOrNull()
|
||||||
@@ -112,18 +112,18 @@ class CodeFragmentAnalyzer(
|
|||||||
scopeForContextElement = descriptor.scopeForMemberDeclarationResolution
|
scopeForContextElement = descriptor.scopeForMemberDeclarationResolution
|
||||||
dataFlowInfo = DataFlowInfo.EMPTY
|
dataFlowInfo = DataFlowInfo.EMPTY
|
||||||
}
|
}
|
||||||
is KtExpression -> {
|
is KtFile -> {
|
||||||
val correctedContext = context.correctContextForExpression()
|
scopeForContextElement = resolveSession.fileScopeProvider.getFileResolutionScope(context)
|
||||||
|
dataFlowInfo = DataFlowInfo.EMPTY
|
||||||
|
}
|
||||||
|
is KtElement -> {
|
||||||
|
val correctedContext = context.correctContextForElement()
|
||||||
|
|
||||||
val contextForElement = resolveToElement(correctedContext)
|
val contextForElement = resolveToElement(correctedContext)
|
||||||
|
|
||||||
scopeForContextElement = contextForElement[BindingContext.LEXICAL_SCOPE, correctedContext]
|
scopeForContextElement = contextForElement[BindingContext.LEXICAL_SCOPE, correctedContext]
|
||||||
dataFlowInfo = contextForElement.getDataFlowInfo(correctedContext)
|
dataFlowInfo = contextForElement.getDataFlowInfo(correctedContext)
|
||||||
}
|
}
|
||||||
is KtFile -> {
|
|
||||||
scopeForContextElement = resolveSession.fileScopeProvider.getFileResolutionScope(context)
|
|
||||||
dataFlowInfo = DataFlowInfo.EMPTY
|
|
||||||
}
|
|
||||||
else -> return null
|
else -> return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -54,6 +54,7 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinMethodDescrip
|
|||||||
import org.jetbrains.kotlin.idea.refactoring.validateElement
|
import org.jetbrains.kotlin.idea.refactoring.validateElement
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
import org.jetbrains.kotlin.psi.psiUtil.parents
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
@@ -407,9 +408,9 @@ class KotlinChangeSignatureDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getTypeCodeFragmentContext(startFrom: PsiElement): KtElement {
|
private fun getTypeCodeFragmentContext(startFrom: PsiElement): KtElement {
|
||||||
return startFrom.parents.mapNotNull {
|
return startFrom.parentsWithSelf.mapNotNull {
|
||||||
when {
|
when {
|
||||||
it is KtNamedFunction -> it.bodyExpression
|
it is KtNamedFunction -> it.bodyExpression ?: it.valueParameterList
|
||||||
it is KtPropertyAccessor -> it.bodyExpression
|
it is KtPropertyAccessor -> it.bodyExpression
|
||||||
it is KtDeclaration && KtPsiUtil.isLocal(it) -> null
|
it is KtDeclaration && KtPsiUtil.isLocal(it) -> null
|
||||||
it is KtConstructor<*> -> it
|
it is KtConstructor<*> -> it
|
||||||
|
|||||||
Reference in New Issue
Block a user