Skip to content

Commit

Permalink
Merge pull request sangria-graphql#317 from dragos/issue/fix-172
Browse files Browse the repository at this point in the history
Initialize symbols before checking their annotations.
  • Loading branch information
OlegIlyenko committed Dec 29, 2017
2 parents 125d5bb + c70928f commit c6c5c77
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class DeriveObjectTypeMacro(context: blackbox.Context) extends {
val allFields = classFields ++ additionalFields(config)

if (allFields.nonEmpty) Right(allFields)
else Left(List(c.enclosingPosition "Field list is empty"))
else Left(List(c.enclosingPosition s"$targetType: Field list is empty"))
case errors Left(errors)
}
}
Expand Down Expand Up @@ -201,7 +201,9 @@ class DeriveObjectTypeMacro(context: blackbox.Context) extends {
}

private def findKnownMembers(tpe: Type, includeMethods: Set[String]): List[KnownMember] =
tpe.members.collect {
// we "force" m by calling info. This makes sure its type information is complete, in particular that
// annotations are available through `.annotations`
tpe.members.map { m => m.info; m }.collect {
case m: MethodSymbol if m.isCaseAccessor
KnownMember(tpe, m, findCaseClassAccessorAnnotations(tpe, m), accessor = true)
case m: MethodSymbol if memberField(m.annotations) || includeMethods.contains(m.name.decodedName.toString)
Expand Down Expand Up @@ -369,4 +371,4 @@ class DeriveObjectTypeMacro(context: blackbox.Context) extends {
case class MacroAddFields(fields: List[Tree]) extends MacroDeriveObjectSetting
case class MacroReplaceField(fieldName: String, field: Tree, pos: Position) extends MacroDeriveObjectSetting
case class MacroTransformFieldNames(transformer: Tree) extends MacroDeriveObjectSetting
}
}

0 comments on commit c6c5c77

Please sign in to comment.