K2: Adjust test data after PCLA implementation [red-to-green]

^KT-59791 In Progress
This commit is contained in:
Denis.Zharkov
2023-12-13 15:08:19 +01:00
committed by Space Team
parent 8459465177
commit b9019d3de1
74 changed files with 232 additions and 205 deletions
@@ -1,42 +0,0 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
annotationsList: []
origin: SOURCE
owningCallableSymbol: KtAnonymousFunctionSymbol(<local>/<no name provided>)
type: KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/String
]
type: test/Target<kotlin/String>
type = test.Target<kotlin.String>
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = test/Target.add(<dispatch receiver>: test.Target<T>, t: T): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = t
receiverType = null
returnType = kotlin.String
symbol = t: T
callableIdIfNonLocal = null
]
callableIdIfNonLocal = test/Target.add
typeArgumentsMapping = {}
argumentMapping = {
s -> (KtVariableLikeSignature:
name = t
receiverType = null
returnType = kotlin.String
symbol = t: T
callableIdIfNonLocal = null)
}
@@ -26,7 +26,7 @@ KtSuccessCallInfo:
KtVariableLikeSignature:
name = t
receiverType = null
returnType = T
returnType = kotlin.String
symbol = t: T
callableIdIfNonLocal = null
]
@@ -36,7 +36,7 @@ KtSuccessCallInfo:
s -> (KtVariableLikeSignature:
name = t
receiverType = null
returnType = T
returnType = kotlin.String
symbol = t: T
callableIdIfNonLocal = null)
}
@@ -1,12 +1,12 @@
FILE: ifInBuildMap.kt
public final fun main(): R|kotlin/Unit| {
R|kotlin/collections/buildMap<CS errors: kotlin/collections/buildMap>#|<R|kotlin/String|, R|kotlin/String|>(<L> = buildMap@fun R|kotlin/collections/MutableMap<kotlin/String, kotlin/String>|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
R|kotlin/collections/buildMap|<R|kotlin/String|, R|kotlin/String|>(<L> = buildMap@fun R|kotlin/collections/MutableMap<kotlin/String, kotlin/String>|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
when () {
Boolean(true) -> {
R|kotlin/io/println|(String(test))
}
else -> {
this@R|special/anonymous|.R|SubstitutionOverride<kotlin/collections/MutableMap.put: R|Stub (chain inference): TypeVariable(V)?|>|(String(foo), String(bar))
this@R|special/anonymous|.R|SubstitutionOverride<kotlin/collections/MutableMap.put: R|kotlin/String?|>|(String(foo), String(bar))
}
}
@@ -2,11 +2,11 @@
// ISSUE: KT-51143
fun main() {
<!NEW_INFERENCE_ERROR!>buildMap {
buildMap {
if (true) {
println("test")
} else {
put("foo", "bar")
}
}<!>
}
}
+1 -4
View File
@@ -1,4 +1 @@
compiler/testData/cli/jvm/builderInferenceErrors.kt:6:9: error: overload resolution ambiguity between candidates: [@InlineOnly() fun println(message: Any?): Unit, @InlineOnly() fun println(message: Boolean): Unit, @InlineOnly() fun println(message: Byte): Unit, ...]
println(secondParameter)
^
COMPILATION_ERROR
OK
@@ -1,7 +1,7 @@
// ISSUE: KT-49160
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-49160
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-49160
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-49160
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-49160
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-50453
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,8 +1,10 @@
// IGNORE_BACKEND_K1: ANY
// ISSUE: KT-52838
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// REASON: red code (see corresponding diagnostic test)
// IGNORE_BACKEND_K2: WASM
// REASON: That still doesn't work properly with PCLA, but accidentally don't fails for other tests but WASM
// (see KT-52838 for tracking and same-named diagnostic test)
fun box(): String {
build {
@@ -0,0 +1,13 @@
MODULE main
CLASS Kt52838cKt$box$1.class
Property: class.signature
K1
Lkotlin/jvm/internal/Lambda;Lkotlin/jvm/functions/Function1<LBuildee<Ljava/lang/Object;>;Lkotlin/Unit;>;
K2
Lkotlin/jvm/internal/Lambda;Lkotlin/jvm/functions/Function1<LBuildee<Lkotlin/Unit;>;Lkotlin/Unit;>;
METHOD invoke(LBuildee;)V
Property: method.signature
K1
(LBuildee<+Ljava/lang/Object;>;)V
K2
(LBuildee<Lkotlin/Unit;>;)V
@@ -1,7 +1,9 @@
// ISSUE: KT-52838
// JVM_ABI_K1_K2_DIFF: KT-64738
// IGNORE_BACKEND_K2: ANY
// REASON: red code (see corresponding diagnostic test)
// IGNORE_BACKEND_K2: WASM
// REASON: That still doesn't work properly with PCLA, but accidentally don't fails for other tests but WASM
// (see KT-52838 for tracking and same-named diagnostic test)
fun box(): String {
build {
@@ -1,7 +1,7 @@
// ISSUE: KT-53639
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-54400
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-54400
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-54400
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-57707
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -2,7 +2,8 @@
// WITH_STDLIB
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// TARGET_BACKEND: JVM
// REASON: red code (see corresponding diagnostic test)
var result = ""
@@ -1,7 +1,7 @@
// ISSUE: KT-57834
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -2,7 +2,7 @@
// WITH_STDLIB
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-60291
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-60291
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,6 @@
// ISSUE: KT-61310
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND_K2: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-63733
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun BoundedBuildee<TargetType>.setBoundedTypeVariable(arg: DifferentType) {}
@@ -2,7 +2,7 @@
// WITH_STDLIB
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-63840
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,7 @@
// ISSUE: KT-63840
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// IGNORE_BACKEND_K1: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
@@ -1,7 +1,5 @@
// WITH_STDLIB
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-58742
class Out<out V>(val v: V)
class Box<R> {
@@ -1,7 +1,5 @@
// WITH_STDLIB
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-58741
fun foo() =
buildBox {
@@ -2,7 +2,7 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val outerBuildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> outerBuild@ {
val outerBuildee = build outerBuild@ {
class LocalClass {
fun localClassMember() {
val innerBuildee = build innerBuild@ {
@@ -17,7 +17,7 @@ fun test() {
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<TargetType><!>>(outerBuildee)
checkExactType<Buildee<TargetType>>(outerBuildee)
}
@@ -2,7 +2,7 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val outerBuildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> outerBuild@ {
val outerBuildee = build outerBuild@ {
object {
fun anonymousObjectMember() {
val innerBuildee = build innerBuild@ {
@@ -17,7 +17,7 @@ fun test() {
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<TargetType><!>>(outerBuildee)
checkExactType<Buildee<TargetType>>(outerBuildee)
}
@@ -2,7 +2,7 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val outerBuildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> outerBuild@ {
val outerBuildee = build outerBuild@ {
fun localFunction() {
val innerBuildee = build innerBuild@ {
this@outerBuild.setTypeVariable(TargetType())
@@ -15,7 +15,7 @@ fun test() {
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<TargetType><!>>(outerBuildee)
checkExactType<Buildee<TargetType>>(outerBuildee)
}
@@ -2,7 +2,7 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val outerBuildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> outerBuild@ {
val outerBuildee = build outerBuild@ {
val innerBuildee = build innerBuild@ {
this@outerBuild.setTypeVariable(TargetType())
this@innerBuild.setTypeVariable(TargetType())
@@ -13,7 +13,7 @@ fun test() {
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<TargetType><!>>(outerBuildee)
checkExactType<Buildee<TargetType>>(outerBuildee)
}
@@ -2,8 +2,8 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val outerBuildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> outerBuild@ {
val middleBuildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> middleBuild@ {
val outerBuildee = build outerBuild@ {
val middleBuildee = build middleBuild@ {
val innerBuildee = build innerBuild@ {
this@outerBuild.setTypeVariable(TargetType())
this@middleBuild.setTypeVariable(TargetType())
@@ -15,11 +15,11 @@ fun test() {
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<TargetType><!>>(middleBuildee)
checkExactType<Buildee<TargetType>>(middleBuildee)
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<TargetType><!>>(outerBuildee)
checkExactType<Buildee<TargetType>>(outerBuildee)
}
@@ -4,7 +4,7 @@
fun test() {
val buildee = build {
setTypeVariable(TargetType())
consume(<!ARGUMENT_TYPE_MISMATCH!>getTypeVariable()<!>)
consume(getTypeVariable())
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
@@ -2,14 +2,14 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val buildee = build {
this as DerivedBuildee<*>
getTypeVariable()
getTypeVariable()
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<*><!>>(buildee)
checkExactType<Buildee<*>>(<!ARGUMENT_TYPE_MISMATCH!>buildee<!>)
}
@@ -3,8 +3,8 @@
fun test() {
val buildee = initializeAndBuild(
{ build <!BUILDER_INFERENCE_MULTI_LAMBDA_RESTRICTION!>{ setTypeVariable(TargetType()) }<!> },
<!BUILDER_INFERENCE_MULTI_LAMBDA_RESTRICTION!>{ placeholderExtensionInvokeOnBuildee() }<!>,
{ build { setTypeVariable(TargetType()) } },
{ placeholderExtensionInvokeOnBuildee() },
)
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
@@ -2,12 +2,12 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val buildee = build {
typeVariableMutableProperty = ""
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<String><!>>(buildee)
checkExactType<Buildee<String>>(buildee)
}
@@ -2,12 +2,12 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val buildee = build {
typeVariableMutableProperty = 42
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<Int><!>>(buildee)
checkExactType<Buildee<Int>>(buildee)
}
@@ -2,12 +2,12 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val buildee = build {
typeVariableMutableProperty = {}
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<() -> Unit><!>>(buildee)
checkExactType<Buildee<() -> Unit>>(buildee)
}
@@ -8,7 +8,7 @@ fun test() {
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<TargetType>>(<!ARGUMENT_TYPE_MISMATCH!>buildee<!>)
checkExactType<Buildee<TargetType>>(buildee)
}
@@ -11,13 +11,13 @@ fun <ETV> Buildee<ETV>.yieldWithoutAnnotation(value: ETV) {}
fun <ETV> Buildee<ETV>.yieldWithAnnotation(t: ETV) {}
fun test() {
val buildeeA = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val buildeeA = build {
yieldWithoutAnnotation(materializeBuildee<TargetType>())
yieldWithoutAnnotation(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>materializeBuildee<!>())
yieldWithoutAnnotation(materializeBuildee())
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<Buildee<TargetType>><!>>(buildeeA)
checkExactType<Buildee<Buildee<TargetType>>>(buildeeA)
val buildeeB = build {
yieldWithAnnotation(materializeBuildee<TargetType>())
@@ -2,10 +2,10 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = <!NEW_INFERENCE_ERROR!>build {
val buildee = build {
setTypeVariable(TargetType())
extensionSetOutProjectedTypeVariable(DifferentType())
}<!>
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<TargetType>>(buildee)
@@ -5,7 +5,7 @@
fun test() {
val buildee = build {
setTypeVariable(Any())
<!OVERLOAD_RESOLUTION_AMBIGUITY!>consumeBuildeeReceiver<!>()
consumeBuildeeReceiver()
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
@@ -4,7 +4,7 @@
fun test() {
val buildee = build {
setTypeVariable(TargetType())
<!OVERLOAD_RESOLUTION_AMBIGUITY!>consume<!>(getTypeVariable())
consume(getTypeVariable())
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
@@ -0,0 +1,29 @@
// ISSUE: KT-60291
// CHECK_TYPE_WITH_EXACT
// WITH_STDLIB
fun test() {
val buildee = selectBuildee(
build { setTypeVariable(TargetType()) },
build {}
)
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<TargetType>>(buildee)
}
fun <T> selectBuildee(vararg values: Buildee<T>): Buildee<T> = values.first()
class TargetType
class Buildee<TV> {
fun setTypeVariable(value: TV) { storage = value }
private var storage: TV = null!!
}
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}
@@ -1,5 +1,4 @@
// ISSUE: KT-60291
// FIR_IDENTICAL
// CHECK_TYPE_WITH_EXACT
// WITH_STDLIB
@@ -0,0 +1,26 @@
// ISSUE: KT-60291
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = if (true)
build { setTypeVariable(TargetType()) }
else
build {}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<TargetType>>(buildee)
}
class TargetType
class Buildee<TV> {
fun setTypeVariable(value: TV) { storage = value }
private var storage: TV = null!!
}
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}
@@ -1,5 +1,4 @@
// ISSUE: KT-60291
// FIR_IDENTICAL
// CHECK_TYPE_WITH_EXACT
fun test() {
@@ -0,0 +1,27 @@
// ISSUE: KT-60291
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = when ("") {
"true" -> build { setTypeVariable(TargetType()) }
"false" -> build {}
else -> Buildee()
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<TargetType>>(buildee)
}
class TargetType
class Buildee<TV> {
fun setTypeVariable(value: TV) { storage = value }
private var storage: TV = null!!
}
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}
@@ -1,5 +1,4 @@
// ISSUE: KT-60291
// FIR_IDENTICAL
// CHECK_TYPE_WITH_EXACT
fun test() {
@@ -1,30 +0,0 @@
// ISSUE: KT-61310
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
if (true) {
setTypeVariable(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>GenericBox<!>())
} else {
setTypeVariable(GenericBox<TargetType>())
}
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<GenericBox<TargetType>><!>>(buildee)
}
class TargetType
class GenericBox<T>
class Buildee<TV> {
fun setTypeVariable(value: TV) { storage = value }
private var storage: TV = null!!
}
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// ISSUE: KT-61310
// CHECK_TYPE_WITH_EXACT
@@ -10,11 +10,11 @@ fun test() {
}
val buildee = boundedBuild {
setBoundedTypeVariable(TargetType())
setBoundedTypeVariable(<!ARGUMENT_TYPE_MISMATCH!>DifferentType()<!>)
setBoundedTypeVariable(DifferentType())
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<BoundedBuildee<TargetType>>(<!ARGUMENT_TYPE_MISMATCH("BoundedBuildee<TargetType>; BoundedBuildee<kotlin.Any>")!>buildee<!>)
checkExactType<BoundedBuildee<TargetType>>(buildee)
}
@@ -3,12 +3,12 @@
// WITH_STDLIB
fun test() {
val buildee = <!NEW_INFERENCE_ERROR!>build {
val buildee = build {
select(
replaceTypeVariable(TargetType()),
DifferentType()
)
}<!>
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<TargetType>>(buildee)
@@ -2,12 +2,12 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = <!NEW_INFERENCE_ERROR!>build {
val buildee = build {
if (true)
replaceTypeVariable(TargetType())
else
DifferentType()
}<!>
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<TargetType>>(buildee)
@@ -2,12 +2,12 @@
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = <!NEW_INFERENCE_ERROR!>build {
val buildee = build {
when {
true -> replaceTypeVariable(TargetType())
else -> DifferentType()
}
}<!>
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<TargetType>>(buildee)
@@ -38,23 +38,23 @@ class Placeholder
// test 1: PTV is in consuming position (yield-case)
fun testYield() {
val arg: UserKlass = UserKlass()
val buildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val buildee = build {
nestedBuild {
yield(arg)
nestedYield(Placeholder())
}
}
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<UserKlass><!>>(buildee)
checkExactType<Buildee<UserKlass>>(buildee)
}
// test 2: PTV is in producing position (materialize-case)
fun testMaterialize() {
fun consume(arg: UserKlass) {}
val buildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val buildee = build {
nestedBuild {
consume(materialize())
nestedYield(Placeholder())
}
}
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<UserKlass><!>>(buildee)
checkExactType<Buildee<UserKlass>>(buildee)
}
@@ -27,5 +27,5 @@ fun testMaterialize() {
val buildee = build {
shareTypeInfo(null, materialize())
}
checkExactType<Buildee<Nothing?>>(<!ARGUMENT_TYPE_MISMATCH("Buildee<kotlin.Nothing?>; Buildee<kotlin.Nothing>")!>buildee<!>)
checkExactType<Buildee<Nothing?>>(buildee)
}
@@ -14,12 +14,12 @@
// PTV is returned as a last statement of the builder argument
fun testLastStatementReturn() {
val buildee = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val buildee = build {
materialize()
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkExactType<!><<!CANNOT_INFER_PARAMETER_TYPE!>Buildee<Unit><!>>(buildee)
checkExactType<Buildee<Unit>>(buildee)
}
/* REQUIRED DECLARATIONS */
@@ -49,40 +49,40 @@ fun main() {
add("one")
val secondParameter = get(1)
<!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(secondParameter) // ERROR: [OVERLOAD_RESOLUTION_AMBIGUITY] Overload resolution ambiguity. All these functions match.
println(secondParameter) // ERROR: [OVERLOAD_RESOLUTION_AMBIGUITY] Overload resolution ambiguity. All these functions match.
}
val list2 = buildList {
add("one")
<!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(get(1)) // ERROR: [OVERLOAD_RESOLUTION_AMBIGUITY] Overload resolution ambiguity. All these functions match.
println(get(1)) // ERROR: [OVERLOAD_RESOLUTION_AMBIGUITY] Overload resolution ambiguity. All these functions match.
}
val list3 = buildList {
add("one")
val secondParameter = Inv(get(1))
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(secondParameter)
foo(secondParameter)
}
val list4 = buildList {
add("one")
val secondParameter = get(1)
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(Inv(secondParameter))
foo(Inv(secondParameter))
}
val list5 = buildList {
add("one")
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(Inv(get(1)))
foo(Inv(get(1)))
}
val list6 = buildList {
add("one")
get(0).<!NONE_APPLICABLE!>bar<!>()
<!BUILDER_INFERENCE_STUB_RECEIVER!>get(0)<!>.bar()
}
val list7 = buildList {
add("one")
with (get(0)) {
<!NONE_APPLICABLE!>bar<!>()
bar()
}
}
val list71 = buildList {
@@ -90,7 +90,7 @@ fun main() {
with (get(0)) l1@ {
with (listOf(1)) {
<!NONE_APPLICABLE!>bar<!>()
bar()
}
}
}
@@ -99,21 +99,21 @@ fun main() {
with (get(0)) {
with (listOf(1)) {
<!NONE_APPLICABLE!>bar<!>()
bar()
}
}
}
val list8 = buildList {
add("one")
Inv(get(0)).<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo2<!>()
Inv(get(0)).foo2()
}
val list9 = buildList {
add("one")
with (get(0)) {
with (Inv(this)) {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo2<!>()
foo2()
}
}
}
@@ -122,7 +122,7 @@ fun main() {
with (get(0)) {
with (Inv(this)) {
<!NONE_APPLICABLE!>bar<!>()
bar()
}
}
}
@@ -148,46 +148,46 @@ fun main() {
val list13 = buildList {
add("one")
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo000<!>(get(0), 0f, get(0))
foo000(get(0), 0f, get(0))
}
val list14 = buildList {
add("one")
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo0000<!>(get(0), 0f, get(0))
foo0000(get(0), 0f, get(0))
}
val list17 = buildList l1@ {
add("one")
with (get(0)) {
<!NONE_APPLICABLE!>foo0003<!>(0f, this@l1.get(0))
foo0003(0f, <!ARGUMENT_TYPE_MISMATCH!>this@l1.get(0)<!>)
}
}
val list18 = buildList {
add("one")
get(0).<!NONE_APPLICABLE!>foo0003<!>(0f, get(0))
<!BUILDER_INFERENCE_STUB_RECEIVER!>get(0)<!>.foo0003(0f, <!ARGUMENT_TYPE_MISMATCH!>get(0)<!>)
}
val map1 = buildMap {
put(1, "one")
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo11<!>(entries)
foo11(entries)
}
// There aren't specific errors below as casting value arguments doesn't make a resolve successful
val list15 = buildList {
add("one")
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo0001<!>(get(0), 0f, get(0))
<!NONE_APPLICABLE!>foo0001<!>(get(0), 0f, get(0))
}
val list16 = buildList {
add("one")
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo0002<!>(get(0), 0f, get(0))
<!NONE_APPLICABLE!>foo0002<!>(get(0), 0f, get(0))
}
}
@@ -211,13 +211,13 @@ fun test() {
add("")
with (get()) {
with (listOf(1)) {
<!NONE_APPLICABLE!>bar<!>()
bar()
}
}
},
{
put(1, "one")
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo11<!>(entries())
foo11(entries())
}
)
}
@@ -0,0 +1,12 @@
// WITH_STDLIB
// ISSUE: KT-50293
fun main() {
val list = buildList {
add("one")
add("two")
val secondParameter = get(1)
println(secondParameter <!USELESS_CAST!>as String<!>)
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// WITH_STDLIB
// ISSUE: KT-50293
@@ -7,6 +7,6 @@ fun interface ReadOnlyProperty<in T, out V> {
}
class Problem {
val variable: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!><!INFERRED_TYPE_VARIABLE_INTO_POSSIBLE_EMPTY_INTERSECTION!>delegate<!>()<!> // delegate returns `ReadOnlyProperty<Problem, {CharSequence & Int}>`
val variable: Int by <!INFERRED_TYPE_VARIABLE_INTO_POSSIBLE_EMPTY_INTERSECTION!>delegate<!>() // delegate returns `ReadOnlyProperty<Problem, {CharSequence & Int}>`
fun <T : CharSequence> delegate() = null <!CAST_NEVER_SUCCEEDS!>as<!> ReadOnlyProperty<Problem, T>
}
@@ -28,11 +28,11 @@ internal class TowerDataElementsForName2() {
}
internal class TowerDataElementsForName3() {
val reversedFilteredLocalScopes by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>lazy<!>(LazyThreadSafetyMode.NONE) {
val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) {
@OptIn(ExperimentalStdlibApi::class)
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildList<!> l1@ {
buildList l1@ {
for (i in lastIndex downTo 0) {
val reversedFilteredLocalScopes by <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>lazy(LazyThreadSafetyMode.NONE) {
val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) {
@OptIn(ExperimentalStdlibApi::class)
buildList {
for (i in lastIndex downTo 0) {
@@ -40,15 +40,15 @@ internal class TowerDataElementsForName3() {
this@l1.add("")
}
}
}<!>
}
}
}
}<!>
}
}
internal class TowerDataElementsForName4() {
@OptIn(ExperimentalStdlibApi::class)
val reversedFilteredLocalScopes = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildList<!> l1@ {
val reversedFilteredLocalScopes = buildList l1@ {
class Foo {
val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) {
@OptIn(ExperimentalStdlibApi::class)
@@ -28,11 +28,11 @@ internal class TowerDataElementsForName2() {
}
internal class TowerDataElementsForName3() {
val reversedFilteredLocalScopes by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>lazy<!>(LazyThreadSafetyMode.NONE) {
val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) {
@OptIn(ExperimentalStdlibApi::class)
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildList<!> l1@ {
buildList l1@ {
for (i in lastIndex downTo 0) {
val reversedFilteredLocalScopes by <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>lazy(LazyThreadSafetyMode.NONE) {
val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) {
@OptIn(ExperimentalStdlibApi::class)
buildList {
for (i in lastIndex downTo 0) {
@@ -40,15 +40,15 @@ internal class TowerDataElementsForName3() {
this@l1.add("")
}
}
}<!>
}
}
}
}<!>
}
}
internal class TowerDataElementsForName4() {
@OptIn(ExperimentalStdlibApi::class)
val reversedFilteredLocalScopes = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildList<!> l1@ {
val reversedFilteredLocalScopes = buildList l1@ {
class Foo {
val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) {
@OptIn(ExperimentalStdlibApi::class)
@@ -1 +0,0 @@
/inconsistentTypeInference.fir.kt:(62,127): error: New inference error [NewConstraintError at Incorporate kotlin/collections/MutableList<TypeVariable(E)> <: kotlin/collections/Collection<kotlin/Int> from Incorporated builder inference constraint kotlin/collections/MutableList<Stub (chain inference): TypeVariable(E)> <: kotlin/collections/Collection<TypeVariable(T)> from Receiver this@R|special/anonymous| into some call from position Incorporated builder inference constraint kotlin/collections/MutableList<Stub (chain inference): TypeVariable(E)> <: kotlin/collections/Collection<TypeVariable(T)> from Receiver this@R|special/anonymous| into some call: kotlin/String <!: kotlin/Int].
@@ -2,9 +2,9 @@
// FIR_DUMP
fun foo() {
<!NEW_INFERENCE_ERROR!>buildList {
buildList {
add("Boom")
println(plus(1)[0])
}<!>
}
}
@@ -1,8 +1,8 @@
FILE: inconsistentTypeInference.fir.kt
public final fun foo(): R|kotlin/Unit| {
R|kotlin/collections/buildList<CS errors: kotlin/collections/buildList>#|<R|kotlin/String|>(<L> = buildList@fun R|kotlin/collections/MutableList<kotlin/String>|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
R|kotlin/collections/buildList|<R|kotlin/String|>(<L> = buildList@fun R|kotlin/collections/MutableList<kotlin/String>|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
this@R|special/anonymous|.R|SubstitutionOverride<kotlin/collections/MutableList.add: R|kotlin/Boolean|>|(String(Boom))
R|kotlin/io/println|(this@R|special/anonymous|.R|kotlin/collections/plus|<R|kotlin/Int|>(Int(1)).R|SubstitutionOverride<kotlin/collections/List.get: R|kotlin/Int|>|(Int(0)))
R|kotlin/io/println|(this@R|special/anonymous|.R|kotlin/collections/plus|<R|it(kotlin/Comparable<*> & java/io/Serializable)|>(Int(1)).R|SubstitutionOverride<kotlin/collections/List.get: R|it(kotlin/Comparable<*> & java/io/Serializable)|>|(Int(0)))
}
)
}
@@ -1 +0,0 @@
/inconsistentTypeInference2.fir.kt:(62,132): error: New inference error [NewConstraintError at Incorporate kotlin/collections/MutableList<TypeVariable(E)> <: kotlin/collections/Collection<kotlin/Int> from Incorporated builder inference constraint kotlin/collections/MutableList<Stub (chain inference): TypeVariable(E)> <: kotlin/collections/Collection<TypeVariable(T)> from Receiver this@R|special/anonymous| into some call from position Incorporated builder inference constraint kotlin/collections/MutableList<Stub (chain inference): TypeVariable(E)> <: kotlin/collections/Collection<TypeVariable(T)> from Receiver this@R|special/anonymous| into some call: kotlin/String <!: kotlin/Int].
@@ -2,8 +2,8 @@
// FIR_DUMP
fun bar() {
<!NEW_INFERENCE_ERROR!>buildList {
buildList {
add("Boom")
println(this.plus(1)[0])
}<!>
}
}
@@ -1,8 +1,8 @@
FILE: inconsistentTypeInference2.fir.kt
public final fun bar(): R|kotlin/Unit| {
R|kotlin/collections/buildList<CS errors: kotlin/collections/buildList>#|<R|kotlin/String|>(<L> = buildList@fun R|kotlin/collections/MutableList<kotlin/String>|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
R|kotlin/collections/buildList|<R|kotlin/String|>(<L> = buildList@fun R|kotlin/collections/MutableList<kotlin/String>|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
this@R|special/anonymous|.R|SubstitutionOverride<kotlin/collections/MutableList.add: R|kotlin/Boolean|>|(String(Boom))
R|kotlin/io/println|(this@R|special/anonymous|.R|kotlin/collections/plus|<R|kotlin/Int|>(Int(1)).R|SubstitutionOverride<kotlin/collections/List.get: R|kotlin/Int|>|(Int(0)))
R|kotlin/io/println|(this@R|special/anonymous|.R|kotlin/collections/plus|<R|it(kotlin/Comparable<*> & java/io/Serializable)|>(Int(1)).R|SubstitutionOverride<kotlin/collections/List.get: R|it(kotlin/Comparable<*> & java/io/Serializable)|>|(Int(0)))
}
)
}