File tree Expand file tree Collapse file tree 2 files changed +5
-19
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +5
-19
lines changed Original file line number Diff line number Diff line change @@ -60,10 +60,8 @@ trait TypeTestsCasts {
6060 // if `test` is primitive but `found` is not, we might have a case like
6161 // found = java.lang.Integer, test = Int, which could be true
6262 // (not sure why that is so, but scalac behaves the same way)
63- ! isDerivedValueClass(foundCls) && ! isDerivedValueClass(testCls) &&
63+ ! isDerivedValueClass(foundCls) && ! isDerivedValueClass(testCls)
6464 // we don't have the logic to handle derived value classes
65- foundCls != defn.ObjectClass
66- // if `foundCls == Object`, it could have been `Any` before erasure.
6765
6866 /** Check whether a runtime test that a value of `foundCls` can be a `testCls`
6967 * can be true in some cases. Issure a warning or an error if that's not the case.
@@ -81,6 +79,10 @@ trait TypeTestsCasts {
8179 unreachable(i " $foundCls and $testCls are unrelated " )
8280 false
8381 }
82+ else if (foundCls.isPrimitiveValueClass && ! testCls.isPrimitiveValueClass) {
83+ ctx.error(" cannot test if value types are references" , tree.pos)
84+ false
85+ }
8486 else true
8587 }
8688 else true
Original file line number Diff line number Diff line change @@ -872,22 +872,6 @@ class RefChecks extends MiniPhase { thisTransformer =>
872872 currentLevel.enterReference(tree.tpe.typeSymbol, tree.pos)
873873 tree
874874 }
875-
876- override def transformTypeApply (tree : tpd.TypeApply )(implicit ctx : Context , info : TransformerInfo ): tpd.Tree = {
877- tree.fun match {
878- case fun@ Select (qual, selector) =>
879- val sym = tree.symbol
880-
881- if (sym == defn.Any_isInstanceOf ) {
882- val argType = tree.args.head.tpe
883- val qualCls = qual.tpe.widen.classSymbol
884- val argCls = argType.classSymbol
885- if (qualCls.isPrimitiveValueClass && ! argCls.isPrimitiveValueClass) ctx.error(" isInstanceOf cannot test if value types are references" , tree.pos)
886- }
887- case _ =>
888- }
889- tree
890- }
891875 }
892876}
893877
You can’t perform that action at this time.
0 commit comments