K1: Adjust positioning for NO_CONTEXT_RECEIVER

This commit is contained in:
Denis.Zharkov
2022-04-06 09:59:47 +03:00
committed by teamcity
parent 82b6fdf97e
commit 3d06a92eea
12 changed files with 26 additions and 114 deletions
@@ -14,5 +14,5 @@ fun test() {
with(f) {
listOf(1, 2, 3).iterator(null)
}
listOf(1, 2, 3).<!NO_CONTEXT_RECEIVER!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>iterator<!>(null)<!>
}
listOf(1, 2, 3).<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NO_CONTEXT_RECEIVER!>iterator<!>(null)
}
@@ -1,34 +0,0 @@
// !LANGUAGE: +ContextReceivers
interface Semigroup<T> {
infix fun T.combine(other: T): T
}
interface Monoid<T> : Semigroup<T> {
val unit: T
}
object IntMonoid : Monoid<Int> {
override fun Int.combine(other: Int): Int = this + other
override val unit: Int = 0
}
object StringMonoid : Monoid<String> {
override fun String.combine(other: String): String = this + other
override val unit: String = ""
}
public inline fun <T, R> Iterable<T>.fold(initial: R, operation: (acc: R, T) -> R): R = TODO()
context(Monoid<T>)
fun <T> List<T>.sum(): T = fold(unit) { acc, e -> acc.combine(e) }
fun <T> listOf(vararg items: T): List<T> = null!!
fun test() {
with(IntMonoid) {
listOf(1, 2, 3).sum()
}
with(StringMonoid) {
listOf(1, 2, 3).<!NO_CONTEXT_RECEIVER!>sum<!>()
listOf("1", "2", "3").sum()
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +ContextReceivers
interface Semigroup<T> {
@@ -28,7 +29,7 @@ fun test() {
listOf(1, 2, 3).sum()
}
with(StringMonoid) {
listOf(1, 2, 3).<!NO_CONTEXT_RECEIVER!>sum()<!>
listOf(1, 2, 3).<!NO_CONTEXT_RECEIVER!>sum<!>()
listOf("1", "2", "3").sum()
}
}
}