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

tasty reader, selection of top level definition from package does not work in an annotation #12642

Open
bishabosha opened this issue Sep 20, 2022 · 5 comments
Assignees
Milestone

Comments

@bishabosha
Copy link
Member

bishabosha commented Sep 20, 2022

originally found in typelevel/cats#4304

Reproduction steps

Scala version: 2.13.9

//> using scala "2.13.9"
//> using options "-Ytasty-reader", "-Ydebug-tasty"
//> using lib "org.typelevel:cats-core_3:2.8.0"

import cats.syntax.all._

object Main extends App

Problem

this code makes the error

./bar.scala:7:21: can't find type required by method catsInstancesForIdCompat2_6_1 in object cats.Invariant: compat.targetName; perhaps it is missing from the classpath.

The cause? annotations of the Invariant.catsInstancesForIdCompat2_6_1 method get forced, one of them being @cats.compat.targetName(...).

targetName is a type alias defined in cats.compat.compat$package but it seems that is never looked at because top level definition wrappers are not considered as part of the package scope in scala 2.

in the -Ydebug-tasty trace, we see that tasty reader tries to force the cats.compat.package package object which is of course empty.

#[6266, Invariant]: [8) <<< forcing annotations of symbol: `(#11713) method catsInstancesForIdCompat2_6_1`
#[6266, Invariant]: [8 0) <<< read within owner: `(#11713) method catsInstancesForIdCompat2_6_1` with modes `ReadAnnotation | ReadAnnotationCtor` at Addr(1118)
#[6266, Invariant]: [8 0 0) <<< reading annotation tree: `(#1738) class targetName` at Addr(1118)
#[6266, Invariant]: [8 0 0 0) <<< force symbol info: `(#7525) package class compat` in context `(#11713) method catsInstancesForIdCompat2_6_1` [space,deep]
#[6266, Invariant]: [8 0 0 0) >>> `(#7525) package class compat` was forced [space,deep]
[error] ./bar.scala:7:21: can't find type required by method catsInstancesForIdCompat2_6_1 in object cats.Invariant: compat.targetName; perhaps it is missing from the classpath.
[error] object Main extends App
[error]                     ^
Error compiling project (Scala 2.13.9, JVM)
Compilation failed
@bishabosha bishabosha self-assigned this Sep 20, 2022
@SethTisue SethTisue added this to the 2.13.10 milestone Sep 20, 2022
@SethTisue
Copy link
Member

@bishabosha if you want to get a fix into 2.13.10, you might need to prepare one soon, since bug 12650 may force us to do 2.13.10 promptly

@bishabosha
Copy link
Member Author

this is more complicated to "fix" because there is also no support for targetName either - so fixing this resolution error will still have the incorrect method call at runtime - but if the method is not used directly from scala 2 then fine

@bishabosha
Copy link
Member Author

bishabosha commented Oct 4, 2022

@sjrd opinion is that top level definitions are too complex to put effort to support, in typelevel/cats#4304 I suggest to move cats.compat.targetName to a normal package object, then it is an open question of can we implement support for targetName annotation.

@SethTisue SethTisue modified the milestones: 2.13.10, 2.13.11 Oct 8, 2022
@SethTisue
Copy link
Member

@bishabosha shall we "Backlog" this, then, or did you want to make an attempt for 2.13.11? I'll assume Backlog, but we can flip it back.

@SethTisue SethTisue modified the milestones: 2.13.11, Backlog Feb 20, 2023
@bishabosha
Copy link
Member Author

Backlog is fine

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

2 participants