File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -47,12 +47,9 @@ trait TypeTestsCasts {
47
47
def argCls = argType.classSymbol
48
48
if (expr.tpe <:< argType)
49
49
Literal (Constant (true )) withPos tree.pos
50
- else if (qualCls.isPrimitiveValueClass) {
51
- if (argCls.isPrimitiveValueClass) Literal (Constant (qualCls == argCls))
52
- else errorTree(tree, " isInstanceOf cannot test if value types are references" )
53
- }
54
50
else if (argCls.isPrimitiveValueClass)
55
- transformIsInstanceOf(expr, defn.boxedClass(argCls).typeRef)
51
+ if (qualCls.isPrimitiveValueClass) Literal (Constant (qualCls == argCls))
52
+ else transformIsInstanceOf(expr, defn.boxedClass(argCls).typeRef)
56
53
else argType.dealias match {
57
54
case _ : SingletonType =>
58
55
val cmpOp = if (argType derivesFrom defn.AnyValClass ) defn.Any_equals else defn.Object_eq
Original file line number Diff line number Diff line change @@ -814,6 +814,22 @@ class RefChecks extends MiniPhase with SymTransformer { thisTransformer =>
814
814
currentLevel.enterReference(tree.tpe.typeSymbol, tree.pos)
815
815
tree
816
816
}
817
+
818
+ override def transformTypeApply (tree : tpd.TypeApply )(implicit ctx : Context , info : TransformerInfo ): tpd.Tree = {
819
+ tree.fun match {
820
+ case fun@ Select (qual, selector) =>
821
+ val sym = tree.symbol
822
+
823
+ if (sym == defn.Any_isInstanceOf ) {
824
+ val argType = tree.args.head.tpe
825
+ val qualCls = qual.tpe.widen.classSymbol
826
+ val argCls = argType.classSymbol
827
+ if (qualCls.isPrimitiveValueClass && ! argCls.isPrimitiveValueClass) ctx.error(" isInstanceOf cannot test if value types are references" , tree.pos)
828
+ }
829
+ case _ =>
830
+ }
831
+ tree
832
+ }
817
833
}
818
834
}
819
835
You can’t perform that action at this time.
0 commit comments