Skip to content

Erased fields are not nullable #23311

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CollectNullableFields extends MiniPhase {
val sym = tree.symbol
val isNullablePrivateField =
sym.isField &&
!sym.is(Lazy) &&
!sym.isOneOf(Lazy | Erased) &&
!sym.owner.is(Trait) &&
sym.initial.isAllOf(PrivateLocal) &&
// We need `isNullableClassAfterErasure` and not `isNullable` because
Expand Down
24 changes: 24 additions & 0 deletions tests/run/i23305.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//> using options -language:experimental.erasedDefinitions

erased trait DBMeta[A]

trait Table[A]

case class Saved[A]()
object Saved {
def table[A](using dbm: DBMeta[A]): Table[Saved[A]] = new Table[Saved[A]] {}
}

case class deleteBulk[A](as: List[Saved[A]])(using dbm: DBMeta[A], tbl: Table[A]) {
final given savedTable: Table[Saved[A]] = Saved.table[A]
}

case class Foo()
object Foo {
given dbMeta: DBMeta[Foo] = new DBMeta[Foo] {}
given table: Table[Foo] = new Table[Foo] {}
}

@main def Test =
val del = deleteBulk(List(Saved[Foo]()))
del.savedTable
Loading