Skip to content

Commit

Permalink
Output intended type name for interactions in compiler plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
robflop committed Aug 14, 2024
1 parent 6d55d35 commit d24407b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,15 @@ class LoRePhase extends PluginPhase:
case TypeRef(_, _) => // Non-parameterized types (e.g. Int, String)
SimpleType(typeTree.asInstanceOf[CachedTypeRef].name.toString, List())
case AppliedType(outerType: CachedTypeRef, args: List[?]) => // Parameterized types like List, Map, etc
// For some reason, probably due to the type definitions in UnboundInteraction, Interactions with requires show
// up as type "T" and those with executes as type "E", so manually do some digging here to get the proper name
// Also keep UnboundInteraction consistent as "Interaction", just so it's not as much of a mess with the above
val typeString = if outerType.name.toString == "UnboundInteraction" then "Interaction"
else if outerType.prefix.typeConstructor.show.contains("Interaction") then "Interaction"
else outerType.name.toString

SimpleType(
outerType.name.toString,
typeString,
args.map {
case tp @ TypeRef(_, _) => SimpleType(tp.asInstanceOf[CachedTypeRef].name.toString, List())
case tp @ AppliedType(_, _) => buildLoreTypeNode(tp, sourcePos)
Expand Down

0 comments on commit d24407b

Please sign in to comment.