Skip to content

summonFrom default case binding #7977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nicolasstucki opened this issue Jan 13, 2020 · 0 comments
Closed

summonFrom default case binding #7977

nicolasstucki opened this issue Jan 13, 2020 · 0 comments

Comments

@nicolasstucki
Copy link
Contributor

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>
@nicolasstucki nicolasstucki self-assigned this Jan 13, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 13, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 13, 2020
odersky added a commit that referenced this issue Jan 13, 2020
Fix #7977: Disallow unsupported pattern in summonFrom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant