Do not resolve all bodies of anonymous objects and local classes in partial body resolve
This commit is contained in:
@@ -106,6 +106,7 @@ fun createContainerForLazyLocalClassifierAnalyzer(
|
|||||||
platform: TargetPlatform,
|
platform: TargetPlatform,
|
||||||
lookupTracker: LookupTracker,
|
lookupTracker: LookupTracker,
|
||||||
languageVersionSettings: LanguageVersionSettings,
|
languageVersionSettings: LanguageVersionSettings,
|
||||||
|
statementFilter: StatementFilter,
|
||||||
localClassDescriptorHolder: LocalClassDescriptorHolder
|
localClassDescriptorHolder: LocalClassDescriptorHolder
|
||||||
): StorageComponentContainer = createContainer("LocalClassifierAnalyzer", platform) {
|
): StorageComponentContainer = createContainer("LocalClassifierAnalyzer", platform) {
|
||||||
configureModule(moduleContext, platform, bindingTrace)
|
configureModule(moduleContext, platform, bindingTrace)
|
||||||
@@ -125,6 +126,7 @@ fun createContainerForLazyLocalClassifierAnalyzer(
|
|||||||
useImpl<LocalLazyDeclarationResolver>()
|
useImpl<LocalLazyDeclarationResolver>()
|
||||||
|
|
||||||
useInstance(languageVersionSettings)
|
useInstance(languageVersionSettings)
|
||||||
|
useInstance(statementFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createContainerForLazyResolve(
|
fun createContainerForLazyResolve(
|
||||||
|
|||||||
+5
-5
@@ -35,7 +35,7 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
@NotNull DataFlowInfo dataFlowInfo,
|
@NotNull DataFlowInfo dataFlowInfo,
|
||||||
@NotNull KotlinType expectedType
|
@NotNull KotlinType expectedType
|
||||||
) {
|
) {
|
||||||
return newContext(trace, scope, dataFlowInfo, expectedType, ContextDependency.INDEPENDENT);
|
return newContext(trace, scope, dataFlowInfo, expectedType, ContextDependency.INDEPENDENT, StatementFilter.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -44,11 +44,11 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@NotNull DataFlowInfo dataFlowInfo,
|
@NotNull DataFlowInfo dataFlowInfo,
|
||||||
@NotNull KotlinType expectedType,
|
@NotNull KotlinType expectedType,
|
||||||
@NotNull ContextDependency contextDependency
|
@NotNull ContextDependency contextDependency,
|
||||||
|
@NotNull StatementFilter statementFilter
|
||||||
) {
|
) {
|
||||||
return newContext(trace, scope, dataFlowInfo, expectedType,
|
return newContext(trace, scope, dataFlowInfo, expectedType, contextDependency,
|
||||||
contextDependency, new ResolutionResultsCacheImpl(),
|
new ResolutionResultsCacheImpl(), statementFilter, false);
|
||||||
StatementFilter.NONE, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+1
-1
@@ -106,7 +106,7 @@ public class ExpressionTypingServices {
|
|||||||
@NotNull ContextDependency contextDependency
|
@NotNull ContextDependency contextDependency
|
||||||
) {
|
) {
|
||||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||||
trace, scope, dataFlowInfo, expectedType, contextDependency
|
trace, scope, dataFlowInfo, expectedType, contextDependency, statementFilter
|
||||||
);
|
);
|
||||||
if (contextExpression != expression) {
|
if (contextExpression != expression) {
|
||||||
context = context.replaceExpressionContextProvider(new Function1<KtExpression, KtExpression>() {
|
context = context.replaceExpressionContextProvider(new Function1<KtExpression, KtExpression>() {
|
||||||
|
|||||||
+3
-2
@@ -52,7 +52,7 @@ class LocalClassifierAnalyzer(
|
|||||||
private val globalContext: GlobalContext,
|
private val globalContext: GlobalContext,
|
||||||
private val storageManager: StorageManager,
|
private val storageManager: StorageManager,
|
||||||
private val descriptorResolver: DescriptorResolver,
|
private val descriptorResolver: DescriptorResolver,
|
||||||
private val funcionDescriptorResolver: FunctionDescriptorResolver,
|
private val functionDescriptorResolver: FunctionDescriptorResolver,
|
||||||
private val typeResolver: TypeResolver,
|
private val typeResolver: TypeResolver,
|
||||||
private val annotationResolver: AnnotationResolver,
|
private val annotationResolver: AnnotationResolver,
|
||||||
private val platform: TargetPlatform,
|
private val platform: TargetPlatform,
|
||||||
@@ -74,6 +74,7 @@ class LocalClassifierAnalyzer(
|
|||||||
platform,
|
platform,
|
||||||
lookupTracker,
|
lookupTracker,
|
||||||
languageVersionSettings,
|
languageVersionSettings,
|
||||||
|
context.statementFilter,
|
||||||
LocalClassDescriptorHolder(
|
LocalClassDescriptorHolder(
|
||||||
scope,
|
scope,
|
||||||
classOrObject,
|
classOrObject,
|
||||||
@@ -82,7 +83,7 @@ class LocalClassifierAnalyzer(
|
|||||||
context,
|
context,
|
||||||
module,
|
module,
|
||||||
descriptorResolver,
|
descriptorResolver,
|
||||||
funcionDescriptorResolver,
|
functionDescriptorResolver,
|
||||||
typeResolver,
|
typeResolver,
|
||||||
annotationResolver,
|
annotationResolver,
|
||||||
supertypeLoopChecker,
|
supertypeLoopChecker,
|
||||||
|
|||||||
@@ -7,18 +7,18 @@ open class C(p: Int) {
|
|||||||
fun foo(p: String?) {
|
fun foo(p: String?) {
|
||||||
val o = object : Runnable {
|
val o = object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (p == null) return
|
/* STATEMENT DELETED: if (p == null) return */
|
||||||
print(p.size)
|
/* STATEMENT DELETED: print(p.length) */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val c = object : C(p!!.size) {
|
val c = object : C(p!!.size) {
|
||||||
override fun f() {
|
override fun f() {
|
||||||
super.f()
|
/* STATEMENT DELETED: super.f() */
|
||||||
if (p == null) return
|
/* STATEMENT DELETED: if (p == null) return */
|
||||||
print(p.size)
|
/* STATEMENT DELETED: print(p.length) */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<caret>p?.size
|
<caret>p?.length
|
||||||
}
|
}
|
||||||
@@ -5,15 +5,15 @@ open class C(p: Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun foo(p: String?) {
|
fun foo(p: String?) {
|
||||||
/* STATEMENT DELETED: val o = object : Runnable { override fun run() { if (p == null) return print(p.size) } } */
|
/* STATEMENT DELETED: val o = object : Runnable { override fun run() { if (p == null) return print(p.length) } } */
|
||||||
|
|
||||||
val c = object : C(p!!.size) {
|
val c = object : C(p!!.size) {
|
||||||
override fun f() {
|
override fun f() {
|
||||||
super.f()
|
/* STATEMENT DELETED: super.f() */
|
||||||
if (p == null) return
|
/* STATEMENT DELETED: if (p == null) return */
|
||||||
print(p.size)
|
/* STATEMENT DELETED: print(p.length) */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<caret>p?.size
|
<caret>p?.length
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ fun foo(p: String?) {
|
|||||||
val o = object : Runnable {
|
val o = object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (p == null) return
|
if (p == null) return
|
||||||
print(p.size)
|
print(p.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,9 +14,9 @@ fun foo(p: String?) {
|
|||||||
override fun f() {
|
override fun f() {
|
||||||
super.f()
|
super.f()
|
||||||
if (p == null) return
|
if (p == null) return
|
||||||
print(p.size)
|
print(p.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<caret>p?.size
|
<caret>p?.length
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
Resolve target: val length: kotlin.Int
|
||||||
|
----------------------------------------------
|
||||||
|
open class C(p: Int) {
|
||||||
|
open fun f(){}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(p1: String?, p2: String?) {
|
||||||
|
if (p1 == null) return
|
||||||
|
/* STATEMENT DELETED: println(p1) */
|
||||||
|
|
||||||
|
val c = object : C(p1.length) {
|
||||||
|
override fun f() {
|
||||||
|
/* STATEMENT DELETED: super.f() */
|
||||||
|
if (p2 == null) return
|
||||||
|
print(p2.<caret>length)
|
||||||
|
/* STATEMENT DELETED: bar() */
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar() {
|
||||||
|
/* STATEMENT DELETED: print(1) */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
open class C(p: Int) {
|
||||||
|
open fun f(){}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(p1: String?, p2: String?) {
|
||||||
|
if (p1 == null) return
|
||||||
|
println(p1)
|
||||||
|
|
||||||
|
val c = object : C(p1.length) {
|
||||||
|
override fun f() {
|
||||||
|
super.f()
|
||||||
|
if (p2 == null) return
|
||||||
|
print(p2.<caret>length)
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar() {
|
||||||
|
print(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,9 +3,9 @@ Resolve target: value-parameter p: kotlin.String?
|
|||||||
fun foo(p: String?) {
|
fun foo(p: String?) {
|
||||||
class LocalClass {
|
class LocalClass {
|
||||||
fun f(): String? {
|
fun f(): String? {
|
||||||
if (p == null) return null
|
/* STATEMENT DELETED: if (p == null) return null */
|
||||||
print(p.size)
|
/* STATEMENT DELETED: print(p.size) */
|
||||||
return ""
|
/* STATEMENT DELETED: return "" */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -317,6 +317,12 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("InsideAnonymousObject.kt")
|
||||||
|
public void testInsideAnonymousObject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/InsideAnonymousObject.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("IntConstantTypeBug.kt")
|
@TestMetadata("IntConstantTypeBug.kt")
|
||||||
public void testIntConstantTypeBug() throws Exception {
|
public void testIntConstantTypeBug() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IntConstantTypeBug.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IntConstantTypeBug.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user