Consider the following method:
void a () { int x; boolean b = false; if (Math.random() < 0.5) { x = 0; b = true; }
There is one :
void a () { if (Math.random() < 0.5) { int x = 1; } }
The compiler isn't responsible for devising and testing the algorithm. You are.
But maybe you should propose a more practical use case. Your example doesn't really show what's your goal.