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

Unable to get a surface of a class with package private members in Scala 3 #3416

Closed
OndrejSpanel opened this issue Feb 27, 2024 · 0 comments · Fixed by #3423
Closed

Unable to get a surface of a class with package private members in Scala 3 #3416

OndrejSpanel opened this issue Feb 27, 2024 · 0 comments · Fixed by #3423

Comments

@OndrejSpanel
Copy link
Contributor

Similar to #3356, tested with "org.wvlet.airframe" %% "airframe-surface" % "24.2.2"

Unable to generate surface of a class with package private values

import wvlet.airframe.surface.Surface

object Tools {
  class Pos(private[Tools] val pos: String) {
    private[Tools] def getPos: String = pos
  }
}

object Main {
  Surface.of[Tools.Pos]

  def main(args: Array[String]): Unit = {

  }
}

Error is:

value pos cannot be accessed as a member of (x : Tools.Pos) from module class Main$.

Notes:

  • Surface.methodsOf[Tools.Pos] gives the same error.
  • when I remove getPos, there are no errors when calling Surface.methodsOf[tools.Tools.Pos]
  • when I make pos public, I get a different error with methodsOf:
object Tools {
  class Pos(val pos: String) {
    private[Tools] def getPos: String = pos
  }
}

object Main {
  Surface.methodsOf[Tools.Pos]

  def main(args: Array[String]): Unit = {

  }
}

Error is:

method getPos cannot be accessed as a member of Tools.Pos from module class Main$.

All these variants work fine in Scala 2.

OndrejSpanel added a commit to OndrejSpanel/airframe that referenced this issue Feb 27, 2024
OndrejSpanel added a commit to OndrejSpanel/airframe that referenced this issue Feb 28, 2024
OndrejSpanel added a commit to OndrejSpanel/airframe that referenced this issue Feb 28, 2024
xerial added a commit that referenced this issue Feb 28, 2024
…cess (#3423)

Starting with tests - I hope I will be able to implement the fix as
well.

---------

Co-authored-by: Taro L. Saito <[email protected]>
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

Successfully merging a pull request may close this issue.

1 participant