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

Fix #56 #57

Merged
merged 8 commits into from
Jul 12, 2021
Merged

Fix #56 #57

merged 8 commits into from
Jul 12, 2021

Conversation

kubukoz
Copy link
Member

@kubukoz kubukoz commented Jul 7, 2021

@kubukoz kubukoz changed the title Reproduce issues from #56 Fix #56 Jul 11, 2021
d.name.toString
def methodNames(clazz: Clazz): List[String] = clazz.impl.body.collect {
case d: DefDef => d.name.toString
case d: ValDef => d.name.toString
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added to support override val toString in both Scala versions. A better name for methodNames would be welcome, although memberNames would miss var (which isn't a suitable implementation for toString)

}

def isCaseClass(clazz: Clazz): Boolean = clazz.mods.hasFlag(Flags.CASE)
def isObject(clazz: Clazz): Boolean = clazz.mods.hasFlag(Flags.MODULE)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added to skip () from case objects.

@@ -34,7 +37,8 @@ object Scala3CompilerApi:
case v: ValDef if v.mods.is(CaseAccessor) => v
}

def className(clazz: Clazz): String = clazz.clazz.name.toString
def className(clazz: Clazz): String =
clazz.clazz.originalName.toString
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

originalName lets us avoid the $ in case objects.

@kubukoz kubukoz marked this pull request as ready for review July 11, 2021 23:49
Copy link
Collaborator

@mrobakowski mrobakowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}
// note: also returns vals because why not
def methodNames(clazz: Clazz): List[String] =
clazz.t.body.collect { case d: (DefDef | ValDef) =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do that in Scala 3??? pog

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently :D

@kubukoz kubukoz merged commit f80f946 into master Jul 12, 2021
@kubukoz kubukoz deleted the issue-56 branch July 12, 2021 14:20
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 this pull request may close these issues.

Scala 3: case objects with override val toString get a duplicate definition
2 participants