Minor. Added regression tests for: KT-3927, KT-9522, KT-10036, KT-7440, KT-9682, KT-9808, KT-9517, KT-9810, KT-9345.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
//KT-3927 Inner class cannot be instantiated with child instance of outer class
|
||||
|
||||
abstract class Base {
|
||||
inner class Inner {
|
||||
fun o() = "O"
|
||||
fun k() = "K"
|
||||
}
|
||||
}
|
||||
|
||||
class Child : Base()
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
result += Child().Inner().o()
|
||||
|
||||
fun Child.f() {
|
||||
result += Inner().k()
|
||||
}
|
||||
Child().f()
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class JavaClass {
|
||||
public String getO() {
|
||||
return "O";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// KT-9522 Allow invoke convention for synthetic property
|
||||
|
||||
operator fun String.invoke() = this + "K"
|
||||
|
||||
fun box(): String {
|
||||
return JavaClass().o();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER
|
||||
// KT-10036 Ambiguous overload cannot be resolved when using a member function reference in Beta 2, that worked in Beta 1
|
||||
|
||||
class OverloadTest {
|
||||
fun foo(bar: Boolean) {}
|
||||
fun foo(bar: Any?) {}
|
||||
}
|
||||
|
||||
object Literal
|
||||
|
||||
inline fun <T : Any> OverloadTest.overload(value: T?, function: OverloadTest.(T) -> Unit) {
|
||||
if (value == null) foo(Literal) else function(<!DEBUG_INFO_SMARTCAST!>value<!>)
|
||||
}
|
||||
|
||||
// Overload resolution ambiguity
|
||||
fun OverloadTest.overloadBoolean(value: Boolean?) = overload(value, OverloadTest::foo)
|
||||
|
||||
// Works fine
|
||||
fun OverloadTest.overloadBoolean2(value: Boolean?) = overload(value) { foo(it) }
|
||||
@@ -0,0 +1,21 @@
|
||||
package
|
||||
|
||||
public inline fun </*0*/ T : kotlin.Any> OverloadTest.overload(/*0*/ value: T?, /*1*/ function: OverloadTest.(T) -> kotlin.Unit): kotlin.Unit
|
||||
public fun OverloadTest.overloadBoolean(/*0*/ value: kotlin.Boolean?): kotlin.Unit
|
||||
public fun OverloadTest.overloadBoolean2(/*0*/ value: kotlin.Boolean?): kotlin.Unit
|
||||
|
||||
public object Literal {
|
||||
private constructor Literal()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class OverloadTest {
|
||||
public constructor OverloadTest()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ bar: kotlin.Any?): kotlin.Unit
|
||||
public final fun foo(/*0*/ bar: kotlin.Boolean): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER
|
||||
// KT-7440 Cannot complete type inference if two extension functions for interface hierarchy
|
||||
|
||||
package inferenceagain
|
||||
|
||||
interface Base<T>
|
||||
interface Derived<T> : Base<T>
|
||||
|
||||
fun <R : Comparable<R>, T : Any> Base<T>.maxBy(f: (T) -> R): T? = null
|
||||
fun <R : Comparable<R>, T : Any> Derived<T>.maxBy(f: (T) -> R): T? = null
|
||||
|
||||
fun <T> derivedOf(vararg members: T): Derived<T> = null!!
|
||||
|
||||
fun <T> x(l: Derived<T>) {
|
||||
derivedOf(1, 2, 3).maxBy<Int, Int> { it } // works
|
||||
derivedOf(1, 2, 3).maxBy { it } // should work
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
package inferenceagain {
|
||||
public fun </*0*/ T> derivedOf(/*0*/ vararg members: T /*kotlin.Array<out T>*/): inferenceagain.Derived<T>
|
||||
public fun </*0*/ T> x(/*0*/ l: inferenceagain.Derived<T>): kotlin.Unit
|
||||
public fun </*0*/ R : kotlin.Comparable<R>, /*1*/ T : kotlin.Any> inferenceagain.Base<T>.maxBy(/*0*/ f: (T) -> R): T?
|
||||
public fun </*0*/ R : kotlin.Comparable<R>, /*1*/ T : kotlin.Any> inferenceagain.Derived<T>.maxBy(/*0*/ f: (T) -> R): T?
|
||||
|
||||
public interface Base</*0*/ T> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Derived</*0*/ T> : inferenceagain.Base<T> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// KT-9682 Overload Resolution Ambiguity after casting to Interface
|
||||
|
||||
open class Foo {
|
||||
fun bar(): Foo {
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
class Foo2 : Foo(), IFoo
|
||||
|
||||
interface IFoo {
|
||||
fun bar(): Foo
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val foo : Foo = Foo2()
|
||||
foo as IFoo
|
||||
foo.bar() // Should be resolved to Foo#bar
|
||||
}
|
||||
|
||||
interface IFoo2 {
|
||||
fun bar(): IFoo2
|
||||
}
|
||||
|
||||
fun test2(foo: Foo) {
|
||||
foo as IFoo2
|
||||
foo.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!>() // should be ambiguity
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
public fun test2(/*0*/ foo: Foo): kotlin.Unit
|
||||
|
||||
public open class Foo {
|
||||
public constructor Foo()
|
||||
public final fun bar(): Foo
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Foo2 : Foo, IFoo {
|
||||
public constructor Foo2()
|
||||
public final override /*2*/ /*fake_override*/ fun bar(): Foo
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface IFoo {
|
||||
public abstract fun bar(): Foo
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface IFoo2 {
|
||||
public abstract fun bar(): IFoo2
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// KT-9808 Extension function on object for new resolve
|
||||
object O
|
||||
|
||||
val foo: O.() -> Unit = null!!
|
||||
|
||||
fun test() {
|
||||
O.foo()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public val foo: O.() -> kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public object O {
|
||||
private constructor O()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
//KT-9517 Wrong resolve for invoke convention after smart cast
|
||||
open class A {
|
||||
open val foo: () -> Number = null!!
|
||||
}
|
||||
|
||||
class B: A() {
|
||||
override val foo: () -> Int
|
||||
get() = null!!
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
if (a is B) {
|
||||
val <!UNUSED_VARIABLE!>foo<!>: Int = <!DEBUG_INFO_SMARTCAST!>a<!>.foo() // B::foo + invoke()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ a: A): kotlin.Unit
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open val foo: () -> kotlin.Number
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B : A {
|
||||
public constructor B()
|
||||
public open override /*1*/ val foo: () -> kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// KT-9810 Local variable vs property from implicit receiver
|
||||
|
||||
class A {
|
||||
val foo = 2
|
||||
}
|
||||
|
||||
fun test(foo: String) {
|
||||
with(A()) {
|
||||
val g: String = foo // locals win
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ foo: kotlin.String): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final val foo: kotlin.Int = 2
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
//KT-9345 Type inference failure
|
||||
|
||||
fun Class<*>.foo(): Any? = kotlin.objectInstance
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public fun java.lang.Class<*>.foo(): kotlin.Any?
|
||||
@@ -2093,6 +2093,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt10036.kt")
|
||||
public void testKt10036() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/kt10036.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt9601.kt")
|
||||
public void testKt9601() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/kt9601.kt");
|
||||
@@ -11475,6 +11481,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt7440.kt")
|
||||
public void testKt7440() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/overload/kt7440.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("OverloadFunRegularAndExt.kt")
|
||||
public void testOverloadFunRegularAndExt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/overload/OverloadFunRegularAndExt.kt");
|
||||
@@ -13632,6 +13644,18 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt9682.kt")
|
||||
public void testKt9682() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt9682.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt9808.kt")
|
||||
public void testKt9808() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt9808.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noThis.kt")
|
||||
public void testNoThis() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/noThis.kt");
|
||||
@@ -13952,6 +13976,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt9517.kt")
|
||||
public void testKt9517() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/invoke/kt9517.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt9805.kt")
|
||||
public void testKt9805() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/invoke/kt9805.kt");
|
||||
@@ -14204,6 +14234,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt9810.kt")
|
||||
public void testKt9810() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/priority/kt9810.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt9965.kt")
|
||||
public void testKt9965() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/priority/kt9965.kt");
|
||||
|
||||
@@ -1008,6 +1008,12 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/regression/kt2082.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt9345.kt")
|
||||
public void testKt9345() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/regression/kt9345.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/reified")
|
||||
|
||||
+6
@@ -4699,6 +4699,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt3927.kt")
|
||||
public void testKt3927() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/kt3927.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt5363.kt")
|
||||
public void testKt5363() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/kt5363.kt");
|
||||
|
||||
+6
@@ -113,6 +113,12 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
|
||||
doTestWithJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("invokeOnSyntheticProperty")
|
||||
public void testInvokeOnSyntheticProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/invokeOnSyntheticProperty/");
|
||||
doTestWithJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("jvmName")
|
||||
public void testJvmName() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/jvmName/");
|
||||
|
||||
Reference in New Issue
Block a user