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
typers&patmatvirtualizer have ad-hoc support for dropping annotations
in a way that makes the CPS plugins happy... this is not ideal,
but unless virtpatmat runs after the plugin phases, I don't see how to solve it
running virtpatmat after the CPS plugin would mean the pattern matching evaluation
cannot be captured by CPS, so it's not even desirable to move it to a later phase
- typedIf must lub annotated types
- drop selector.tpe's annotations
- drop annots in matchEnd's argument type
- deal with annots in casts synth by in virtpatmat
(drop them from type arg to asInstanceof, recover them using type ascription)
- workaround skolemize existential dropping annots
CPS is the main reason why typedMatchAnonFun is not used anymore,
and PartialFunction synthesis is moved back to uncurry (which is quite painful due to labeldefs being so broken)
we can't synth partialfunction during typer since T @cps[U] does not conform to Any,
so we can't pass it as a type arg to PartialFunction, so we can't type a cps-transformed PF
after the CPS plugin, T @cps[U] becomes ControlContext[...], which is a type we can pass
to PartialFunction
virtpatmat is now also run until right before uncurry
(so, can't use isPastTyper, although it means more or less the same thing -- we don't run after uncurry)
the main functional improvements are in the selective ANF transform
its treatment of labeldefs was broken: for example,
LabelDef L1; LabelDef L2 --> DefDef L1; L1(); DefDef L2; L2()
but this does not take into account L1 may jump over L2 to another label
since methods always return (or fail), and the ANF transform generates ValDefs
to store the result of those method calls, both L1 and L2 would always be executed
(so you would run a match with N cases N times, with each partial run starting at a later case)
also fixed a couple of weird bugs in selective anf that caused matches to be duplicated
(with the duplicate being nested in the original)
since label defs are turned into method defs, and later defs
will be nested in the flatMap calls on the controlcontext
yielded by earlier statements, we reverse the list of method
definitions, so that earlier (in the control flow sense) methods
are visible in later ones
selective CPS now generates a catch that's directly digestible by backend
// pt = Any* occurs when compiling test/files/pos/annotDepMethType.scala with -Xexperimental
@@ -1105,22 +1105,14 @@ class Foo(x: Other) { x._1 } // no error in this order
1105
1105
def_equals(checker: Tree, binder: Symbol):Tree= checker MEMBER_==REF(binder) // NOTE: checker must be the target of the ==, that's the patmat semantics for ya
1106
1106
defand(a: Tree, b: Tree):Tree= a AND b
1107
1107
1108
+
// drop annotations generated by CPS plugin etc, since its annotationchecker rejects T @cps[U] <: Any
1109
+
// let's assume for now annotations don't affect casts, drop them there, and bring them back using the outer Typed tree
// the force is needed mainly to deal with the GADT typing hack (we can't detect it otherwise as tp nor pt need contain an abstract type, we're just casting wildly)
// in principle we should pack the types of each branch before lubbing, but lub doesn't really work for existentials anyway
3777
3780
// in the special (though common) case where the types are equal, it pays to pack before comparing
3778
3781
// especially virtpatmat needs more aggressive unification of skolemized types
3779
3782
// this breaks src/library/scala/collection/immutable/TrieIterator.scala
3780
-
if (opt.virtPatmat &&!isPastTyper && thenTp =:= elseTp) (thenp1.tpe, false) // use unpacked type
3783
+
if ( opt.virtPatmat &&!isPastTyper
3784
+
&& thenp1.tpe.annotations.isEmpty && elsep1.tpe.annotations.isEmpty // annotated types need to be lubbed regardless (at least, continations break if you by pass them like this)
3785
+
&& thenTp =:= elseTp
3786
+
) (thenp1.tpe, false) // use unpacked type
3781
3787
// TODO: skolemize (lub of packed types) when that no longer crashes on files/pos/t4070b.scala
3782
3788
else ptOrLub(List(thenp1.tpe, elsep1.tpe))
3783
3789
@@ -3802,7 +3808,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
3802
3808
valselector1= atPos(tree.pos.focusStart) { if (arity ==1) ids.head else gen.mkTuple(ids) }
0 commit comments