Skip to content

Commit

Permalink
Merge branch 'hastypeunresolved'
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Aug 25, 2016
2 parents 083ee04 + af1ed70 commit 9767f87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/com/netflix/java/refactor/find/HasType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class HasTypeScanner(val op: HasType): SingleCompilationUnitAstScanner<Boolean>(
val invocation = node as JCTree.JCMethodInvocation
if(invocation.meth is JCTree.JCIdent) {
// statically imported type
return (invocation.meth as JCTree.JCIdent).sym.owner.toString() == op.clazz
return (invocation.meth as JCTree.JCIdent)?.sym?.owner?.toString() == op.clazz
}
return super.visitMethodInvocation(node, context)
}
Expand Down
13 changes: 7 additions & 6 deletions src/test/kotlin/com/netflix/java/refactor/find/HasTypeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import org.junit.Test
import java.util.*
import kotlin.test.assertTrue

class HasTypeTest: AbstractRefactorTest() {
class HasTypeTest : AbstractRefactorTest() {

@Test
fun hasType() {
val a = java("""
Expand All @@ -15,7 +15,7 @@ class HasTypeTest: AbstractRefactorTest() {
| List list;
|}
""")

assertTrue(parseJava(a).hasType(List::class.java))
}

Expand All @@ -30,23 +30,24 @@ class HasTypeTest: AbstractRefactorTest() {

assertTrue(parseJava(a).hasType(Collections::class.java))
}

@Test
fun unresolvableMethodSymbol() {
val a = java("""
public class B {
public static void baz() {
// the parse tree inside this anonymous class will be un-attributed because
// A is not a resolvable symbol
A a = new A() {
@Override public void foo() {
bar();
}
}
}
public static void bar() {}
}
""")

parseJava(a).hasType("Something")
parseJava(a).hasType("DoesNotMatter")
}
}

0 comments on commit 9767f87

Please sign in to comment.