Skip to content
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

[Focus] Compilation fails in Scala 3 in nested case class/object #1293

Open
rpiaggio opened this issue Jul 29, 2022 · 0 comments
Open

[Focus] Compilation fails in Scala 3 in nested case class/object #1293

rpiaggio opened this issue Jul 29, 2022 · 0 comments

Comments

@rpiaggio
Copy link

With Monocle 3.1.0,

class OpticsSuite extends DisciplineSuite {

  final case class Nested(a: Int)
  object Nested {
    val a: Lens[Nested, Int] = Focus[Nested](_.a)
  }
}

fails with

[error] -- Error: (...)/OpticsSuite.scala:37:44 
[error] 37 |    val a: Lens[Nested, Int] = Focus[Nested](_.a)
[error]    |                               ^^^^^^^^^^^^^^^^^^
[error]    |Exception occurred while executing macro expansion.
[error]    |java.lang.ClassCastException: class dotty.tools.dotc.ast.Trees$This cannot be cast to class dotty.tools.dotc.ast.Trees$RefTree (dotty.tools.dotc.ast.Trees$This and dotty.tools.dotc.ast.Trees$RefTree are in unnamed module of loader sbt.internal.classpath.ClassLoaderCache$Key$CachedClassLoader @7df31f1b)
[error]    |    at scala.quoted.runtime.impl.QuotesImpl.scala$quoted$runtime$impl$QuotesImpl$reflect$Ref$$$_$apply$$anonfun$6(QuotesImpl.scala:436)
[error]    |    at scala.quoted.runtime.impl.QuotesImpl$reflect$.scala$quoted$runtime$impl$QuotesImpl$reflect$$$withDefaultPos(QuotesImpl.scala:2904)
[error]    |    at scala.quoted.runtime.impl.QuotesImpl$reflect$Ref$.apply(QuotesImpl.scala:436)
[error]    |Testat scala.quoted.runtime.impl.QuotesImpl$reflect$Ref$.apply(QuotesImpl.scala:434)
[error]    |    at monocle.internal.focus.features.selectonlyfield.SelectOnlyFieldParser.getCompanionObject$$anonfun$1(SelectOnlyFieldParser.scala:36)
[error]    |    at scala.util.Either.map(Either.scala:382)
[error]    |    at monocle.internal.focus.features.selectonlyfield.SelectOnlyFieldParser.getCompanionObject(SelectOnlyFieldParser.scala:36)
[error]    |    at monocle.internal.focus.features.selectonlyfield.SelectOnlyFieldParser.getFieldAction$$anonfun$1(SelectOnlyFieldParser.scala:28)
[error]    |    at scala.util.Either.flatMap(Either.scala:352)
[error]    |    at monocle.internal.focus.features.selectonlyfield.SelectOnlyFieldParser.monocle$internal$focus$features$selectonlyfield$SelectOnlyFieldParser$$getFieldAction(SelectOnlyFieldParser.scala:30)
[error]    |    at monocle.internal.focus.features.selectonlyfield.SelectOnlyFieldParser$SelectOnlyField$.unapply(SelectOnlyFieldParser.scala:17)
[error]    |    at monocle.internal.focus.features.ParserLoop.loop$1(ParserLoop.scala:56)
[error]    |    at monocle.internal.focus.features.ParserLoop.parseFocusActions(ParserLoop.scala:64)
[error]    |    at monocle.internal.focus.features.ParserLoop.parseFocusActions$(ParserLoop.scala:27)
[error]    |    at monocle.internal.focus.FocusImpl.parseFocusActions(FocusImpl.scala:7)
[error]    |    at monocle.internal.focus.FocusImpl.$anonfun$1(FocusImpl.scala:20)
[error]    |    at scala.util.Either.flatMap(Either.scala:352)
[error]    |    at monocle.internal.focus.FocusImpl.run(FocusImpl.scala:22)
[error]    |    at monocle.internal.focus.FocusImpl$.apply(FocusImpl.scala:33)
[error]    |
[error]    |----------------------------------------------------------------------------
[error]    |Inline stack trace
[error]    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]    |This location contains code that was inlined from Focus.scala:35
[error]     ----------------------------------------------------------------------------
[error] one error found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant