File tree 2 files changed +20
-4
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -3780,22 +3780,22 @@ object Types {
3780
3780
3781
3781
def tryCompiletimeConstantFold (implicit ctx : Context ): Type = tycon match {
3782
3782
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 {
3784
3784
case ConstantType (Constant (n)) => Some (n)
3785
3785
case _ => None
3786
3786
}
3787
3787
3788
- def boolValue (tp : Type ): Option [Boolean ] = tp match {
3788
+ def boolValue (tp : Type ): Option [Boolean ] = tp.dealias match {
3789
3789
case ConstantType (Constant (n : Boolean )) => Some (n)
3790
3790
case _ => None
3791
3791
}
3792
3792
3793
- def intValue (tp : Type ): Option [Int ] = tp match {
3793
+ def intValue (tp : Type ): Option [Int ] = tp.dealias match {
3794
3794
case ConstantType (Constant (n : Int )) => Some (n)
3795
3795
case _ => None
3796
3796
}
3797
3797
3798
- def stringValue (tp : Type ): Option [String ] = tp match {
3798
+ def stringValue (tp : Type ): Option [String ] = tp.dealias match {
3799
3799
case ConstantType (Constant (n : String )) => Some (n)
3800
3800
case _ => None
3801
3801
}
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments