-
Notifications
You must be signed in to change notification settings - Fork 21
Regression in Scala 2.13.7 - cannot use wildcard for F-bounded type when using OptManifest #12481
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
Note that I can write in this case |
I'll take a look. Compare scalacenter/scalafix#1493 |
I guess it involves scala/scala#9776 and not wildcard representation. An extra check is introduced. |
attn @lrytz |
I'll let lrytz say if it is simply correct, which I guess it is. The manifest seeks to summon test at scala/scala#9802 |
Thank you @som-snytt - I think you're right
|
Though i'm not all that sure how wildcards are working / supposed to work.
|
Works in Scala 3, by the way. But their wildcards are generally better at ignoring stuff, as demonstrated in the possibly somewhat related #8039. |
Yes, I noticed that dotty is nicer with special wildcard name handling. I expected to need some name-based extraction somewhere. But per Lukas's comment, I tried to induce explicit failure, but it was something else leaking when summoning the manifest, which is not merely implicit but "internal" or "magical". Also, paulp's "rocket science" dig is motivational, I don't remember why it didn't come up on the underscore ticket. BTW both PRs landed about the same time, which is why I assumed the underscore ticket was causative. I didn't actually bisect. |
The main code path where val existentialParams = new ListBuffer[Symbol]
var skipBounds = false
// check all bounds, except those that are existential type parameters
// or those within typed annotated with @uncheckedBounds
if (!inPattern) tree.tpe foreach {
case tp @ ExistentialType(tparams, tpe) =>
existentialParams ++= tparams
case ann: AnnotatedType if ann.hasAnnotation(UncheckedBoundsClass) =>
// scala/bug#7694 Allow code synthesizers to disable checking of bounds for TypeTrees based on inferred LUBs
// which might not conform to the constraints.
skipBounds = true
case tp: TypeRef =>
val tpWithWildcards = deriveTypeWithWildcards(existentialParams.toList)(tp)
checkTypeRef(tpWithWildcards, tree, skipBounds)
case _ =>
}
if (skipBounds) {
tree.setType(tree.tpe.map {
_.filterAnnotations(_.symbol != UncheckedBoundsClass)
})
}
tree |
TIL that this doesn't complain 🤔 trait Foo[A <: Int]
class bar[A] extends StaticAnnotation
@bar[Foo[String]]
val x = 42 |
Also this: trait Foo[A <: Int]
trait Bar[A, B]
val x: Bar[Foo[String] @uncheckedBounds, Foo[String]] = null |
(leaving it on the 2.13.8 milestone, because no released version of 2.12 had the bug) |
reproduction steps
using Scala 2.13.6 (and all before), the following works ( https://scastie.scala-lang.org/NkHsooECRGqIgttwtvkgMg )
In Scala 2.13.7, the marked line produces an error
This is somehow caused by the
OptManifest
argument to theRef
constructor. If I remove that implicit argument, it compiles again.The text was updated successfully, but these errors were encountered: