Skip to content

summonFrom default case binding #7977

Closed
@nicolasstucki

Description

@nicolasstucki

minimized code

import scala.compiletime.summonFrom
class Main {
  inline def foo(): Any = summonFrom {
    case x => println("foo " + x)
  }
  foo()
}

expectation

Should not allow bindings to be defined for the default case in a summonFrom.

Details

Stack trace
> dotc -Xprint:typer Foo.scala 
result of Foo.scala after typer:
package <empty> {
  import scala.compiletime.summonFrom
  class Main() extends Object() {
    inline def foo(): Any = 
      (implicit match 
        {
          case given x @ _ => 
            println("foo ".+(x))
        }
      ):Any
    {
      {
        given val x: implicit = $scrutinee1
        println("foo ".+(x))
      }:Any
    }
  }
}
exception occurred while compiling Foo.scala
java.lang.AssertionError: assertion failed: unresolved symbols: value $scrutinee1(line 5) when pickling Foo.scala while compiling Foo.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: unresolved symbols: value $scrutinee1(line 5) when pickling Foo.scala
        at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:704)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$10$$anonfun$8(Pickler.scala:63)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:305)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$2(Pickler.scala:87)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:305)
        at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:87)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:315)
        at scala.collection.immutable.List.map(List.scala:219)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:316)
        at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:91)
        at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:167)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
        at dotty.tools.dotc.Run.runPhases$5(Run.scala:177)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:185)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:192)
        at dotty.tools.dotc.Run.compileSources(Run.scala:129)
        at dotty.tools.dotc.Run.compile(Run.scala:112)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:36)
        at dotty.tools.dotc.Driver.process(Driver.scala:189)
        at dotty.tools.dotc.Driver.process(Driver.scala:158)
        at dotty.tools.dotc.Driver.process(Driver.scala:170)
        at dotty.tools.dotc.Driver.main(Driver.scala:197)
        at dotty.tools.dotc.Main.main(Main.scala)```
</details>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions