-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Exports generate broken code depending on location (scope) of said code #20079
Comments
Addendum: we have went a bit on a merry chase with this one with @prolativ (thx buddy!). The only place that seems to be a possible source of the implicit final class OutputTraverseOps[A, CC[X] <: Iterable[X]](coll: CC[A]):
def traverse[B, To](f: A => Output[B])(using BuildFrom[CC[Output[B]], B, To], Context): Output[To] =
coll.map(f).asInstanceOf[CC[Output[B]]].sequence with constraint of |
A better minimization: https://github.com/prolativ/besom-issue-430/tree/prolativ-simplified |
Metals are not to blame for anything here: |
In general the crash in runtime seems to be caused by the compiler picking up the wrong instance of |
A minimization as a (currently failing) Vuilpix-style
object Foo:
def xyz[A, CC[X] <: Iterable[X]](coll: CC[A]): Unit = ()
object Bar:
export Foo.xyz
object Test:
val ints = List(1)
Foo.xyz[Int, List](ints)
Foo.xyz[Int, scala.collection.View](ints) // error
Bar.xyz[Int, List](ints)
Bar.xyz[Int, scala.collection.View](ints) // error The first error is not reported, although it should. However it is reported if we rename |
How I fixed it: This was quite hard to diagnose, despite the great minimization. At some point, given a type parameter /** Dealias type if it can be done without forcing the TypeRef's info */
def safeDealias(using Context): Type = self match {
case self: TypeRef
if self.denot.exists && self.symbol.isAliasType && !self.symbol.isProvisional =>
self.superType.stripTypeVar.safeDealias
case _ =>
self
} It turned out that the So why did anything work before if we got the logic wrong in such a basic part? It's because in The following actions were taken to avoid a problem like this in the future:
|
Symbols that had the TypeParam flag set were classified as alias types unless they also had the Deferred flag set. Maybe this did not break that much since Namer always added the Deferred for type parameters. But export forwarders use synthesized parameters which did not have Deferred set. Fixes #20079
This is related to VirtusLab/besom#430.
This issue is really mind-bending: in repro in Besom repo I have this working fine if object exporting these implicit methods is in test scope but failing steadily if it's in main scope. Running
scala-cli test .
in this repro shows the same behavior:in main
crashes whilein test
andlocal
both work. If you do however run tests from metalsin main
andin test
tests fail butlocal
works!Compiler version
3.3.1
Minimized code
https://github.com/lbialy/besom-issue-430
Output
Run
scala-cli test .
in the main folder of this repo and you will get:Expectation
I would expect that
Array("a", "b").toList.traverse(str => ...)
would inferCC
type param intraverse
asList
and notView
:toList
infersList[File]
:but then
traverse
infersOutput[View[X]]
:The text was updated successfully, but these errors were encountered: