File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,8 @@ object Types {
165
165
case _ : SingletonType | NoPrefix => true
166
166
case tp : RefinedOrRecType => tp.parent.isStable
167
167
case tp : ExprType => tp.resultType.isStable
168
+ case AppliedType (tycon : TypeRef , args : List [Type ])
169
+ if defn.isCompiletimeAppliedType(tycon.symbol) && args.forall(_.isStable) => true
168
170
case tp : AnnotatedType =>
169
171
// NOTE UncheckedStableAnnot was originally meant to be put on fields,
170
172
// not on types. Allowing it on types is a Scala 3 extension. See:
@@ -4242,7 +4244,7 @@ object Types {
4242
4244
// final val one = 1
4243
4245
// type Two = one.type + one.type
4244
4246
// ```
4245
- case tp : TermRef => tp.underlying
4247
+ case tp : TypeProxy if tp.underlying.isStable => tp.underlying.fixForEvaluation
4246
4248
case tp => tp
4247
4249
}
4248
4250
Original file line number Diff line number Diff line change @@ -116,4 +116,24 @@ object Test {
116
116
117
117
val t83 : ToDouble [1 ] = 1.0
118
118
val t84 : ToDouble [2 ] = 2 // error
119
+
120
+ // Singletons are dereferenced
121
+ val t85 : Int = 5
122
+ val t86 : t85.type = t85
123
+ summon[t85.type + t85.type =:= t86.type + t86.type ]
124
+
125
+ // Singletons are dereferenced recursively
126
+ val t87 : t86.type = t87
127
+ summon[t85.type + t85.type =:= t87.type + t87.type ]
128
+
129
+ // Skolems of compile-time types are dereferenced:
130
+ // (?1 : (Test.x : Int) * (Test.x : Int)) --> (Test.x : Int) * (Test.x : Int)
131
+ def mult (x : Int , y : Int ): x.type * y.type = (x * y).asInstanceOf
132
+ val t88 : t85.type * t85.type * t85.type = mult(mult(t85, t85), t85)
133
+
134
+ // Compile-time operations with singleton arguments are singletons
135
+ summon[t85.type + t86.type <:< Singleton ]
136
+
137
+ // Compile-time operations with non-singleton arguments are not singletons
138
+ summon[t85.type + Int <:< Singleton ] // error
119
139
}
You can’t perform that action at this time.
0 commit comments