File tree 1 file changed +4
-3
lines changed
compiler/src/dotty/tools/dotc/transform
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -209,16 +209,17 @@ object TypeTestsCasts {
209
209
* can be true in some cases. Issues a warning or an error otherwise.
210
210
*/
211
211
def checkSensical (foundClasses : List [Symbol ])(using Context ): Boolean =
212
+ def exprType = i " type ${expr.tpe.widen.stripAnnots}"
212
213
def check (foundCls : Symbol ): Boolean =
213
214
if (! isCheckable(foundCls)) true
214
215
else if (! foundCls.derivesFrom(testCls)) {
215
216
val unrelated = ! testCls.derivesFrom(foundCls) && (
216
217
testCls.is(Final ) || ! testCls.is(Trait ) && ! foundCls.is(Trait )
217
218
)
218
219
if (foundCls.is(Final ))
219
- unreachable(i " type ${expr.tpe.widen} is not a subclass of $testCls" )
220
+ unreachable(i " $exprType is not a subclass of $testCls" )
220
221
else if (unrelated)
221
- unreachable(i " type ${expr.tpe.widen} and $testCls are unrelated " )
222
+ unreachable(i " $exprType and $testCls are unrelated " )
222
223
else true
223
224
}
224
225
else true
@@ -227,7 +228,7 @@ object TypeTestsCasts {
227
228
val foundEffectiveClass = effectiveClass(expr.tpe.widen)
228
229
229
230
if foundEffectiveClass.isPrimitiveValueClass && ! testCls.isPrimitiveValueClass then
230
- ctx.error(" cannot test if value types are references " , tree.sourcePos)
231
+ ctx.error(i " cannot test if value of $exprType is a reference of $testCls " , tree.sourcePos)
231
232
false
232
233
else foundClasses.exists(check)
233
234
end checkSensical
You can’t perform that action at this time.
0 commit comments