This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun bar(source: Observable<CharSequence>) { | |
} | |
fun foo(source: Observable<String>) { | |
bar(source) // Compilation error | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun bar(source: Observable<out CharSequence>) { | |
source.scan { a, b -> "$a,$b" } // Compilation error | |
} | |
fun foo(source: Observable<String>) { | |
bar(source) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Observable<out T> { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun bar(consumer: Consumer<String>) { | |
} | |
fun foo(consumer: Consumer<CharSequence>) { | |
bar(consumer) // Compilation error | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun bar(consumer: Consumer<in String>) { | |
if (consumer is Subject) { | |
val value: String = consumer.value // Compilation error | |
} | |
} | |
fun foo(consumer: Consumer<CharSequence>) { | |
bar(consumer) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Consumer<in T> { | |
fun accept(value: T) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun foo() { | |
val source: Observable<String> = observableOf("Hello") | |
bar(source) // No error | |
} | |
fun bar(source: Observable<CharSequence>) { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface UserDataSource { | |
Single<User> load(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
observableOf<String>(null) // Compilation error | |
// 2 | |
val o1: Observable<String?> = observableOf(null) | |
val o2: Observable<String> = o1 // Compilation error, types do not match | |
// 3 | |
val o1: Observable<String?> = observableOf(null) | |
val o2: Observable<String> = o1.notNull() // No error, null values filtered out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FragmentWithDialog(output: (Output) -> Unit) : Fragment() { | |
sealed class Output { | |
object DialogShown : Output() | |
} | |
} | |
class FragmentWithInput(input: Observable<Input>) : Fragment() { | |
sealed class Input { |
OlderNewer