Skip to content

Commit

Permalink
Nullability example
Browse files Browse the repository at this point in the history
  • Loading branch information
tevjef committed Jan 4, 2018
1 parent 709ccd6 commit ef33495
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
36 changes: 36 additions & 0 deletions example/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
buildscript {
ext.kotlin_version = '1.2.10'

repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}


apply plugin: 'java'
apply plugin: 'kotlin'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile group: 'junit', name: 'junit', version: '4.12'
}

compileKotlin {
kotlinOptions.jvmTarget = "1.6"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.6"
}

dependencies {
compile rootProject
}
9 changes: 9 additions & 0 deletions example/src/main/java/me/tevjef/Example.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package me.tevjef;

import io.reactivex.Observable;

public class Example {
public static void main(String[] args) {
Observable.fromIterable(null);
}
}
8 changes: 8 additions & 0 deletions example/src/main/java/me/tevjef/Example.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package me.tevjef

import io.reactivex.Observable

fun main(args: Array<String>) {
// Compile time failure when fromIterable is annotated with io.reactivex.annotations.NonNull
Observable.fromIterable<Int>(null)
}
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Thu Jan 04 09:42:32 EST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
rootProject.name='rxjava'
include 'example'

2 changes: 1 addition & 1 deletion src/main/java/io/reactivex/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ public static <T> Observable<T> fromFuture(Future<? extends T> future, Scheduler
*/
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Observable<T> fromIterable(Iterable<? extends T> source) {
public static <T> Observable<T> fromIterable(@NonNull Iterable<? extends T> source) {
ObjectHelper.requireNonNull(source, "source is null");
return RxJavaPlugins.onAssembly(new ObservableFromIterable<T>(source));
}
Expand Down

0 comments on commit ef33495

Please sign in to comment.