Skip to content

Commit 1a358c0

Browse files
oderskynicolasstucki
authored andcommitted
Make SourceFile equals depend on file
Used to depend on file's path, but that does not work for VirtualFiles that might be different even though they have the same path.
1 parent 9542f38 commit 1a358c0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/src/dotty/tools/dotc/util/SourceFile.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ class SourceFile(val file: AbstractFile, computeContent: => Array[Char]) extends
5454
override def jfile: Optional[JFile] = Optional.ofNullable(file.file)
5555

5656
override def equals(that : Any): Boolean = that match {
57-
case that : SourceFile => file.path == that.file.path && start == that.start
57+
case that : SourceFile => file == that.file && start == that.start
5858
case _ => false
5959
}
60-
override def hashCode: Int = file.path.## + start.##
60+
override def hashCode: Int = file.hashCode * 41 + start.hashCode
6161

6262
def apply(idx: Int): Char = content().apply(idx)
6363

0 commit comments

Comments
 (0)