Add test for KT-41917 (already fixed)

This commit is contained in:
Mikhail Glukhikh
2021-02-20 11:24:09 +03:00
parent 1fe0a1f160
commit 6e46b0a1c4
4 changed files with 85 additions and 0 deletions
@@ -0,0 +1,50 @@
FILE: kt41917.kt
public final class DummyDelegate<V> : R|kotlin/Any| {
public constructor<V>(s: R|V|): R|DummyDelegate<V>| {
super<R|kotlin/Any|>()
}
public final val s: R|V| = R|<local>/s|
public get(): R|V|
public final operator fun getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|V| {
^getValue this@R|/DummyDelegate|.R|/DummyDelegate.s|
}
}
public final fun testImplicit(c: R|C|): R|kotlin/Int| {
^testImplicit R|<local>/c|.R|/A.implicit|.R|kotlin/String.length|
}
public final fun testExplicit(c: R|C|): R|kotlin/Int| {
^testExplicit R|<local>/c|.R|/A.explicit|.R|kotlin/String.length|
}
public open class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final val implicit: R|kotlin/String|by R|/DummyDelegate.DummyDelegate|<R|kotlin/String|>(String(hello))
public get(): R|kotlin/String| {
^ this@R|/A|.D|/A.implicit|.R|SubstitutionOverride</DummyDelegate.getValue: R|kotlin/String|>|(this@R|/A|, ::R|/A.implicit|)
}
public final val explicit: R|kotlin/String|by R|/DummyDelegate.DummyDelegate|<R|kotlin/String|>(String(hello))
public get(): R|kotlin/String| {
^ this@R|/A|.D|/A.explicit|.R|SubstitutionOverride</DummyDelegate.getValue: R|kotlin/String|>|(this@R|/A|, ::R|/A.explicit|)
}
}
public abstract interface B : R|kotlin/Any| {
public abstract val implicit: R|kotlin/String|
public get(): R|kotlin/String|
public abstract val explicit: R|kotlin/String|
public get(): R|kotlin/String|
}
public final class C : R|A|, R|B| {
public constructor(): R|C| {
super<R|A|>()
}
}
@@ -0,0 +1,23 @@
import kotlin.reflect.KProperty
class DummyDelegate<V>(val s: V) {
operator fun getValue(thisRef: Any?, property: KProperty<*>): V {
return s
}
}
fun testImplicit(c: C) = c.implicit.length // (1)
fun testExplicit(c: C) = c.explicit.length
open class A {
val implicit by DummyDelegate("hello")
val explicit: String by DummyDelegate("hello")
}
interface B {
val implicit: String
val explicit: String
}
class C : A(), B
@@ -4613,6 +4613,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.kt");
}
@Test
@TestMetadata("kt41917.kt")
public void testKt41917() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt");
}
@Test
@TestMetadata("propertyWithFunctionalType.kt")
public void testPropertyWithFunctionalType() throws Exception {
@@ -4680,6 +4680,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.kt");
}
@Test
@TestMetadata("kt41917.kt")
public void testKt41917() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt");
}
@Test
@TestMetadata("propertyWithFunctionalType.kt")
public void testPropertyWithFunctionalType() throws Exception {