We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1725a67 commit 5cd0a9dCopy full SHA for 5cd0a9d
compiler/src/dotty/tools/dotc/core/Types.scala
@@ -3552,7 +3552,7 @@ object Types {
3552
if (defn.isCompiletime_S(tycon.symbol) && args.length == 1)
3553
trace(i"normalize S $this", typr, show = true) {
3554
args.head.normalized match {
3555
- case ConstantType(Constant(n: Int)) => ConstantType(Constant(n + 1))
+ case ConstantType(Constant(n: Int)) if n >= 0 => ConstantType(Constant(n + 1))
3556
case none => tryMatchAlias
3557
}
3558
tests/neg/i6606.scala
@@ -0,0 +1,5 @@
1
+val t0: Int = 0
2
+val t1: scala.compiletime.S[-1] = 0 // error
3
+val t2: scala.compiletime.S[Int] = 1
4
+val t3: scala.compiletime.S[Int] = 0 // error
5
+val t4: scala.compiletime.S[Int] = n // error
0 commit comments