File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -45,17 +45,26 @@ import reporting.diagnostic.messages.SuperCallsNotAllowedInline
4545 * (11) Minimizes `call` fields of `Inline` nodes to just point to the toplevel
4646 * class from which code was inlined.
4747 *
48+ * (12) Converts GADT bounds into normal type bounds
49+ *
4850 * The reason for making this a macro transform is that some functions (in particular
4951 * super and protected accessors and instantiation checks) are naturally top-down and
5052 * don't lend themselves to the bottom-up approach of a mini phase. The other two functions
5153 * (forwarding param accessors and synthetic methods) only apply to templates and fit
5254 * mini-phase or subfunction of a macro phase equally well. But taken by themselves
5355 * they do not warrant their own group of miniphases before pickling.
5456 */
55- class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTransformer =>
57+ class PostTyper extends MacroTransform with SymTransformer { thisTransformer =>
58+
5659
5760 import tpd ._
5861
62+ def transformSym (ref : SymDenotation )(implicit ctx : Context ): SymDenotation = {
63+ if (ref.is(BindDefinedType ) && ctx.gadt.bounds.contains(ref.symbol)) {
64+ ref.copySymDenotation(info = ctx.gadt.bounds.apply(ref.symbol) & ref.info)
65+ } else ref
66+ }
67+
5968 /** the following two members override abstract members in Transform */
6069 override def phaseName : String = " posttyper"
6170
Original file line number Diff line number Diff line change 1+ trait Map2 [K ] {
2+ def get (k : K ): K = k
3+ def foo : K = {
4+ this match {
5+ case that : Map2 [b] => that.get(3 .asInstanceOf [b])
6+ // case that: Map2[c] => that.get(4.asInstanceOf[K])
7+ case _ => get(5 .asInstanceOf [K ])
8+ }
9+ }
10+ }
You can’t perform that action at this time.
0 commit comments