[tests] BI (1P&1TV/1TIO): add tests for target types
single builder parameter single postponed type variable single origin of type information relevant issues: KT-60719 KT-60720 KT-60855 KT-60877 KT-60880
This commit is contained in:
committed by
Space Team
parent
bfe54942d3
commit
44a4c4ee1c
+46
@@ -0,0 +1,46 @@
|
||||
// DIAGNOSTICS: -UNCHECKED_CAST
|
||||
|
||||
// CHECK_TYPE_WITH_EXACT
|
||||
|
||||
// ISSUE: KT-60719
|
||||
/* ATTENTION:
|
||||
* this test is supposed to monitor unclear feature behavior;
|
||||
* an explicit design decision regarding said behavior has not been made at the moment of test creation;
|
||||
* if the behavior of the test changes, please consult with the linked YT ticket
|
||||
* and either add a comment about the change if an explicit design decision is still unavailable
|
||||
* (preferably accompanied by an analysis of the change's reasons)
|
||||
* or remove this disclaimer otherwise
|
||||
*/
|
||||
|
||||
class Buildee<CT> {
|
||||
fun yield(arg: CT) {}
|
||||
fun materialize(): CT = { _: UserKlass -> } as CT
|
||||
}
|
||||
|
||||
fun <FT> build(
|
||||
instructions: Buildee<FT>.() -> Unit
|
||||
): Buildee<FT> {
|
||||
return Buildee<FT>().apply(instructions)
|
||||
}
|
||||
|
||||
class UserKlass
|
||||
|
||||
// test 1: PTV is in consuming position (yield-case)
|
||||
fun testYield() {
|
||||
val buildee = build {
|
||||
yield { val x: UserKlass = <!UNRESOLVED_REFERENCE!>it<!> }
|
||||
}
|
||||
checkExactType<Buildee<(UserKlass) -> Unit>>(<!ARGUMENT_TYPE_MISMATCH("Buildee<kotlin/Function1<UserKlass, kotlin/Unit>>; Buildee<kotlin/Function0<kotlin/Unit>>")!>buildee<!>)
|
||||
}
|
||||
|
||||
// test 2: PTV is in producing position (materialize-case)
|
||||
fun testMaterialize() {
|
||||
fun <T> shareTypeInfo(from: T, to: T) {}
|
||||
val buildee = build {
|
||||
shareTypeInfo(
|
||||
{ val x: UserKlass = <!UNRESOLVED_REFERENCE!>it<!> },
|
||||
materialize()
|
||||
)
|
||||
}
|
||||
checkExactType<Buildee<(UserKlass) -> Unit>>(<!ARGUMENT_TYPE_MISMATCH("Buildee<kotlin/Function1<UserKlass, kotlin/Unit>>; Buildee<kotlin/Function0<kotlin/Unit>>")!>buildee<!>)
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// DIAGNOSTICS: -UNCHECKED_CAST
|
||||
|
||||
// CHECK_TYPE_WITH_EXACT
|
||||
|
||||
// ISSUE: KT-60719
|
||||
/* ATTENTION:
|
||||
* this test is supposed to monitor unclear feature behavior;
|
||||
* an explicit design decision regarding said behavior has not been made at the moment of test creation;
|
||||
* if the behavior of the test changes, please consult with the linked YT ticket
|
||||
* and either add a comment about the change if an explicit design decision is still unavailable
|
||||
* (preferably accompanied by an analysis of the change's reasons)
|
||||
* or remove this disclaimer otherwise
|
||||
*/
|
||||
|
||||
class Buildee<CT> {
|
||||
fun yield(arg: CT) {}
|
||||
fun materialize(): CT = { _: UserKlass -> } as CT
|
||||
}
|
||||
|
||||
fun <FT> build(
|
||||
instructions: Buildee<FT>.() -> Unit
|
||||
): Buildee<FT> {
|
||||
return Buildee<FT>().apply(instructions)
|
||||
}
|
||||
|
||||
class UserKlass
|
||||
|
||||
// test 1: PTV is in consuming position (yield-case)
|
||||
fun testYield() {
|
||||
val buildee = build {
|
||||
yield { val x: UserKlass = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>it<!> }
|
||||
}
|
||||
checkExactType<Buildee<(UserKlass) -> Unit>>(<!TYPE_MISMATCH("Buildee<(UserKlass) -> Unit>; Buildee<() -> Unit>"), TYPE_MISMATCH("Buildee<() -> Unit>; Buildee<(UserKlass) -> Unit>")!>buildee<!>)
|
||||
}
|
||||
|
||||
// test 2: PTV is in producing position (materialize-case)
|
||||
fun testMaterialize() {
|
||||
fun <T> shareTypeInfo(from: T, to: T) {}
|
||||
val buildee = build {
|
||||
shareTypeInfo(
|
||||
{ val x: UserKlass = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>it<!> },
|
||||
materialize()
|
||||
)
|
||||
}
|
||||
checkExactType<Buildee<(UserKlass) -> Unit>>(<!TYPE_MISMATCH("Buildee<(UserKlass) -> Unit>; Buildee<() -> Unit>"), TYPE_MISMATCH("Buildee<() -> Unit>; Buildee<(UserKlass) -> Unit>")!>buildee<!>)
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// DIAGNOSTICS: -UNCHECKED_CAST
|
||||
|
||||
// CHECK_TYPE_WITH_EXACT
|
||||
|
||||
// ISSUE: KT-60720
|
||||
/* ATTENTION:
|
||||
* this test is supposed to monitor unclear feature behavior;
|
||||
* an explicit design decision regarding said behavior has not been made at the moment of test creation;
|
||||
* if the behavior of the test changes, please consult with the linked YT ticket
|
||||
* and either add a comment about the change if an explicit design decision is still unavailable
|
||||
* (preferably accompanied by an analysis of the change's reasons)
|
||||
* or remove this disclaimer otherwise
|
||||
*/
|
||||
|
||||
class Buildee<CT> {
|
||||
fun yield(arg: CT) {}
|
||||
fun materialize(): CT = fun UserKlass.() {} as CT
|
||||
}
|
||||
|
||||
fun <FT> build(
|
||||
instructions: Buildee<FT>.() -> Unit
|
||||
): Buildee<FT> {
|
||||
return Buildee<FT>().apply(instructions)
|
||||
}
|
||||
|
||||
class UserKlass
|
||||
|
||||
// test 1: PTV is in consuming position (yield-case)
|
||||
fun testYield() {
|
||||
val buildee = build {
|
||||
yield { val x: UserKlass = this<!UNRESOLVED_LABEL!>@yield<!> }
|
||||
}
|
||||
checkExactType<Buildee<UserKlass.() -> Unit>>(<!ARGUMENT_TYPE_MISMATCH("Buildee<@ExtensionFunctionType kotlin/Function1<UserKlass, kotlin/Unit>>; Buildee<kotlin/Function0<kotlin/Unit>>")!>buildee<!>)
|
||||
}
|
||||
|
||||
// test 2: PTV is in producing position (materialize-case)
|
||||
fun testMaterialize() {
|
||||
fun <T> shareTypeInfo(from: T, to: T) {}
|
||||
val buildee = build {
|
||||
shareTypeInfo(
|
||||
{ val x: UserKlass = this<!UNRESOLVED_LABEL!>@shareTypeInfo<!> },
|
||||
materialize()
|
||||
)
|
||||
}
|
||||
checkExactType<Buildee<UserKlass.() -> Unit>>(<!ARGUMENT_TYPE_MISMATCH("Buildee<@ExtensionFunctionType kotlin/Function1<UserKlass, kotlin/Unit>>; Buildee<kotlin/Function0<kotlin/Unit>>")!>buildee<!>)
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// DIAGNOSTICS: -UNCHECKED_CAST
|
||||
|
||||
// CHECK_TYPE_WITH_EXACT
|
||||
|
||||
// ISSUE: KT-60720
|
||||
/* ATTENTION:
|
||||
* this test is supposed to monitor unclear feature behavior;
|
||||
* an explicit design decision regarding said behavior has not been made at the moment of test creation;
|
||||
* if the behavior of the test changes, please consult with the linked YT ticket
|
||||
* and either add a comment about the change if an explicit design decision is still unavailable
|
||||
* (preferably accompanied by an analysis of the change's reasons)
|
||||
* or remove this disclaimer otherwise
|
||||
*/
|
||||
|
||||
class Buildee<CT> {
|
||||
fun yield(arg: CT) {}
|
||||
fun materialize(): CT = fun UserKlass.() {} as CT
|
||||
}
|
||||
|
||||
fun <FT> build(
|
||||
instructions: Buildee<FT>.() -> Unit
|
||||
): Buildee<FT> {
|
||||
return Buildee<FT>().apply(instructions)
|
||||
}
|
||||
|
||||
class UserKlass
|
||||
|
||||
// test 1: PTV is in consuming position (yield-case)
|
||||
fun testYield() {
|
||||
val buildee = build {
|
||||
yield { val x: UserKlass = <!NO_THIS!>this@yield<!> }
|
||||
}
|
||||
checkExactType<Buildee<UserKlass.() -> Unit>>(<!TYPE_MISMATCH("Buildee<UserKlass.() -> Unit>; Buildee<() -> Unit>"), TYPE_MISMATCH("Buildee<() -> Unit>; Buildee<UserKlass.() -> Unit>")!>buildee<!>)
|
||||
}
|
||||
|
||||
// test 2: PTV is in producing position (materialize-case)
|
||||
fun testMaterialize() {
|
||||
fun <T> shareTypeInfo(from: T, to: T) {}
|
||||
val buildee = build {
|
||||
shareTypeInfo(
|
||||
{ val x: UserKlass = <!NO_THIS!>this@shareTypeInfo<!> },
|
||||
materialize()
|
||||
)
|
||||
}
|
||||
checkExactType<Buildee<UserKlass.() -> Unit>>(<!TYPE_MISMATCH("Buildee<UserKlass.() -> Unit>; Buildee<() -> Unit>"), TYPE_MISMATCH("Buildee<() -> Unit>; Buildee<UserKlass.() -> Unit>")!>buildee<!>)
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// FIR_IDENTICAL
|
||||
// DIAGNOSTICS: -UNCHECKED_CAST, -UNREACHABLE_CODE
|
||||
|
||||
// CHECK_TYPE_WITH_EXACT
|
||||
|
||||
// ISSUE: KT-60880
|
||||
/* ATTENTION:
|
||||
* this test monitors an unfixed compiler bug;
|
||||
* if the behavior of the test changes, please consult with the linked YT ticket
|
||||
* to check whether the described problem has been fixed by your changes;
|
||||
* if the issue isn't actually fixed but new behavior persists,
|
||||
* please add a comment about the behavior change to the ticket
|
||||
* (preferably accompanied by an analysis of the change's reasons)
|
||||
*/
|
||||
|
||||
class Buildee<CT> {
|
||||
fun materialize(): CT = null as CT
|
||||
}
|
||||
|
||||
fun <FT> build(
|
||||
instructions: Buildee<FT>.() -> Unit
|
||||
): Buildee<FT> {
|
||||
return Buildee<FT>().apply(instructions)
|
||||
}
|
||||
|
||||
fun testMaterialize() {
|
||||
fun consume(arg: Nothing) {}
|
||||
val buildee = build {
|
||||
consume(materialize())
|
||||
}
|
||||
checkExactType<Buildee<Nothing>>(buildee)
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// DIAGNOSTICS: -UNCHECKED_CAST, -UNREACHABLE_CODE
|
||||
|
||||
// CHECK_TYPE_WITH_EXACT
|
||||
|
||||
// ISSUE: KT-60877
|
||||
/* ATTENTION:
|
||||
* this test monitors an unfixed compiler bug;
|
||||
* if the behavior of the test changes, please consult with the linked YT ticket
|
||||
* to check whether the described problem has been fixed by your changes;
|
||||
* if the issue isn't actually fixed but new behavior persists,
|
||||
* please add a comment about the behavior change to the ticket
|
||||
* (preferably accompanied by an analysis of the change's reasons)
|
||||
*/
|
||||
|
||||
class Buildee<CT> {
|
||||
fun materialize(): CT = null as CT
|
||||
}
|
||||
|
||||
fun <FT> build(
|
||||
instructions: Buildee<FT>.() -> Unit
|
||||
): Buildee<FT> {
|
||||
return Buildee<FT>().apply(instructions)
|
||||
}
|
||||
|
||||
fun testMaterialize() {
|
||||
fun <T> shareTypeInfo(from: T, to: T) {}
|
||||
val buildee = build {
|
||||
shareTypeInfo(null, materialize())
|
||||
}
|
||||
checkExactType<Buildee<Nothing?>>(<!ARGUMENT_TYPE_MISMATCH("Buildee<kotlin/Nothing?>; Buildee<kotlin/Nothing>")!>buildee<!>)
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// DIAGNOSTICS: -UNCHECKED_CAST, -UNREACHABLE_CODE
|
||||
|
||||
// CHECK_TYPE_WITH_EXACT
|
||||
|
||||
// ISSUE: KT-60877
|
||||
/* ATTENTION:
|
||||
* this test monitors an unfixed compiler bug;
|
||||
* if the behavior of the test changes, please consult with the linked YT ticket
|
||||
* to check whether the described problem has been fixed by your changes;
|
||||
* if the issue isn't actually fixed but new behavior persists,
|
||||
* please add a comment about the behavior change to the ticket
|
||||
* (preferably accompanied by an analysis of the change's reasons)
|
||||
*/
|
||||
|
||||
class Buildee<CT> {
|
||||
fun materialize(): CT = null as CT
|
||||
}
|
||||
|
||||
fun <FT> build(
|
||||
instructions: Buildee<FT>.() -> Unit
|
||||
): Buildee<FT> {
|
||||
return Buildee<FT>().apply(instructions)
|
||||
}
|
||||
|
||||
fun testMaterialize() {
|
||||
fun <T> shareTypeInfo(from: T, to: T) {}
|
||||
val buildee = build {
|
||||
shareTypeInfo(null, materialize())
|
||||
}
|
||||
checkExactType<Buildee<Nothing?>>(<!TYPE_MISMATCH("Buildee<Nothing?>; Buildee<Nothing>"), TYPE_MISMATCH("Buildee<Nothing>; Buildee<Nothing?>")!>buildee<!>)
|
||||
}
|
||||
Reference in New Issue
Block a user