scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.87k stars 1.06k forks source link

Existential Types error doesn't point to offending location in project #19672

Open rbscgh opened 8 months ago

rbscgh commented 8 months ago

Compiler version

3.3.1

Minimized example

The compiler is complaining about a usage of forSome however it is not found in either the project or its dependencies.

here are some cross compiled deps: Dep Version
specs2 4.20.5
specs2-mock 4.20.5
circe-core,generic,parser 0.14.6
monix 3.4.1

here is the offending trait but its not using forSome

Output Error/Warning message

[warn] Explanation
[warn] ===========
[warn] Existential types in their full generality are no longer supported.
[warn] Scala-3 does applications of class types to wildcard type arguments.
[warn] Other forms of existential types that come from Scala-2 classfiles
[warn] are only approximated in a best-effort way.
[warn] An existential type that came from a Scala-2 classfile for trait ClassesOf
[warn] cannot be mapped accurately to a Scala-3 equivalent.
[warn] original type    : Seq[Class[? >: _$1 & _$1² & _$1³]] forSome _$1; _$1²; _$1³
[warn] reduces to       : Seq[Class[? >: _$1 & _$1² & _$1³]]
[warn] type used instead: Seq[Class[? >: Any]]
[warn] This choice can cause follow-on type errors or hide type errors.
[warn] Proceed at own risk.
[warn] 
[warn] where:    _$1  is a type in method classesOf
[warn]           _$1² is a type in method classesOf
[warn]           _$1³ is a type in method classesOf
[warn] 
[warn]   |-----------------------------------------------------------------------------
[warn]   | Explanation (enabled by `-explain`)
[warn]   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[warn]   | Existential types in their full generality are no longer supported.
[warn]   | Scala-3 does applications of class types to wildcard type arguments.
[warn]   | Other forms of existential types that come from Scala-2 classfiles
[warn]   | are only approximated in a best-effort way.
[warn]    -----------------------------------------------------------------------------

Why this Error/Warning was not helpful

No where in the direct project or dependency do I see a usage of forSome. It would be nice to see where the compiler is finding that issue so we can resolve it.

Suggested improvement

It could be made more helpful by including the offending line in project or dependency.

smarter commented 8 months ago

I believe the forSome here comes from the result type inferred by Scala 2 for the classesOf method and should disappear if an explicit result type of Seq[Class[_]] is used. Things Scala 3 could do better here:

smarter commented 8 months ago

It could be made more helpful by including the offending line in project or dependency.

Agreed, but here again this might be tricky to reconstruct from the scala 2 pickled information.

rbscgh commented 5 months ago

@smarter because this is happening only when compiling tests.. do you know how i could suppress the error so i can maintain fatalWarnings for the rest of the code ?

rbscgh commented 5 months ago

https://github.com/scala/scala3/blob/7d559ad06bdfe448450341c7fdf12cc0513456f3/compiler/src/dotty/tools/dotc/reporting/messages.scala#L1924

here is the message in dotty, but how to find out the format for WConf-

rbscgh commented 5 months ago

Test / scalacOptions ++= Seq("-Wconf:id=98:i")

this worked ^^ :D