Skip to content

Commit

Permalink
In type assigner for Apply, carry ErrorType's from the fn.
Browse files Browse the repository at this point in the history
This was already done for `TypeApply` in
cecfb61. We apply the same logic
for `Apply` nodes.
  • Loading branch information
sjrd authored and nicolasstucki committed Dec 7, 2023
1 parent 79b4f37 commit 5fdbba4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ trait TypeAssigner {
else fntpe.resultType // fast path optimization
else
errorType(em"wrong number of arguments at ${ctx.phase.prev} for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.srcPos)
case err: ErrorType =>
err
case t =>
if (ctx.settings.Ydebug.value) new FatalError("").printStackTrace()
errorType(err.takesNoParamsMsg(fn, ""), tree.srcPos)
Expand Down Expand Up @@ -563,5 +565,3 @@ object TypeAssigner extends TypeAssigner:
def seqLitType(tree: untpd.SeqLiteral, elemType: Type)(using Context) = tree match
case tree: untpd.JavaSeqLiteral => defn.ArrayOf(elemType)
case _ => if ctx.erasedTypes then defn.SeqType else defn.SeqType.appliedTo(elemType)


22 changes: 22 additions & 0 deletions tests/pos/constvalue-of-failed-match-type.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import scala.compiletime.*

object Inlines:
inline def testInline[A](): Boolean =
inline erasedValue[A] match
case _: Tuple =>
constValue[Tuple.Size[A & Tuple]] == 2
case _ =>
false
end Inlines

case class Foo2(x: Boolean, y: String)
case class Foo3(x: Boolean, y: String, z: Int)

object Test:
def main(args: Array[String]): Unit =
// Note: the assert's don't do anything since it's a pos test; they show intent (and pass if we run the test)
assert(!Inlines.testInline[Foo2]())
assert(!Inlines.testInline[Foo3]())
assert(Inlines.testInline[(Boolean, String)]())
assert(!Inlines.testInline[(Boolean, String, Int)]())
end Test

0 comments on commit 5fdbba4

Please sign in to comment.