Skip to content

Commit 0aaa769

Browse files
authored
Merge pull request #8286 from soronpo/fix_ops
Fixes #8280
2 parents df323e7 + e44e8f0 commit 0aaa769

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3780,22 +3780,22 @@ object Types {
37803780

37813781
def tryCompiletimeConstantFold(implicit ctx: Context): Type = tycon match {
37823782
case tycon: TypeRef if defn.isCompiletimeAppliedType(tycon.symbol) =>
3783-
def constValue(tp: Type): Option[Any] = tp match {
3783+
def constValue(tp: Type): Option[Any] = tp.dealias match {
37843784
case ConstantType(Constant(n)) => Some(n)
37853785
case _ => None
37863786
}
37873787

3788-
def boolValue(tp: Type): Option[Boolean] = tp match {
3788+
def boolValue(tp: Type): Option[Boolean] = tp.dealias match {
37893789
case ConstantType(Constant(n: Boolean)) => Some(n)
37903790
case _ => None
37913791
}
37923792

3793-
def intValue(tp: Type): Option[Int] = tp match {
3793+
def intValue(tp: Type): Option[Int] = tp.dealias match {
37943794
case ConstantType(Constant(n: Int)) => Some(n)
37953795
case _ => None
37963796
}
37973797

3798-
def stringValue(tp: Type): Option[String] = tp match {
3798+
def stringValue(tp: Type): Option[String] = tp.dealias match {
37993799
case ConstantType(Constant(n: String)) => Some(n)
38003800
case _ => None
38013801
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import scala.compiletime.ops.int._
2+
import scala.compiletime.S
3+
4+
class Foo[T <: Int] {
5+
def incP = new Foo[T + 1]
6+
def incS = new Foo[S[T]]
7+
}
8+
object Foo {
9+
def apply[T <: Int & Singleton](value : T) : Foo[T] = new Foo[T]
10+
}
11+
12+
val fincS : Foo[2] = Foo(1).incS
13+
val fincP1 : Foo[2] = Foo(1).incP
14+
val fincP2a = Foo(1).incP
15+
val fincP2b : Foo[2] = fincP2a
16+
val fincP3 : Foo[2] = (new Foo[1]).incP

0 commit comments

Comments
 (0)