Skip to content

Commit f6290ef

Browse files
optimization
Summary: - if a type alias doesn't have parameters, there is no need to copy-paste its body (`Subst.subst` with an empty substitution will traverse and copy the structure) Reviewed By: robertoaloi Differential Revision: D60760134 fbshipit-source-id: 6ee5cf7a304445ace324c35cfb0dc50386552e00
1 parent 9b8a196 commit f6290ef

File tree

1 file changed

+7
-4
lines changed
  • eqwalizer/src/main/scala/com/whatsapp/eqwalizer/tc

1 file changed

+7
-4
lines changed

eqwalizer/src/main/scala/com/whatsapp/eqwalizer/tc/Util.scala

+7-4
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,13 @@ class Util(pipelineContext: PipelineContext) {
9292
case _ =>
9393
}
9494
val id = Id(remoteId.name, remoteId.arity)
95-
def applyType(decl: TypeDecl): Type = {
96-
val subst = decl.params.zip(args).map { case (VarType(n), ty) => n -> ty }.toMap
97-
Subst.subst(subst, decl.body)
98-
}
95+
def applyType(decl: TypeDecl): Type =
96+
if (id.arity == 0)
97+
decl.body
98+
else {
99+
val subst = decl.params.zip(args).map { case (VarType(n), ty) => n -> ty }.toMap
100+
Subst.subst(subst, decl.body)
101+
}
99102

100103
DbApi
101104
.getType(remoteId.module, id)

0 commit comments

Comments
 (0)