Skip to content

Commit 80b6594

Browse files
committed
avoid possible NPEs when extracting dependencies
in general, we are keeping the code here in sync with code that 1) we expect to end up in sbt eventually too 2) contains fixes that arose during testing of the incremental compiler on at least one of the same codebases we expect scala-sculpt to be used with the change to symbolsInType is borrowed from adriaanm/sbt#1, specifically from adriaanm/sbt@98e9cff the sbt test case that triggers it is https://github.com/sbt/sbt/tree/0.13/sbt/src/sbt-test/source-dependencies/macro-annotation but we cannot add a similar test case here unless we expanded our test scaffold a lot, since we'd need to add a dependency on macro paradise and run the compiler twice (once for the macro, once for rest of the test code) the change to flattenTypeToSymbols is borrowed from adriaanm/sbt@dc60968
1 parent 02cde8a commit 80b6594

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/scala/scala/tools/sculpt/plugin/ExtractDependencies.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ abstract class ExtractDependencies extends PluginComponent {
9595
}
9696

9797
// skip packages
98-
private def symbolsInType(tp: Type) = tp.collect{ case tp if !(tp.typeSymbol hasFlag PACKAGE) => tp.typeSymbolDirect }.toSet
99-
private def flattenTypeToSymbols(tp: Type): List[Symbol] = tp match {
98+
private def symbolsInType(tp: Type) = tp.collect{ case tp if tp != null && !(tp.typeSymbolDirect hasFlag PACKAGE) => tp.typeSymbolDirect }.toSet
99+
private def flattenTypeToSymbols(tp: Type): List[Symbol] = if (tp eq null) Nil else tp match {
100100
case ct: CompoundType => ct.typeSymbolDirect :: ct.parents.flatMap(flattenTypeToSymbols)
101101
case _ => List(tp.typeSymbolDirect)
102102
}

0 commit comments

Comments
 (0)