-
Notifications
You must be signed in to change notification settings - Fork 1.1k
"Could not find TASTY file" error when tasty/class files already exist #11644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This issue appeared recently after #11308 was merged, but what looks to be the root cause is much older (since #3382): sbt:scala3> console
scala> import dotty.tools.io._
scala> Path("./foo.txt").parent
val res0: dotty.tools.io.Directory = ./foo.txt
scala> Path("foo.txt").parent
val res1: dotty.tools.io.Directory = foo.txt
scala> Path("/foo.txt").parent
val res2: dotty.tools.io.Directory = /
scala> Path("./bar/foo.txt").parent
val res3: dotty.tools.io.Directory = bar
scala> Path(".").parent
val res4: dotty.tools.io.Directory = . Compare Scala 2.13: sbt:root> console
[info] Starting scala interpreter...
Welcome to Scala 2.13.5 (OpenJDK 64-Bit Server VM, Java 1.8.0_282).
Type in expressions for evaluation. Or try :help.
scala> import scala.reflect.io._
import scala.reflect.io._
scala> Path("./foo.txt").parent
val res0: scala.reflect.io.Directory = .
scala> Path("foo.txt").parent
val res1: scala.reflect.io.Directory = .
scala> Path("/foo.txt").parent
val res2: scala.reflect.io.Directory = /
scala> Path("./bar/foo.txt").parent
val res3: scala.reflect.io.Directory = ./bar
scala> Path(".").parent
val res4: scala.reflect.io.Directory = .. The Scala 2.13 implementation is here: https://github.com/scala/scala/blob/262f6e9a6d217a8c95dd6e70235f0c615edd50e6/src/reflect/scala/reflect/io/Path.scala#L155-L171 |
@bishabosha @nicolasstucki maybe one of you could take a look? |
The previous implementation wrongly assumed that if `jpath.normalize.getParent` returns null, then `jpath` must be a root. However the null in this case really only means that no name elements remain after normalization and the call to `getParent`. Since redundant name elements such as "." and ".." may be removed by `normalize`, and `getParent` may simply remove the last name element, there are cases other than roots to consider, such as the current directory. Some examples of broken behavior prior this commit: scala> Path("./foo.txt").parent val res0: dotty.tools.io.Directory = ./foo.txt // should be Directory(.) scala> Path("foo.txt").parent val res1: dotty.tools.io.Directory = foo.txt // should be Directory(.) scala> Path(".").parent val res4: dotty.tools.io.Directory = . // should be Directory(..) The changes here are based in part on the Scala 2.13 implementation of scala.reflect.io.Path#parent Fixes scala#11644
The previous implementation wrongly assumed that if `jpath.normalize.getParent` returns null, then `jpath` must be a root. However the null in this case really only means that no name elements remain after normalization and the call to `getParent`. Since redundant name elements such as "." and ".." may be removed by `normalize`, and `getParent` may simply remove the last name element, there are cases other than roots to consider, such as the current directory. Some examples of broken behavior prior this commit: scala> Path("./foo.txt").parent val res0: dotty.tools.io.Directory = ./foo.txt // should be Directory(.) scala> Path("foo.txt").parent val res1: dotty.tools.io.Directory = foo.txt // should be Directory(.) scala> Path(".").parent val res4: dotty.tools.io.Directory = . // should be Directory(..) The changes here are based in part on the Scala 2.13 implementation of scala.reflect.io.Path#parent Fixes scala#11644
Fix #11644: Fix broken dotty.tools.io.Path#parent
The previous implementation wrongly assumed that if `jpath.normalize.getParent` returns null, then `jpath` must be a root. However the null in this case really only means that no name elements remain after normalization and the call to `getParent`. Since redundant name elements such as "." and ".." may be removed by `normalize`, and `getParent` may simply remove the last name element, there are cases other than roots to consider, such as the current directory. Some examples of broken behavior prior this commit: scala> Path("./foo.txt").parent val res0: dotty.tools.io.Directory = ./foo.txt // should be Directory(.) scala> Path("foo.txt").parent val res1: dotty.tools.io.Directory = foo.txt // should be Directory(.) scala> Path(".").parent val res4: dotty.tools.io.Directory = . // should be Directory(..) The changes here are based in part on the Scala 2.13 implementation of scala.reflect.io.Path#parent Fixes scala#11644
The previous implementation wrongly assumed that if `jpath.normalize.getParent` returns null, then `jpath` must be a root. However the null in this case really only means that no name elements remain after normalization and the call to `getParent`. Since redundant name elements such as "." and ".." may be removed by `normalize`, and `getParent` may simply remove the last name element, there are cases other than roots to consider, such as the current directory. Some examples of broken behavior prior this commit: scala> Path("./foo.txt").parent val res0: dotty.tools.io.Directory = ./foo.txt // should be Directory(.) scala> Path("foo.txt").parent val res1: dotty.tools.io.Directory = foo.txt // should be Directory(.) scala> Path(".").parent val res4: dotty.tools.io.Directory = . // should be Directory(..) The changes here are based in part on the Scala 2.13 implementation of scala.reflect.io.Path#parent Fixes scala#11644
Compiler version
3.0.0-RC1 and 3.0.0-RC2-bin-SNAPSHOT-git-086d1a8
(no issue with 3.0.0-M3)
Minimized code
Output
Expectation
No error
Notes
Seems to only be a problem when the class/tasty files are in the current directory.
The text was updated successfully, but these errors were encountered: