Skip to content

Generic number literals miss overloaded method #11482

Closed
@rjolly

Description

@rjolly

Compiler version

3.0.0-RC1

Minimized code and output

import scala.language.experimental.genericNumberLiterals
type BigInteger = java.math.BigInteger
given BigInteger: scala.util.FromDigits[BigInteger] with {
  def fromDigits(digits: String) = new BigInteger(digits)
  def apply(x: BigInteger) = x
  def apply(x: String) = fromDigits(x)
}
println(BigInteger(1))
        ^^^^^^^^^^
None of the overloaded alternatives of method apply in object BigInteger with types
 (x: String): BigInteger
 (x: BigInteger): BigInteger
match arguments ((1 : Int))

Expectation

Should work as when there's no overload:

given BigInteger: scala.util.FromDigits[BigInteger] with {
  def fromDigits(digits: String) = new BigInteger(digits)
  def apply(x: BigInteger) = x
}
println(BigInteger(1))
// 1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions