Skip to content

Commit 26d6203

Browse files
committed
Fix #10116: Fix adaptConstant to that it survives Ycheck
1 parent 4411811 commit 26d6203

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3425,7 +3425,7 @@ class Typer extends Namer
34253425
// try converting a constant to the target type
34263426
val folded = ConstFold(tree, pt)
34273427
if (folded ne tree)
3428-
return adaptConstant(folded, folded.tpe.asInstanceOf[ConstantType])
3428+
return adaptConstant(tree, folded.tpe.asInstanceOf[ConstantType])
34293429

34303430
val captured = captureWildcards(wtp)
34313431
if (captured `ne` wtp)

tests/pos/i10116.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
object OverloadedWithLong {
2+
def overloaded(x: Long): Any =
3+
x
4+
5+
def overloaded(x: Any): Unit =
6+
???
7+
}
8+
9+
object Test {
10+
def main(args: Array[String]): Unit =
11+
import OverloadedWithLong._
12+
13+
val l: Any = 0 :: Nil
14+
val r = overloaded(l match {
15+
case x :: xs => 5
16+
})
17+
assert(r == 5L)
18+
}

0 commit comments

Comments
 (0)