Skip to content

Commit 49f183a

Browse files
committed
Run RefChecks at group end
Move to end of group. Needed a fix in ExtensionMethods to work correctly. Before the fix, extension methods got wrong flags.
1 parent 48a39b4 commit 49f183a

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ class Compiler {
5353
new ElimJavaPackages), // Eliminate syntactic references to Java packages
5454
List(new CheckStatic, // Check restrictions that apply to @static members
5555
new ElimRepeated, // Rewrite vararg parameters and arguments
56-
new RefChecks, // Various checks mostly related to abstract members and overriding
5756
new NormalizeFlags, // Rewrite some definition flags
5857
new ExtensionMethods, // Expand methods of value classes with extension methods
5958
new ExpandSAMs, // Expand single abstract method closures to anonymous classes
6059
new TailRec, // Rewrite tail recursion to loops
6160
new ByNameClosures, // Expand arguments to by-name parameters to closures
6261
new LiftTry, // Put try expressions that might execute on non-empty stacks into their own methods
6362
new HoistSuperArgs, // Hoist complex arguments of supercalls to enclosing scope
64-
new ClassOf), // Expand `Predef.classOf` calls.
63+
new ClassOf, // Expand `Predef.classOf` calls.
64+
new RefChecks), // Various checks mostly related to abstract members and overriding
6565
List(new TryCatchPatterns, // Compile cases in try/catch
6666
new PatternMatcher, // Compile pattern matches
6767
new ExplicitOuter, // Add accessors to outer classes from nested ones.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class ClassOf extends MiniPhaseTransform {
2121

2222
override def phaseName: String = "classOf"
2323

24+
override def treeTransformPhase(implicit ctx: Context, info: TransformerInfo) =
25+
groupEndPhase
26+
2427
override def transformTypeApply(tree: TypeApply)(implicit ctx: Context, info: TransformerInfo): Tree =
2528
if (tree.symbol eq defn.Predef_classOf) {
2629
val targ = tree.args.head.tpe

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with Ful
134134
private def createExtensionMethod(imeth: Symbol, staticClass: Symbol)(implicit ctx: Context): TermSymbol = {
135135
val extensionName = extensionNames(imeth).head.toTermName
136136
val extensionMeth = ctx.newSymbol(staticClass, extensionName,
137-
imeth.flags | Final &~ (Override | Protected | AbsOverride),
137+
(imeth.flags | Final) &~ (Override | Protected | AbsOverride),
138138
fullyParameterizedType(imeth.info, imeth.owner.asClass),
139139
privateWithin = imeth.privateWithin, coord = imeth.coord)
140140
extensionMeth.addAnnotations(imeth.annotations)(ctx.withPhase(thisTransformer))

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,9 +806,8 @@ class RefChecks extends MiniPhase { thisTransformer =>
806806
class Transform(currentLevel: RefChecks.OptLevelInfo = RefChecks.NoLevelInfo) extends TreeTransform {
807807
def phase = thisTransformer
808808

809-
// Errors when run at end of group
810-
//override def treeTransformPhase(implicit ctx: Context, info: TransformerInfo) =
811-
// groupEndPhase
809+
override def treeTransformPhase(implicit ctx: Context, info: TransformerInfo) =
810+
groupEndPhase
812811

813812
override def prepareForStats(trees: List[Tree])(implicit ctx: Context) = {
814813
// println(i"preparing for $trees%; %, owner = ${ctx.owner}")

0 commit comments

Comments
 (0)