File tree 2 files changed +21
-0
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ object Types {
175
175
// see: tests/explicit-nulls/pos/flow-stable.scala.disabled
176
176
tp.tp1.isStable && (realizability(tp.tp2) eq Realizable ) ||
177
177
tp.tp2.isStable && (realizability(tp.tp1) eq Realizable )
178
+ case AppliedType (tycon : TypeRef , args) if defn.isCompiletimeAppliedType(tycon.symbol) && args.forall(_.isStable) => true
178
179
case _ => false
179
180
}
180
181
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