Skip to content

Commit d68120a

Browse files
committed
[Dotty bug] Erasure/adaptation bug that causes boxing to the applied to the result of a label def invocation.
1 parent a20b802 commit d68120a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/scala/inox/solvers/theories/ASCIIStringEncoder.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ trait ASCIIStringEncoder extends SimpleEncoder {
4343
protected object encoder extends SelfTreeTransformer {
4444
override def transform(e: Expr): Expr = e match {
4545
case StringLiteral(v) =>
46-
stringCons(StringLiteral(v.flatMap(c => c.toString.getBytes.toSeq match {
47-
case Seq(b) if 32 <= b && b <= 127 => b.toChar.toString + b.toChar.toString
48-
case Seq(b) => encodeByte(b) + encodeByte(b)
49-
case Seq(b1, b2) => encodeByte(b1) + encodeByte(b2)
50-
})))
46+
// NOTE(gsps): [Bug] Workaround for erasure/adaptation bug in Dotty
47+
def decode(c: Char): String =
48+
c.toString.getBytes.toSeq match {
49+
case Seq(b) if 32 <= b && b <= 127 => b.toChar.toString + b.toChar.toString
50+
case Seq(b) => encodeByte(b) + encodeByte(b)
51+
case Seq(b1, b2) => encodeByte(b1) + encodeByte(b2)
52+
}
53+
stringCons(StringLiteral(v.flatMap(decode)))
5154
case StringLength(a) => Division(StringLength(transform(a).getField(value)), TWO)
5255
case StringConcat(a, b) => stringCons(StringConcat(transform(a).getField(value), transform(b).getField(value)))
5356
case SubString(a, start, end) => stringCons(SubString(transform(a).getField(value), transform(start) * TWO, transform(end) * TWO))

0 commit comments

Comments
 (0)