Skip to content

Commit c723851

Browse files
committed
Fix "supercalls not allowed in inlined code" error logic
1 parent c3e8087 commit c723851

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
192192
}
193193
else
194194
transformSelect(tree, Nil)
195-
case tree: Super =>
196-
if (ctx.owner.enclosingMethod.isInlineMethod)
197-
ctx.error(SuperCallsNotAllowedInline(ctx.owner), tree.pos)
198-
super.transform(tree)
199195
case tree: Apply =>
200196
methPart(tree) match {
201197
case Select(nu: New, nme.CONSTRUCTOR) if isCheckable(nu) =>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ object Inliner {
8888
sym != inlineMethod &&
8989
(!sym.is(Param) || sym.owner != inlineMethod)
9090

91-
def isExternalReference(sym: Symbol)(implicit ctx: Context): Boolean = {
92-
val inlineMethod = ctx.owner.ownersIterator.findSymbol(_.isInlineMethod)
93-
sym.exists && !isLocal(sym, inlineMethod)
94-
}
91+
def enclosingInlineMethod(implicit ctx: Context) =
92+
ctx.owner.ownersIterator.findSymbol(_.isInlineMethod)
93+
94+
def isExternalReference(sym: Symbol)(implicit ctx: Context): Boolean =
95+
ctx.mode.is(Mode.BodyOfInlined) && sym.exists && !isLocal(sym, enclosingInlineMethod)
9596

9697
/** Register inline info for given inline method `sym`.
9798
*

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ class Typer extends Namer
475475
case pt: SelectionProto if pt.name == nme.CONSTRUCTOR => true
476476
case _ => false
477477
}
478-
if (ctx.mode.is(Mode.BodyOfInlined) && Inliner.isExternalReference(qual1.symbol))
479-
ctx.error(em"illegal super call in inlined method", tree.pos)
478+
if (Inliner.isExternalReference(qual1.symbol))
479+
ctx.error(SuperCallsNotAllowedInline(Inliner.enclosingInlineMethod), tree.pos)
480480
pt match {
481481
case pt: SelectionProto if pt.name.isTypeName =>
482482
qual1 // don't do super references for types; they are meaningless anyway

0 commit comments

Comments
 (0)