File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
compiler/src/dotty/tools/dotc/transform
tests/neg-custom-args/isInstanceOf Expand file tree Collapse file tree 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 {
2828 }
2929
3030 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 =>
3433 ensureCheckable(fn.qualifier, tree.args.head)
3534 case _ => tree
3635 }
@@ -66,11 +65,12 @@ object Checkable {
6665 */
6766 def checkable (X : Type , P : Type , pos : Position )(implicit ctx : Context ): Boolean = {
6867 def isAbstract (P : Type ) = ! P .dealias.typeSymbol.isClass
68+ def isPatternTypeSymbol (sym : Symbol ) = ! sym.isClass && sym.is(Case )
6969
7070 def replaceP (implicit ctx : Context ) = new TypeMap {
7171 def apply (tp : Type ) = tp match {
7272 case tref : TypeRef
73- if ! tref.typeSymbol.isClass && tref.symbol.is( Case ) => WildcardType
73+ if isPatternTypeSymbol( tref.typeSymbol) => WildcardType
7474 case AnnotatedType (_, annot)
7575 if annot.symbol == defn.UncheckedAnnot => WildcardType
7676 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