FIR: Add more tests for delegate inference
This commit is contained in:
committed by
teamcity
parent
bb411cbba7
commit
2e69f7732c
+12
@@ -1207,6 +1207,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/delegateInference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateWithArgInference.kt")
|
||||
public void testDelegateWithArgInference() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/delegateWithArgInference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateWithLambda.kt")
|
||||
public void testDelegateWithLambda() throws Exception {
|
||||
@@ -1236,6 +1242,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
||||
public void testProvideDelegate() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/provideDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("receiverInference.kt")
|
||||
public void testReceiverInference() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/receiverInference.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+10
@@ -1055,6 +1055,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/delegateInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegateWithArgInference.kt")
|
||||
public void testDelegateWithArgInference() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/delegateWithArgInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegateWithLambda.kt")
|
||||
public void testDelegateWithLambda() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/delegateWithLambda.kt");
|
||||
@@ -1079,6 +1084,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
public void testProvideDelegate() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/provideDelegate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("receiverInference.kt")
|
||||
public void testReceiverInference() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/receiverInference.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/diagnostics")
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
FILE: delegateWithArgInference.kt
|
||||
public final class Delegate<T> : R|kotlin/Any| {
|
||||
public constructor<T>(data: R|T|): R|Delegate<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val data: R|T| = R|<local>/data|
|
||||
public get(): R|T|
|
||||
|
||||
public final operator fun getValue(thisRef: R|kotlin/Nothing?|, prop: R|kotlin/reflect/KProperty<*>|): R|T| {
|
||||
^getValue this@R|/Delegate|.R|/Delegate.data|
|
||||
}
|
||||
|
||||
}
|
||||
public final fun makeIntDelegate(t: R|kotlin/Int|): R|Delegate<kotlin/Int>| {
|
||||
^makeIntDelegate R|/Delegate.Delegate|<R|kotlin/Int|>(R|<local>/t|)
|
||||
}
|
||||
public final fun <M> materialize(): R|M| {
|
||||
^materialize Null(null)!!
|
||||
}
|
||||
public final fun <Q> id(v: R|Q|): R|Q| {
|
||||
^id R|<local>/v|
|
||||
}
|
||||
public final val x: R|kotlin/Int|by R|/makeIntDelegate|(R|/id|<R|kotlin/Int|>(R|/materialize|<R|kotlin/Int|>()))
|
||||
public get(): R|kotlin/Int| {
|
||||
^ D|/x|.R|SubstitutionOverride</Delegate.getValue: R|kotlin/Int|>|(Null(null), ::R|/x|)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class Delegate<T>(val data: T) {
|
||||
operator fun getValue(thisRef: Nothing?, prop: KProperty<*>): T = data
|
||||
}
|
||||
|
||||
fun makeIntDelegate(t: Int): Delegate<Int> = Delegate(t)
|
||||
fun <TT> makeDelegate(t: TT): Delegate<TT> = Delegate(t)
|
||||
fun <M> materialize(): M = null!!
|
||||
fun <M2> materialize2(): M2 = null!!
|
||||
fun <Q> id(v: Q): Q = v
|
||||
|
||||
val x by makeIntDelegate(run {
|
||||
val x: String = materialize()
|
||||
materialize2()
|
||||
})
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
FILE: receiverInference.kt
|
||||
public abstract interface XEntity : R|kotlin/Any| {
|
||||
}
|
||||
public final class Provider<out R> : R|kotlin/Any| {
|
||||
public constructor<out R>(): R|Provider<R>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun provideDelegate(thisRef: R|XEntity|, prop: R|kotlin/Any|): R|R| {
|
||||
^provideDelegate Null(null)!!
|
||||
}
|
||||
|
||||
}
|
||||
public final class Prop<E, V> : R|kotlin/Any| {
|
||||
public constructor<E, V>(): R|Prop<E, V>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun getValue(receiver: R|E|, prop: R|kotlin/Any|): R|V| {
|
||||
^getValue Null(null)!!
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <R : R|XEntity|, V> mkProp(): R|Provider<Prop<R, V>>| {
|
||||
^mkProp R|/Provider.Provider|<R|Prop<R, V>|>()
|
||||
}
|
||||
public final class MyEnt : R|XEntity| {
|
||||
public constructor(): R|MyEnt| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val d: R|kotlin/String|by R|/mkProp|<R|MyEnt|, R|kotlin/String|>().R|SubstitutionOverride</Provider.provideDelegate: R|Prop<Stub (builder inference): TypeVariable(_R), Stub (builder inference): TypeVariable(_V)>|>|(this@R|/MyEnt|, ::R|/MyEnt.d|)
|
||||
public get(): R|kotlin/String| {
|
||||
^ this@R|/MyEnt|.D|/MyEnt.d|.R|SubstitutionOverride</Prop.getValue: R|Stub (builder inference): TypeVariable(_V)|>|(this@R|/MyEnt|, ::R|/MyEnt.d|)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
|
||||
interface XEntity
|
||||
class Provider<out R> {
|
||||
operator fun provideDelegate(thisRef: XEntity, prop: Any): R = null!!
|
||||
}
|
||||
|
||||
class Prop<E, V> {
|
||||
operator fun getValue(receiver: E, prop: Any): V = null!!
|
||||
}
|
||||
|
||||
fun <R: XEntity, V> mkProp(): Provider<Prop<R, V>> = Provider()
|
||||
|
||||
class MyEnt: XEntity {
|
||||
val d: String by mkProp()
|
||||
}
|
||||
+12
@@ -1207,6 +1207,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/delegateInference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateWithArgInference.kt")
|
||||
public void testDelegateWithArgInference() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/delegateWithArgInference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateWithLambda.kt")
|
||||
public void testDelegateWithLambda() throws Exception {
|
||||
@@ -1236,6 +1242,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
public void testProvideDelegate() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/provideDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("receiverInference.kt")
|
||||
public void testReceiverInference() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/receiverInference.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+12
@@ -1207,6 +1207,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/delegateInference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateWithArgInference.kt")
|
||||
public void testDelegateWithArgInference() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/delegateWithArgInference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateWithLambda.kt")
|
||||
public void testDelegateWithLambda() throws Exception {
|
||||
@@ -1236,6 +1242,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
public void testProvideDelegate() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/provideDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("receiverInference.kt")
|
||||
public void testReceiverInference() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/delegates/receiverInference.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user