Skip to content

Instantly share code, notes, and snippets.

View erokhins's full-sized avatar

Stanislav Erokhin erokhins

  • JetBrains
  • Amsterdam
View GitHub Profile

Code fragment:

fun test() = 1 // comment

Kotlin code fragment:

fun test2() = 2 // comment
// FILE: 1.kt
package p3
class A {
fun <T> test(a: List<T>): Int {
println("Function 1")
return 1
}
fun test(b: List<Int>) {
println("Function 2")
// FILE: 1.kt
package p3
class A {
fun<T> inTransaction(block: (tran: String) -> T): T {
println("Function 1")
return block("")
}
fun inTransaction(block: (tran: String) -> Unit) {
@erokhins
erokhins / fine-grained-variance-check.md
Created May 2, 2018 17:55 — forked from mekarthedev/fine-grained-variance-check.md
Kotlin proposal: Allow `out` type parameter to occur in `in` position

Allow out type parameter to safely occur in in position

  • Type: Design proposal
  • Author: Viacheslav Makarov
  • Status: Draft

Summary

Reduce the need in @UnsafeVariance. Allow covariant types to have non-private methods with non-covariant signature. To protect class' covariance, out-project signatures