Skip to content

Instantly share code, notes, and snippets.

@tateisu
Created August 18, 2014 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tateisu/8e63b9a22fdcac4843fd to your computer and use it in GitHub Desktop.
Save tateisu/8e63b9a22fdcac4843fd to your computer and use it in GitHub Desktop.
android.support.annotation の @NonNull が定数式以外に全く効果が無い件。
この場合は test() の3つ目は警告を出して欲しいだろう普通
boolean f1( @NonNull String arg){
return arg.contains( "foo" );
}
@NonNull String getString(){
return "foo";
}
String getStringOrNull(){
return (System.currentTimeMillis() %1) ==0 ? null : "foo";
}
void test(){
f1(null); // 警告が出る
f1(getString()); // 警告が出ない
f1(getStringOrNull()); // 警告が出ない
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment