From d6db1a1b35469618c106937b3079a161dd9b8828 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Thu, 28 Mar 2019 02:45:57 +0300 Subject: [PATCH] [NI] Relax requirement for stub types in builder-inference For functions with implicit return type annotations will be replaced anyway in order to initialize return type, so this restriction in `StubType` was too strong #KT-30656 Fixed --- .../testsWithStdLib/coroutines/inference/incorrectCalls.kt | 4 ++-- .../coroutines/inference/incorrectCalls.ni.txt | 2 +- core/descriptors/src/org/jetbrains/kotlin/types/StubType.kt | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt index 476d64642db..b341dcc9ea3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt @@ -28,10 +28,10 @@ val test2 = generate { val test3 = generate { yield(3) - yieldBarReturnType(3) + yieldBarReturnType(3) } val test4 = generate { yield(3) - barReturnType() + barReturnType() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.ni.txt index cb114e9f144..aa1fb869364 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.ni.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.ni.txt @@ -4,7 +4,7 @@ public val test1: kotlin.collections.List public val test2: kotlin.collections.List public val test3: kotlin.collections.List public val test4: kotlin.collections.List -public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List public final class GenericController { public constructor GenericController() diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/StubType.kt b/core/descriptors/src/org/jetbrains/kotlin/types/StubType.kt index f822bd2364a..522fa24636a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/StubType.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/StubType.kt @@ -24,9 +24,7 @@ class StubType( override val annotations: Annotations get() = Annotations.EMPTY - override fun replaceAnnotations(newAnnotations: Annotations): SimpleType { - error("Shouldn't be called on non-fixed type") - } + override fun replaceAnnotations(newAnnotations: Annotations): SimpleType = this override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType { return if (newNullability == isMarkedNullable)