[FIR] Add tests for KT-50386 and KT-50646

This commit is contained in:
Dmitriy Novozhilov
2023-02-13 14:28:51 +02:00
committed by Space Team
parent 092ebf4c11
commit 8ae5213155
8 changed files with 189 additions and 0 deletions
@@ -1059,6 +1059,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt");
}
@Test
@TestMetadata("kt50386.kt")
public void testKt50386() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt50386.kt");
}
@Test
@TestMetadata("lambdaAsReceiver.kt")
public void testLambdaAsReceiver() throws Exception {
@@ -1071,6 +1077,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.kt");
}
@Test
@TestMetadata("overloadsWithGenericAndGenericLambda.kt")
public void testOverloadsWithGenericAndGenericLambda() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/overloadsWithGenericAndGenericLambda.kt");
}
@Test
@TestMetadata("safeCallOnTypeAlias.kt")
public void testSafeCallOnTypeAlias() throws Exception {
@@ -913,6 +913,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt");
}
@TestMetadata("kt50386.kt")
public void testKt50386() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt50386.kt");
}
@TestMetadata("lambdaAsReceiver.kt")
public void testLambdaAsReceiver() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/lambdaAsReceiver.kt");
@@ -923,6 +928,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.kt");
}
@TestMetadata("overloadsWithGenericAndGenericLambda.kt")
public void testOverloadsWithGenericAndGenericLambda() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/overloadsWithGenericAndGenericLambda.kt");
}
@TestMetadata("safeCallOnTypeAlias.kt")
public void testSafeCallOnTypeAlias() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/safeCallOnTypeAlias.kt");
@@ -0,0 +1,74 @@
FILE: kt50386.kt
public abstract interface Flow<T> : R|kotlin/Any| {
}
public abstract interface MutableSharedFlow<T> : R|Flow<T>| {
}
public final fun test(output: R|(ScrapingOffOutput) -> kotlin/Unit|): R|kotlin/Unit| {
lval p: <ERROR TYPE REF: Ambiguity: presenter, [/presenter, /presenter]> = <Ambiguity: presenter, [/presenter, /presenter]>#(R|<local>/output|, <L> = presenter@fun <anonymous>(): R|ScrapingOffPresenter| <inline=Unknown> {
^ R|/ScrapingOffPresenter.ScrapingOffPresenter|()
}
)
}
public abstract class Presenter<Events, Model, Output> : R|kotlin/Any| {
public constructor<Events, Model, Output>(outputExtraBufferCapacity: R|kotlin/Int| = Int(16)): R|Presenter<Events, Model, Output>| {
super<R|kotlin/Any|>()
}
public final val output: R|MutableSharedFlow<Output>| = Null(null)!!
public get(): R|MutableSharedFlow<Output>|
public abstract fun Present(events: R|Events|): R|Model|
}
public final fun <Event : R|kotlin/Any|, Model, Output> presenter(events: R|Event|, output: R|((Output) -> kotlin/Unit)?| = Null(null), presenterProvider: R|() -> Presenter<Event, Model, Output>|): R|Model| {
^presenter Null(null)!!
}
public final fun <Event : R|kotlin/Any|, Model, Output> presenter(output: R|((Output) -> kotlin/Unit)?| = Null(null), extraBufferCapacity: R|kotlin/Int| = Int(16), presenterProvider: R|() -> Presenter<Flow<Event>, Model, Output>|): R|PresentedData<Model, MutableSharedFlow<Event>>| {
^presenter Null(null)!!
}
public final data class PresentedData<M, E> : R|kotlin/Any| {
public constructor<M, E>(model: R|M|, events: R|E|): R|PresentedData<M, E>| {
super<R|kotlin/Any|>()
}
public final val model: R|M| = R|<local>/model|
public get(): R|M|
public final val events: R|E| = R|<local>/events|
public get(): R|E|
public final operator fun component1(): R|M|
public final operator fun component2(): R|E|
public final fun copy(model: R|M| = this@R|/PresentedData|.R|/PresentedData.model|, events: R|E| = this@R|/PresentedData|.R|/PresentedData.events|): R|PresentedData<M, E>|
}
private final class ScrapingOffPresenter : R|Presenter<Flow<ScrapingOffEvent>, ScrapingOffModel, ScrapingOffOutput>| {
public constructor(): R|ScrapingOffPresenter| {
super<R|Presenter<Flow<ScrapingOffEvent>, ScrapingOffModel, ScrapingOffOutput>|>()
}
public open override fun Present(events: R|Flow<ScrapingOffEvent>|): R|ScrapingOffModel| {
^Present R|/ScrapingOffModel.ScrapingOffModel|()
}
}
public final class ScrapingOffEvent : R|kotlin/Any| {
public constructor(): R|ScrapingOffEvent| {
super<R|kotlin/Any|>()
}
}
public final class ScrapingOffOutput : R|kotlin/Any| {
public constructor(): R|ScrapingOffOutput| {
super<R|kotlin/Any|>()
}
}
public final class ScrapingOffModel : R|kotlin/Any| {
public constructor(): R|ScrapingOffModel| {
super<R|kotlin/Any|>()
}
}
@@ -0,0 +1,42 @@
// ISSUE: KT-50386
interface Flow<T>
interface MutableSharedFlow<T> : Flow<T>
fun test(output: ((ScrapingOffOutput) -> Unit)) {
val p = <!OVERLOAD_RESOLUTION_AMBIGUITY!>presenter<!>(output) { ScrapingOffPresenter() }
}
abstract class Presenter<Events, Model, Output>(outputExtraBufferCapacity: Int = 16) {
val output: MutableSharedFlow<Output> = null!!
abstract fun Present(events: Events): Model
}
fun <Event : Any, Model, Output> presenter(
events: Event,
output: ((Output) -> Unit)? = null,
presenterProvider: () -> Presenter<Event, Model, Output>
): Model = null!!
fun <Event : Any, Model, Output> presenter(
output: ((Output) -> Unit)? = null,
extraBufferCapacity: Int = 16,
presenterProvider: () -> Presenter<Flow<Event>, Model, Output>
): PresentedData<Model, MutableSharedFlow<Event>> = null!!
data class PresentedData<M, E>(
val model: M,
val events: E,
)
private class ScrapingOffPresenter : Presenter<Flow<ScrapingOffEvent>, ScrapingOffModel, ScrapingOffOutput>() {
override fun Present(events: Flow<ScrapingOffEvent>): ScrapingOffModel {
return ScrapingOffModel()
}
}
class ScrapingOffEvent
class ScrapingOffOutput
class ScrapingOffModel
@@ -0,0 +1,17 @@
FILE: overloadsWithGenericAndGenericLambda.kt
public final class Inv<T> : R|kotlin/Any| {
public constructor<T>(): R|Inv<T>| {
super<R|kotlin/Any|>()
}
}
public final fun <T> foo(c: R|Inv<T>|, f: R|() -> T|): R|kotlin/Unit| {
}
public final fun <T> foo(c: R|Inv<T>|, v: R|T|): R|kotlin/Unit| {
}
public final fun <T> test(x: R|Inv<T>|, v: R|T|): R|kotlin/Unit| {
<Ambiguity: foo, [/foo, /foo]>#(R|<local>/x|, <L> = foo@fun <anonymous>(): R|T| <inline=Unknown> {
^ R|<local>/v|
}
)
}
@@ -0,0 +1,10 @@
// ISSUE: KT-50646
class Inv<T>
fun <T> foo(c: Inv<T>, f: () -> T) {}
fun <T> foo(c: Inv<T>, v: T) {}
fun <T> test(x: Inv<T>, v: T) {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(x) { v }
}
@@ -1059,6 +1059,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt");
}
@Test
@TestMetadata("kt50386.kt")
public void testKt50386() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt50386.kt");
}
@Test
@TestMetadata("lambdaAsReceiver.kt")
public void testLambdaAsReceiver() throws Exception {
@@ -1071,6 +1077,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.kt");
}
@Test
@TestMetadata("overloadsWithGenericAndGenericLambda.kt")
public void testOverloadsWithGenericAndGenericLambda() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/overloadsWithGenericAndGenericLambda.kt");
}
@Test
@TestMetadata("safeCallOnTypeAlias.kt")
public void testSafeCallOnTypeAlias() throws Exception {
@@ -1059,6 +1059,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt");
}
@Test
@TestMetadata("kt50386.kt")
public void testKt50386() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt50386.kt");
}
@Test
@TestMetadata("lambdaAsReceiver.kt")
public void testLambdaAsReceiver() throws Exception {
@@ -1071,6 +1077,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.kt");
}
@Test
@TestMetadata("overloadsWithGenericAndGenericLambda.kt")
public void testOverloadsWithGenericAndGenericLambda() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/overloadsWithGenericAndGenericLambda.kt");
}
@Test
@TestMetadata("safeCallOnTypeAlias.kt")
public void testSafeCallOnTypeAlias() throws Exception {