Skip to content

cannot override generic Java method instantiated with value class with -Yexplicit-nulls #15194

Open
@olhotak

Description

@olhotak

Compiler version

Scala compiler version 3.2.0-RC1-bin-SNAPSHOT-git-7fbbeef -- Copyright 2002-2022, LAMP/EPFL

Minimized code

import language.unsafeNulls

class PosZLong(value: Long) extends AnyVal

object PosZLongOrd extends Ordering[PosZLong]:
  def compare(x: PosZLong, y: PosZLong): Int = 0

Compile with scalac -Yexplicit-nulls PosZLong.scala

Minimized from scalatest/scalactic.

Output

-- Error: PosZLong.scala:4:7 --------------------------------------------------------------------------------------------------------------
4 |object PosZLongOrd extends Ordering[PosZLong]:
  |       ^
  |object creation impossible, since def compare(x$0: T | Null, x$1: T | Null): Int in trait Comparator in package java.util is not defined 
  |(The class implements a member with a different type: def compare(x: PosZLong, y: PosZLong): Int in object PosZLongOrd)
1 error found

Expectation

Should compile.

Fails to compile independently of language.unsafeNulls.

Probably related to #13975.

Blocker in community build for scalatest and the many projects that depend on it.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions