Skip to content

Commit 8b7f0ac

Browse files
committed
SI-5361 Refactor in accordance with review comments.
Check for malformed stats in the refinement body in the same place we check for erroneous parents.
1 parent 327083d commit 8b7f0ac

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,11 +2711,6 @@ trait Typers extends Modes with Adaptations with Tags {
27112711
val stats = templ.body
27122712
namer.enterSyms(stats)
27132713

2714-
// This is also checked later in typedStats, but that is too late for SI-5361, so
2715-
// we eagerly check this here.
2716-
for (stat <- stats if !treeInfo.isDeclarationOrTypeDef(stat))
2717-
OnlyDeclarationsError(stat)
2718-
27192714
// need to delay rest of typedRefinement to avoid cyclic reference errors
27202715
unit.toCheck += { () =>
27212716
val stats1 = typedStats(stats, NoSymbol)
@@ -5067,7 +5062,13 @@ trait Typers extends Modes with Adaptations with Tags {
50675062
def typedCompoundTypeTree(tree: CompoundTypeTree) = {
50685063
val templ = tree.templ
50695064
val parents1 = templ.parents mapConserve (typedType(_, mode))
5070-
if (parents1 exists (_.isErrorTyped)) tree setType ErrorType
5065+
5066+
// This is also checked later in typedStats, but that is too late for SI-5361, so
5067+
// we eagerly check this here.
5068+
for (stat <- templ.body if !treeInfo.isDeclarationOrTypeDef(stat))
5069+
OnlyDeclarationsError(stat)
5070+
5071+
if ((parents1 ++ templ.body) exists (_.isErrorTyped)) tree setType ErrorType
50715072
else {
50725073
val decls = newScope
50735074
//Console.println("Owner: " + context.enclClass.owner + " " + context.enclClass.owner.id)

0 commit comments

Comments
 (0)