Skip to content
New issue

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

Omitting the null check for modules in == is not correct #9655

Open
scabug opened this issue Feb 12, 2016 · 1 comment
Open

Omitting the null check for modules in == is not correct #9655

scabug opened this issue Feb 12, 2016 · 1 comment
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Feb 12, 2016

Since scala/scala#2954 we omit null checks when generating SomeModule == x. This is incorrect, a module dereference may return null.

class C {
  println(s"O is $O")
  val r = O == ("hi": AnyRef)
}
object O extends C

object Test {
  def main(args: Array[String]): Unit = {
    println((new C).r)
  }
}

runs as

O is null
java.lang.NullPointerException
	at C.<init>(Test.scala:10)
	at O$.<init>(Test.scala:12)
	at O$.<clinit>(Test.scala)
	at C.<init>(Test.scala:9)
	at Test$.main(Test.scala:16)
	at Test.main(Test.scala)

Related to scala/scala-dev#8 (comment)

@scabug
Copy link
Author

scabug commented Feb 12, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9655?orig=1
Reporter: @lrytz
Affected Versions: 2.11.7
See #7852

@scabug scabug added the backend label Apr 7, 2017
@scabug scabug added this to the Backlog milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants