Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Cannot print wildcard singleton type #156

Closed
@tindzk

Description

@tindzk

It is possible to instantiate a singleton type parameter with a wildcard, but not print it:

$ curl -s https://raw.githubusercontent.com/typelevel/scala/typelevel-readme/try-typelevel-scala.sh | bash

Loading...
Welcome to the Ammonite Repl 0.8.4
(Scala 2.12.2-bin-typelevel-4 Java 1.8.0_112)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ repl.compiler.settings.YliteralTypes.value = true  

@ case class Wrap[T <: Singleton](value: String with T) 
defined class Wrap
@ def f(): Wrap[_] = Wrap("test") 
defined function f
@ f() 
cmd3.sc:8: type arguments [_$1] do not conform to class Wrap's type parameter bounds [T <: Singleton]
            .print(res3, res3, "res3", _root_.scala.None)                                                                                                                               
             ^                                                                                                                                                                          
cmd3.sc:8: type arguments [_$1] do not conform to class Wrap's type parameter bounds [T <: Singleton]
            .print(res3, res3, "res3", _root_.scala.None)                                                                                                                               
                  ^                                                                                                                                                                     
Compilation Failed
@ f().value 
res3: String with Any = "test"

Edit: Here is a minimised example:

case class Wrap[T <: Singleton](value: T)
def f[T](value: T): Unit = {}
f(null.asInstanceOf[Wrap[_]])

The error occurs whenever Wrap[_] is passed as a function argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions