Skip to content

Surface for Option with a default value crashing with Scala 3 #3353

@OndrejSpanel

Description

@OndrejSpanel

Following code compiles and runs fine with Scala 2.13.12, but causes compile-time exception with Scala 3.3.1 and 3.4.0-RC3:

import wvlet.airframe.surface.Surface

object Main {
  case class FValue[T](value: Option[Int] = None)

  def main(args: Array[String]): Unit = {
    Surface.of[FValue[Int]]
  }
}

Tested with

libraryDependencies += "org.wvlet.airframe" %% "airframe-surface" % "24.1.1"

The error is:

java.lang.Exception: Expected an expression. This is a partially applied Term. Try eta-expanding the term first.

Details

C:\Dev\surface-option-bug\src\main\scala\Main.scala:7:15 Exception occurred while executing macro expansion. java.lang.Exception: Expected an expression. This is a partially applied Term. Try eta-expanding the term first. at scala.quoted.runtime.impl.QuotesImpl$reflect$TreeMethods$.asExpr(QuotesImpl.scala:110) at scala.quoted.runtime.impl.QuotesImpl$reflect$TreeMethods$.asExprOf(QuotesImpl.scala:116) at scala.quoted.runtime.impl.QuotesImpl$reflect$TreeMethods$.asExprOf(QuotesImpl.scala:115) at wvlet.airframe.surface.CompileTimeSurfaceFactory.$anonfun$37(CompileTimeSurfaceFactory.scala:662) at wvlet.airframe.surface.CompileTimeSurfaceFactory.$anonfun$adapted$6(CompileTimeSurfaceFactory.scala:662) at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:110) at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1538) at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:135) at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1605) at scala.collection.immutable.List.mapConserve(List.scala:472) at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1605) at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1504) at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:135) at dotty.tools.dotc.quoted.PickledQuotes$.spliceTerms(PickledQuotes.scala:152) at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:88) at scala.quoted.runtime.impl.QuotesImpl.unpickleExprV2(QuotesImpl.scala:3143) at wvlet.airframe.surface.CompileTimeSurfaceFactory.$anonfun$36(CompileTimeSurfaceFactory.scala:662) at scala.collection.Iterator$$anon$9.next(Iterator.scala:584) at scala.collection.immutable.List.prependedAll(List.scala:153) at scala.collection.immutable.List$.from(List.scala:684) at scala.collection.immutable.List$.from(List.scala:681) at scala.collection.IterableOps$WithFilter.map(Iterable.scala:898) at wvlet.airframe.surface.CompileTimeSurfaceFactory.wvlet$airframe$surface$CompileTimeSurfaceFactory$$methodParametersOf(CompileTimeSurfaceFactory.scala:747) at wvlet.airframe.surface.CompileTimeSurfaceFactory.wvlet$airframe$surface$CompileTimeSurfaceFactory$$constructorParametersOf(CompileTimeSurfaceFactory.scala:632) at wvlet.airframe.surface.CompileTimeSurfaceFactory$$anon$12.applyOrElse(CompileTimeSurfaceFactory.scala:327) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:288) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:289) at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266) at wvlet.airframe.surface.CompileTimeSurfaceFactory.wvlet$airframe$surface$CompileTimeSurfaceFactory$$surfaceOf(CompileTimeSurfaceFactory.scala:138) at wvlet.airframe.surface.CompileTimeSurfaceFactory.surfaceOf(CompileTimeSurfaceFactory.scala:78) at wvlet.airframe.surface.CompileTimeSurfaceFactory$.surfaceOf(CompileTimeSurfaceFactory.scala:15)

Surface.of[FValue[Int]]

Scastie repro:

https://scastie.scala-lang.org/5ohvZnwMSX6k2hZvo8el7Q

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions