Skip to content

Commit 099b91b

Browse files
DarkDimiusnicolasstucki
authored andcommitted
Fix #2944: propagate information from GADT bounds to normal info.
This allows all other parts of pipeline to be less aware of existence of the GADT bounds. In particular, it makes us pickle them as normal type bounds.
1 parent 0ddf48e commit 099b91b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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(sym: SymDenotation)(implicit ctx: Context): SymDenotation = {
63+
if (sym.is(BindDefinedType) && ctx.gadt.bounds.contains(sym.symbol)) {
64+
sym.copySymDenotation(info = ctx.gadt.bounds.apply(sym.symbol) & sym.info)
65+
} else sym
66+
}
67+
5968
/** the following two members override abstract members in Transform */
6069
override def phaseName: String = "posttyper"
6170

0 commit comments

Comments
 (0)