diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 0709d9b59238..3c77ef1e9066 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -125,7 +125,9 @@ object Types { def isRef(sym: Symbol)(implicit ctx: Context): Boolean = stripAnnots.stripTypeVar match { case this1: TypeRef => this1.info match { // see comment in Namer#typeDefSig - case TypeAlias(tp) => tp.isRef(sym) + case TypeAlias(tp) => + assert((tp ne this) && (tp ne this1), s"$tp / $this") + tp.isRef(sym) case _ => this1.symbol eq sym } case this1: RefinedOrRecType => this1.parent.isRef(sym) diff --git a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala index c19bc0556f8a..6841e90b2602 100644 --- a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala +++ b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala @@ -44,8 +44,13 @@ class InteractiveDriver(settings: List[String]) extends Driver { def currentCtx: Context = myCtx - private val myOpenedFiles = new mutable.LinkedHashMap[URI, SourceFile] - private val myOpenedTrees = new mutable.LinkedHashMap[URI, List[SourceTree]] + private val myOpenedFiles = new mutable.LinkedHashMap[URI, SourceFile] { + override def default(key: URI) = NoSource + } + + private val myOpenedTrees = new mutable.LinkedHashMap[URI, List[SourceTree]] { + override def default(key: URI) = Nil + } def openedFiles: Map[URI, SourceFile] = myOpenedFiles def openedTrees: Map[URI, List[SourceTree]] = myOpenedTrees diff --git a/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala b/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala index dd89f9f9f3a1..2863c4e35d0b 100644 --- a/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala +++ b/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala @@ -351,9 +351,12 @@ object DottyLanguageServer { /** Convert an lsp4j.Position to a SourcePosition */ def sourcePosition(driver: InteractiveDriver, uri: URI, pos: lsp4j.Position): SourcePosition = { - val source = driver.openedFiles(uri) // might throw exception - val p = Positions.Position(source.lineToOffset(pos.getLine) + pos.getCharacter) - new SourcePosition(source, p) + val source = driver.openedFiles(uri) + if (source.exists) { + val p = Positions.Position(source.lineToOffset(pos.getLine) + pos.getCharacter) + new SourcePosition(source, p) + } + else NoSourcePosition } /** Convert a SourcePosition to an lsp4j.Range */