Skip to content

Commit

Permalink
Merge pull request #1144 from kptncook/fix-enum-derivation
Browse files Browse the repository at this point in the history
Fix enum derivation
  • Loading branch information
yanns authored Oct 28, 2024
2 parents 19bf882 + b3bf911 commit aa7ad7e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class DeriveEnumTypeMacro(context: blackbox.Context)

val actualValue =
if (value.isModuleClass) {
if (value.owner.isModuleClass) {
if (value.owner.isModuleClass && !value.owner.isPackage) {
q"${value.owner.name.toTermName}.${value.name.toTermName}"
} else {
q"${value.name.toTermName}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import sangria.schema._
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

class DeriveEnumTypeMacroSpec extends AnyWordSpec with Matchers {
import DeriveMacroTestModel._
sealed trait Difficulty

sealed trait Difficulty
object Difficulty {
case object Easy extends Difficulty
case object Medium extends Difficulty
case object Hard extends Difficulty
}

object Difficulty {
case object Easy extends Difficulty
case object Medium extends Difficulty
case object Hard extends Difficulty
}
sealed trait Fruit

sealed trait Fruit
case object RedApple extends Fruit
case object SuperBanana extends Fruit
case object MegaOrange extends Fruit

case object RedApple extends Fruit
case object SuperBanana extends Fruit
case object MegaOrange extends Fruit
sealed abstract class ExoticFruit(val score: Int) extends Fruit

sealed abstract class ExoticFruit(val score: Int) extends Fruit
case object Guava extends ExoticFruit(123)

case object Guava extends ExoticFruit(123)
class DeriveEnumTypeMacroSpec extends AnyWordSpec with Matchers {
import DeriveMacroTestModel._

@GraphQLName("MyFruit")
@GraphQLDescription("Very tasty fruit")
Expand Down

0 comments on commit aa7ad7e

Please sign in to comment.