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 {
60
60
// if `test` is primitive but `found` is not, we might have a case like
61
61
// found = java.lang.Integer, test = Int, which could be true
62
62
// (not sure why that is so, but scalac behaves the same way)
63
- ! isDerivedValueClass(foundCls) && ! isDerivedValueClass(testCls) &&
63
+ ! isDerivedValueClass(foundCls) && ! isDerivedValueClass(testCls)
64
64
// 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.
67
65
68
66
/** Check whether a runtime test that a value of `foundCls` can be a `testCls`
69
67
* can be true in some cases. Issure a warning or an error if that's not the case.
@@ -81,6 +79,10 @@ trait TypeTestsCasts {
81
79
unreachable(i " $foundCls and $testCls are unrelated " )
82
80
false
83
81
}
82
+ else if (foundCls.isPrimitiveValueClass && ! testCls.isPrimitiveValueClass) {
83
+ ctx.error(" cannot test if value types are references" , tree.pos)
84
+ false
85
+ }
84
86
else true
85
87
}
86
88
else true
Original file line number Diff line number Diff line change @@ -872,22 +872,6 @@ class RefChecks extends MiniPhase { thisTransformer =>
872
872
currentLevel.enterReference(tree.tpe.typeSymbol, tree.pos)
873
873
tree
874
874
}
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
- }
891
875
}
892
876
}
893
877
You can’t perform that action at this time.
0 commit comments