Skip to content

java.lang.Boolean.TRUE doesn't conform to the instance type java.lang.Boolean.TRUE.type in function parameters #12901

Open
@unkarjedy

Description

@unkarjedy

Scala 2.13.12

Example:

class Key[T] {}

object example {
  private val Key: Key[java.lang.Boolean.TRUE.type] = new Key[java.lang.Boolean.TRUE.type]

  def putUserData[T](key: Key[T], value: T): Unit = ???

  def main(args: Array[String]): Unit = {
    //OK: compiles fine
    val value: java.lang.Boolean.TRUE.type = java.lang.Boolean.TRUE
    val option: Option[java.lang.Boolean.TRUE.type] = Option(java.lang.Boolean.TRUE)

    //Error: found: Boolean, required: Boolean.TRUE.type
    putUserData(Key, java.lang.Boolean.TRUE)
  }
}

The code compiles with error at line 14

type mismatch;
 found   : Boolean
 required: Boolean.TRUE.type
    putUserData(Key, java.lang.Boolean.TRUE)

Note that it compiles fine in Scala 3.3.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions