Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down