Skip to content

Use of outer type argument in extension inline unapply(Seq) method causes compiler error #15188

Closed
@gorilskij

Description

@gorilskij

Compiler version

#15053

Minimized code

object O

extension [T] (ctx: O.type) inline def unapplySeq(input: T): Option[Seq[T]] = Some(Seq(input)) 

@main
def Main = {
  val O(x) = 3
  println(s"x: $x")
}

Output

Compiler error

Exception in thread "main" java.lang.IndexOutOfBoundsException: 0
        at scala.collection.LinearSeqOps.apply(LinearSeq.scala:117)
        at scala.collection.LinearSeqOps.apply$(LinearSeq.scala:114)
        at scala.collection.immutable.List.apply(List.scala:79)
        at dotty.tools.dotc.core.Substituters$.substParams(Substituters.scala:151)
        at dotty.tools.dotc.core.Substituters$SubstParamsMap.apply(Substituters.scala:197)
        at dotty.tools.dotc.core.Substituters$SubstParamsMap.apply(Substituters.scala:197)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda(Types.scala:5553)
        at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5582)
        at dotty.tools.dotc.core.Substituters$.substParams(Substituters.scala:161)
        at dotty.tools.dotc.core.Substituters$SubstParamsMap.apply(Substituters.scala:197)
        at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda(Types.scala:5555)
        at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5582)
        at dotty.tools.dotc.core.Substituters$.substParams(Substituters.scala:161)
        ...

Expectation

x: 3

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions