Skip to content

Fix selceting type member in unsafe nulls #12031

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

Merged
merged 1 commit into from
Apr 11, 2021

Conversation

noti0na1
Copy link
Member

@noti0na1 noti0na1 commented Apr 8, 2021

Fix:

scalac -Yexplicit-nulls -language:unsafeNulls tests/explicit-nulls/unsafe-common/unsafe-select-type-member.scala
import java.util.ArrayList

def f[T]: ArrayList[T] = {
  val cz = Class.forName("java.util.ArrayList")
  val o = cz.newInstance() // error: T of Class[?] | Null
  o.asInstanceOf[ArrayList[T]]
}

@noti0na1 noti0na1 requested a review from odersky April 8, 2021 17:35
@odersky odersky merged commit b44cafa into scala:master Apr 11, 2021
@odersky odersky deleted the fix-type-member-select branch April 11, 2021 08:07
@Kordyjan Kordyjan added this to the 3.0.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants