You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bug report focuses (mostly) on different problems with simplification of intersection types. I wanted to report one bug, but I just got too many errors by fiddling with the same code; my apologies. I still believe this bug report to be useful.
I see an error message (about an actual error) mentioning Coll with Traversable[T] with Traversable[T] instead of Coll with Traversable[T]. Additionally, given that Coll is bound in a constraint Coll <: Traversable[T], this should simplify further to Coll, even though this type appears in an invariant context. If this were the case, the problems below would not show up.
The following is supposed to give an idea of what's happening, but it is not (yet) fully reduced.
traitExp[+T] //Expression type, somewhat à la Lightweight Modular Staging but simpler.sealedtraitForceable[T, Coll] {...} //type-classdefbenchQuery[T, Coll<:Traversable[T]](msg: String,
v: Exp[Coll],
expectedResult: Traversable[T],
extraOptims: Seq[(String, Exp[Nothing] =>Exp[Nothing])], timeScala: Double)(implicitf: Forceable[T, Coll]):Traversable[T]
classUnconvertedExp[+T](valv:T)
//Removing the constraints causes type inference problems:implicitdeftoQuery[T, Repr<:Traversable[T]](t: Exp[ReprwithTraversable[T]]):UnconvertedExp[Exp[ReprwithTraversable[T]]] =newUnconvertedExp(t)
//Ensure that the parameter was not implicitly converted to Exp.defQuery[T, Repr<:Traversable[T]](t: UnconvertedExp[Exp[ReprwithTraversable[T]]]):Exp[ReprwithTraversable[T]] = t.v
//Code triggering the error:defbenchQueryComplete[T, Coll<:Traversable[T]](msg: String)
(expected: =>Traversable[T])
(query: =>Exp[Coll],
extraOptims: Seq[(String, Exp[Nothing] =>Exp[Nothing])] =Seq.empty) {
valbuiltQuery=Query(query)
benchQuery("", builtQuery, expectedRes, extraOptims, timeScala) //error line
Error:
could not find implicit value for parameter f: ivm.expressiontree.Lifting.Forceable[T,CollwithTraversable[T] withTraversable[T]]
Not having time to fully reduce this code, I tried annotating builtQuery to show the result of type inference, producing this code:
Here the compiler is deducing apparently Repr = Nothing in the call to toQuery, which is completely unexpected since toQuery's declaration uses the somewhat-well-known workaround to SI-5298. The only difference I see and that should matter (if bugs make some sense) is that query is a call-by-name parameter: query: => Exp[Coll].
The text was updated successfully, but these errors were encountered:
IIUC, Scala2 intersections won't be simplified, that will be left to Scala3 intersections, so this can be closed.
The workaround also becomes unnecessary once #5298 is fixed (which it hopefully is in Dotty).
This bug report focuses (mostly) on different problems with simplification of intersection types. I wanted to report one bug, but I just got too many errors by fiddling with the same code; my apologies. I still believe this bug report to be useful.
I see an error message (about an actual error) mentioning
Coll with Traversable[T] with Traversable[T]
instead ofColl with Traversable[T]
. Additionally, given thatColl
is bound in a constraintColl <: Traversable[T]
, this should simplify further toColl
, even though this type appears in an invariant context. If this were the case, the problems below would not show up.The following is supposed to give an idea of what's happening, but it is not (yet) fully reduced.
Error:
Not having time to fully reduce this code, I tried annotating
builtQuery
to show the result of type inference, producing this code:But then I got an even worse error:
That's worse because it can be fixed by inserting an implicit conversion:
However, I do need that type annotation on the implicit conversion. Otherwise, using just
toQuery(query)
, I get:Here the compiler is deducing apparently
Repr = Nothing
in the call totoQuery
, which is completely unexpected sincetoQuery
's declaration uses the somewhat-well-known workaround to SI-5298. The only difference I see and that should matter (if bugs make some sense) is thatquery
is a call-by-name parameter:query: => Exp[Coll]
.The text was updated successfully, but these errors were encountered: