Skip to content

Detect explicitly spliced wildcard types #8871

Closed
@nicolasstucki

Description

@nicolasstucki

We are not allowed to splice wildcard types to avoid soundness issues. They are not checked when explicitly spliced:

import scala.quoted._
object Macro {
  def impl[A : Type](using qctx: QuoteContext): Unit = {
    import qctx.tasty._
    val tpe = typeOf[A].seal.asInstanceOf[quoted.Type[_ <: AnyRef]]
    '{ (a: ${tpe}) => ???} // should be an error
  }
}
import scala.quoted._
object Macro {
  def impl[A : Type](using qctx: QuoteContext): Unit = {
    import qctx.tasty._
    val tpe/*: quoted.Type[? <: AnyKind]*/ = typeOf[A].seal
    '{ f[$tpe] } // should be an error
  }
  def f[T <: AnyKind]: Unit = ()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions