We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can be used to avoid unnecessary null-checks when inlining an instance method.
Miguel's code: NullnessPropagator
Below there are two null checks in t, none is necessary: t is an instance method, we know in it's body that ALOAD 0 is non-null.
t
ALOAD 0
class C { @inline final def f = 1 def t = f + f }
The text was updated successfully, but these errors were encountered:
Nullness analysis is implemented in scala/scala#4519, performance of aliasing analysis improved in scala/scala#4711.
still to do: Peephole opts around null
also to do: take null tests into account (if (x == null) { [x known null here] })
Miguel's treats module loads as not null. Jason provided a counterexample:
class C(a: Any) object X { def o = O} object O extends C(println(X.o)) { println(O) } object Test extends App { O }
scalac sandbox/test.scala && qscala Test null O$@4c873330
A bit simpler:
class C { val b = O } object O extends C object Test extends App { println(O.b) // null }
Another example:
object A1 extends { val e = B1 } with Object { val b1 = B1 } object B1 { val a1 = A1 } object Test extends App { println(A1.b1) // B1 println(B1.a1) // null println(A1.e) // B1 }
See also #16
Sorry, something went wrong.
PatMat generates null tests that can potentially be eliminated:
public f(I)I L0 LINENUMBER 3 L0 NEW C DUP ILOAD 1 INVOKESPECIAL C.<init> (I)V ASTORE 3 ALOAD 3 IFNULL L1 [...]
Implemented in scala/scala#4858 / scala/scala@80b0660
No branches or pull requests
Can be used to avoid unnecessary null-checks when inlining an instance method.
Miguel's code: NullnessPropagator
Below there are two null checks in
t
, none is necessary:t
is an instance method, we know in it's body thatALOAD 0
is non-null.The text was updated successfully, but these errors were encountered: