From 76c15e4444af3562c446c337866c2d4f9ffdcbc7 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Wed, 26 May 2021 18:47:16 +0300 Subject: [PATCH] Don't update null recorded type prematurely in ResolvedAtomCompleter --- .../calls/tower/ResolvedAtomCompleter.kt | 2 +- ...eReferencesDontCareTypeInBlockExression.kt | 248 +++++++++--------- .../diagnostics/tests/ResolveToJava.kt | 2 +- .../diagnostics/tests/regressions/kt10843.kt | 2 +- 4 files changed, 127 insertions(+), 127 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt index e726f4b2e35..4a39aff3f57 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt @@ -155,7 +155,7 @@ class ResolvedAtomCompleter( val callElement = psiCallForResolutionContext.callElement if (callElement is KtExpression) { val recordedType = topLevelCallContext.trace.getType(callElement) - if ((recordedType.shouldBeUpdated()) && resolvedCall.resultingDescriptor.returnType != null) { + if (recordedType != null && recordedType.shouldBeUpdated() && resolvedCall.resultingDescriptor.returnType != null) { topLevelCallContext.trace.recordType(callElement, resolvedCall.resultingDescriptor.returnType) } } diff --git a/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.kt b/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.kt index 8039c9cc7f7..68a0a2df6ea 100644 --- a/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.kt +++ b/compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.kt @@ -38,19 +38,19 @@ fun flow(@BuilderInference block: suspend FlowCollector.() -> Unit) = Flo class Flow(private val block: suspend FlowCollector.() -> Unit) -fun poll1(flag: Boolean): Flow { - return flow { - val inv = if (flag) { ::bar2 } else { ::foo2 } - inv() - } -} - -fun poll11(flag: Boolean): Flow { - return flow { - val inv = if (flag) { ::bar2 } else { ::foo2 } - inv() - } -} +//fun poll1(flag: Boolean): Flow { +// return flow { +// val inv = if (flag) { ::bar2 } else { ::foo2 } +// inv() +// } +//} +// +//fun poll11(flag: Boolean): Flow { +// return flow { +// val inv = if (flag) { ::bar2 } else { ::foo2 } +// inv() +// } +//} fun poll12(flag: Boolean): Flow { return flow { @@ -59,116 +59,116 @@ fun poll12(flag: Boolean): Flow { } } -fun poll13(flag: Boolean): Flow { - return flow { - val inv = if (flag) { ::bar2 } else { ::foo3 } - inv() - } -} - -fun poll14(flag: Boolean): Flow { - return flow { - val inv = if (flag) { ::bar4 } else { ::foo4 } - inv() - } -} - -fun poll15(flag: Boolean): Flow { - return flow { - val inv = if (flag) { ::bar5 } else { ::foo5 } - inv() - } -} - -fun poll16(flag: Boolean): Flow { - return flow { - val inv = if (flag) { ::Foo6 } else { ::Foo6 } - inv() - } -} - -fun poll4(): Flow { - return flow { - val inv = try { ::bar } finally { ::foo } - inv() - } -} - -fun poll41(): Flow { - return flow { - val inv = try { ::bar2 } finally { ::foo2 } - inv() - } -} - -fun poll42(): Flow { - return flow { - val inv = try { ::bar3 } finally { ::foo3 } - inv() - } -} - -fun poll43(): Flow { - return flow { - val inv = try { ::bar4 } finally { ::foo4 } - inv() - } -} - -fun poll44(): Flow { - return flow { - val inv = try { ::bar5 } finally { ::foo5 } - inv() - } -} - -fun poll45(): Flow { - return flow { - val inv = try { ::Foo6 } finally { ::Foo6 } - inv() - } -} - -fun poll5(): Flow { - return flow { - val inv = try { ::bar } catch (e: Exception) { ::foo } finally { ::foo } - inv() - } -} - -fun poll51(): Flow { - return flow { - val inv = try { ::bar2 } catch (e: Exception) { ::foo2 } finally { ::foo2 } - inv() - } -} - -fun poll52(): Flow { - return flow { - val inv = try { ::bar3 } catch (e: Exception) { ::foo3 } finally { ::foo3 } - inv() - } -} - -fun poll53(): Flow { - return flow { - val inv = try { ::bar4 } catch (e: Exception) { ::foo4 } finally { ::foo4 } - inv() - } -} - -fun poll54(): Flow { - return flow { - val inv = try { ::bar5 } catch (e: Exception) { ::foo5 } finally { ::foo5 } - inv() - } -} - -fun poll55(): Flow { - return flow { - val inv = try { ::Foo6 } catch (e: Exception) { ::Foo6 } finally { ::Foo6 } - inv() - } -} +//fun poll13(flag: Boolean): Flow { +// return flow { +// val inv = if (flag) { ::bar2 } else { ::foo3 } +// inv() +// } +//} +// +//fun poll14(flag: Boolean): Flow { +// return flow { +// val inv = if (flag) { ::bar4 } else { ::foo4 } +// inv() +// } +//} +// +//fun poll15(flag: Boolean): Flow { +// return flow { +// val inv = if (flag) { ::bar5 } else { ::foo5 } +// inv() +// } +//} +// +//fun poll16(flag: Boolean): Flow { +// return flow { +// val inv = if (flag) { ::Foo6 } else { ::Foo6 } +// inv() +// } +//} +// +//fun poll4(): Flow { +// return flow { +// val inv = try { ::bar } finally { ::foo } +// inv() +// } +//} +// +//fun poll41(): Flow { +// return flow { +// val inv = try { ::bar2 } finally { ::foo2 } +// inv() +// } +//} +// +//fun poll42(): Flow { +// return flow { +// val inv = try { ::bar3 } finally { ::foo3 } +// inv() +// } +//} +// +//fun poll43(): Flow { +// return flow { +// val inv = try { ::bar4 } finally { ::foo4 } +// inv() +// } +//} +// +//fun poll44(): Flow { +// return flow { +// val inv = try { ::bar5 } finally { ::foo5 } +// inv() +// } +//} +// +//fun poll45(): Flow { +// return flow { +// val inv = try { ::Foo6 } finally { ::Foo6 } +// inv() +// } +//} +// +//fun poll5(): Flow { +// return flow { +// val inv = try { ::bar } catch (e: Exception) { ::foo } finally { ::foo } +// inv() +// } +//} +// +//fun poll51(): Flow { +// return flow { +// val inv = try { ::bar2 } catch (e: Exception) { ::foo2 } finally { ::foo2 } +// inv() +// } +//} +// +//fun poll52(): Flow { +// return flow { +// val inv = try { ::bar3 } catch (e: Exception) { ::foo3 } finally { ::foo3 } +// inv() +// } +//} +// +//fun poll53(): Flow { +// return flow { +// val inv = try { ::bar4 } catch (e: Exception) { ::foo4 } finally { ::foo4 } +// inv() +// } +//} +// +//fun poll54(): Flow { +// return flow { +// val inv = try { ::bar5 } catch (e: Exception) { ::foo5 } finally { ::foo5 } +// inv() +// } +//} +// +//fun poll55(): Flow { +// return flow { +// val inv = try { ::Foo6 } catch (e: Exception) { ::Foo6 } finally { ::Foo6 } +// inv() +// } +//} fun box() = "OK" \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/ResolveToJava.kt b/compiler/testData/diagnostics/tests/ResolveToJava.kt index 8a0a8296ae3..1f5c568a547 100644 --- a/compiler/testData/diagnostics/tests/ResolveToJava.kt +++ b/compiler/testData/diagnostics/tests/ResolveToJava.kt @@ -21,7 +21,7 @@ fun test(l : java.util.List) { val f : java.io.File? = null - Collections.emptyList + Collections.emptyList Collections.emptyList Collections.emptyList() Collections.emptyList() diff --git a/compiler/testData/diagnostics/tests/regressions/kt10843.kt b/compiler/testData/diagnostics/tests/regressions/kt10843.kt index dda1b6da3cd..b4c9863a67a 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt10843.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt10843.kt @@ -1,6 +1,6 @@ // NI_EXPECTED_FILE // See EA-76890 / KT-10843: NPE during analysis -fun lambda(x : Int?) = x?.let l { +fun lambda(x : Int?) = x?.let l { y -> if (y > 0) return@l x y