Skip to content

Mirror.SumOf fails to summon in the context of multiple files #9069

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
anatoliykmetyuk opened this issue May 28, 2020 · 2 comments
Closed

Mirror.SumOf fails to summon in the context of multiple files #9069

anatoliykmetyuk opened this issue May 28, 2020 · 2 comments

Comments

@anatoliykmetyuk
Copy link
Contributor

Test.scala:

def Test =
  summon[deriving.Mirror.SumOf[Foo]]

Wrapper.scala:

sealed trait Foo
case class Bar(x: Int) extends Foo

Compile together while specifying Test.scala first in the compiler command: dotty-bootstrapped/dotc -d out Test.scala Wrapper.scala.

Output:

-- Error: /Users/kmetiuk/Projects/scala3/playground/upickle-pg/Test.scala:2:36 -
2 |  summon[deriving.Mirror.SumOf[Foo]]
  |                                    ^
  |no implicit argument of type deriving.Mirror.SumOf[Foo] was found for parameter x of method summon in object DottyPredef
-- Error: /Users/kmetiuk/Projects/scala3/playground/upickle-pg/Wrapper.scala:2:11
2 |case class Bar(x: Int) extends Foo
  |           ^
  |children of trait Foo were already queried before class Bar was discovered.
  |As a remedy, you could move class Bar on the same nesting level as trait Foo.
2 errors found

If you flip the order of the files in the command (dotty-bootstrapped/dotc -d out Wrapper.scala Test.scala) or compile them as a single file:

sealed trait Foo
case class Bar(x: Int) extends Foo
def Test =
  summon[deriving.Mirror.SumOf[Foo]]

The compilation succeeds.

You can reproduce the issue with Dotty Issues Workspace using the following launch.iss script:

launch.iss
$ (rm -rv out || true) && mkdir out  # Cleanup

dotty-bootstrapped/dotc -d out
  $here/Test.scala $here/Wrapper.scala

/cc @milessabin

@anatoliykmetyuk anatoliykmetyuk changed the title Mirror.SumOf fail to resolve in the context of multiple files Mirror.SumOf fails to summon in the context of multiple files May 28, 2020
@smarter
Copy link
Member

smarter commented May 28, 2020

Same issue as #9064 ?

@anatoliykmetyuk
Copy link
Contributor Author

Could be. I discovered it in upickle, and it also kept blowing up with java.lang.OutOfMemoryError.

@odersky odersky self-assigned this May 30, 2020
odersky added a commit to dotty-staging/dotty that referenced this issue May 30, 2020
Complete children of sealed classes or traits when the parent class is completed.
odersky added a commit to dotty-staging/dotty that referenced this issue May 30, 2020
Complete children of sealed classes or traits when the parent class is completed.
odersky added a commit to dotty-staging/dotty that referenced this issue May 30, 2020
Complete all possible children of sealed classes or traits before first querying
with `children`. This way we make they register themselves with Child annotations
in the parent class.
odersky added a commit to dotty-staging/dotty that referenced this issue May 30, 2020
Complete all possible children of sealed classes or traits before first querying
with `children`. This way we make they register themselves with Child annotations
in the parent class.
odersky added a commit to dotty-staging/dotty that referenced this issue May 30, 2020
Complete all possible children of sealed classes or traits before first querying
with `children`. This way we make they register themselves with Child annotations
in the parent class.
anatoliykmetyuk added a commit that referenced this issue Jun 2, 2020
Fix #9069: Complete children of sealed classes early
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

3 participants