Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
liufengyun committed Mar 23, 2018
1 parent e942a16 commit 2d5f2d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ class IsInstanceOfChecker extends MiniPhase {
}

tree.fun match {
case fn: Select if fn.symbol == defn.Any_typeTest =>
ensureCheckable(fn.qualifier, tree.args.head)
case fn: Select if fn.symbol == defn.Any_isInstanceOf =>
case fn: Select
if fn.symbol == defn.Any_typeTest || fn.symbol == defn.Any_isInstanceOf =>
ensureCheckable(fn.qualifier, tree.args.head)
case _ => tree
}
Expand Down Expand Up @@ -66,11 +65,12 @@ object Checkable {
*/
def checkable(X: Type, P: Type, pos: Position)(implicit ctx: Context): Boolean = {
def isAbstract(P: Type) = !P.dealias.typeSymbol.isClass
def isPatternTypeSymbol(sym: Symbol) = !sym.isClass && sym.is(Case)

def replaceP(implicit ctx: Context) = new TypeMap {
def apply(tp: Type) = tp match {
case tref: TypeRef
if !tref.typeSymbol.isClass && tref.symbol.is(Case) => WildcardType
if isPatternTypeSymbol(tref.typeSymbol) => WildcardType
case AnnotatedType(_, annot)
if annot.symbol == defn.UncheckedAnnot => WildcardType
case _ => mapOver(tp)
Expand Down
10 changes: 10 additions & 0 deletions tests/neg-custom-args/isInstanceOf/3324h.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object Test {
trait Marker
def foo[T](x: T) = x match {
case _: (T & Marker) => // no warning
// case _: T with Marker => // scalac emits a warning
case _ =>
}

def bar(x: Any) = x.isInstanceOf[List[String]] // error
}

0 comments on commit 2d5f2d4

Please sign in to comment.