File tree 2 files changed +14
-4
lines changed
compiler/src/dotty/tools/dotc/transform
tests/neg-custom-args/isInstanceOf
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,8 @@ class IsInstanceOfChecker extends MiniPhase {
28
28
}
29
29
30
30
tree.fun match {
31
- case fn : Select if fn.symbol == defn.Any_typeTest =>
32
- ensureCheckable(fn.qualifier, tree.args.head)
33
- case fn : Select if fn.symbol == defn.Any_isInstanceOf =>
31
+ case fn : Select
32
+ if fn.symbol == defn.Any_typeTest || fn.symbol == defn.Any_isInstanceOf =>
34
33
ensureCheckable(fn.qualifier, tree.args.head)
35
34
case _ => tree
36
35
}
@@ -66,11 +65,12 @@ object Checkable {
66
65
*/
67
66
def checkable (X : Type , P : Type , pos : Position )(implicit ctx : Context ): Boolean = {
68
67
def isAbstract (P : Type ) = ! P .dealias.typeSymbol.isClass
68
+ def isPatternTypeSymbol (sym : Symbol ) = ! sym.isClass && sym.is(Case )
69
69
70
70
def replaceP (implicit ctx : Context ) = new TypeMap {
71
71
def apply (tp : Type ) = tp match {
72
72
case tref : TypeRef
73
- if ! tref.typeSymbol.isClass && tref.symbol.is( Case ) => WildcardType
73
+ if isPatternTypeSymbol( tref.typeSymbol) => WildcardType
74
74
case AnnotatedType (_, annot)
75
75
if annot.symbol == defn.UncheckedAnnot => WildcardType
76
76
case _ => mapOver(tp)
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ trait Marker
3
+ def foo [T ](x : T ) = x match {
4
+ case _ : (T & Marker ) => // no warning
5
+ // case _: T with Marker => // scalac emits a warning
6
+ case _ =>
7
+ }
8
+
9
+ def bar (x : Any ) = x.isInstanceOf [List [String ]] // error
10
+ }
You can’t perform that action at this time.
0 commit comments