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 {
4747 def argCls = argType.classSymbol
4848 if (expr.tpe <:< argType)
4949 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- }
5450 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)
5653 else argType.dealias match {
5754 case _ : SingletonType =>
5855 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 =>
814814 currentLevel.enterReference(tree.tpe.typeSymbol, tree.pos)
815815 tree
816816 }
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+ }
817833 }
818834}
819835
You can’t perform that action at this time.
0 commit comments