Skip to content

Commit efb3199

Browse files
restore NoSpecialType error
Reviewed By: VLanvin, thepulkitagarwal Differential Revision: D60451900 fbshipit-source-id: 006b381094ce4f554263d7c390fd371e668aa1a8
1 parent 134fbf4 commit efb3199

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.whatsapp.eqwalizer.ast.Exprs.Expr
1010
import com.whatsapp.eqwalizer.ast.Forms.OverloadedFunSpec
1111
import com.whatsapp.eqwalizer.ast.RemoteId
1212
import com.whatsapp.eqwalizer.ast.Types.{DynamicType, FunType, NoneType, Type}
13+
import com.whatsapp.eqwalizer.tc.TcDiagnostics.NoSpecialType
1314

1415
class ElabApplyOverloaded(pipelineContext: PipelineContext) {
1516
private lazy val check = pipelineCtx.check
@@ -18,6 +19,7 @@ class ElabApplyOverloaded(pipelineContext: PipelineContext) {
1819
private lazy val subtype = pipelineContext.subtype
1920
private val elabApply = pipelineContext.elabApply
2021
private val narrow = pipelineContext.narrow
22+
private lazy val diagnosticsInfo = pipelineContext.diagnosticsInfo
2123
private implicit val pipelineCtx: PipelineContext = pipelineContext
2224

2325
def elabOverloaded(expr: Expr, remoteId: RemoteId, args: List[Expr], env: Env): (Type, Env) = {
@@ -28,6 +30,8 @@ class ElabApplyOverloaded(pipelineContext: PipelineContext) {
2830
val resTy = elabApply.elabApply(check.freshen(ft), args, argTys, env1)
2931
(resTy, env1)
3032
case _ =>
33+
if (pipelineCtx.overloadedSpecDynamicResult)
34+
diagnosticsInfo.add(NoSpecialType(expr.pos, expr, argTys))
3135
(DynamicType, env1)
3236
}
3337
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ object TcDiagnostics {
3737
def errorName = "expected_fun_type"
3838
override def erroneousExpr: Option[Expr] = Some(expr)
3939
}
40+
case class NoSpecialType(pos: Pos, expr: Expr, argTys: List[Type])(implicit val pipelineContext: PipelineContext)
41+
extends TypeError {
42+
private val argTysString = argTys.map(show).mkString(", ")
43+
override val msg: String = s"Not enough info to branch. Arg types: $argTysString"
44+
def errorName = "not_enough_info_to_branch"
45+
override def erroneousExpr: Option[Expr] = Some(expr)
46+
}
4047
case class LambdaArityMismatch(pos: Pos, expr: Expr, lambdaArity: Int, argsArity: Int) extends TypeError {
4148
override val msg: String = s"fun with arity $lambdaArity used as fun with $argsArity arguments"
4249
def errorName = "fun_arity_mismatch"

0 commit comments

Comments
 (0)