@@ -352,14 +352,25 @@ class Namer { typer: Typer =>
352352 cls
353353 case tree : MemberDef =>
354354 val name = checkNoConflict(tree.name)
355- val flags = checkFlags(tree.mods.flags)
356- val isDeferred = lacksDefinition(tree)
357- val deferred = if (isDeferred) Deferred else EmptyFlags
358- val method = if (tree.isInstanceOf [DefDef ]) Method else EmptyFlags
359- val higherKinded = tree match {
360- case TypeDef (_, LambdaTypeTree (_, _)) if isDeferred => HigherKinded
361- case _ => EmptyFlags
362- }
355+ var flags = checkFlags(tree.mods.flags)
356+ tree match
357+ case tree : ValOrDefDef =>
358+ if tree.unforcedRhs == EmptyTree
359+ && ! flags.isOneOf(TermParamOrAccessor )
360+ && ! tree.name.isConstructorName
361+ then
362+ flags |= Deferred
363+ if (tree.isInstanceOf [DefDef ]) flags |= Method
364+ else if flags.isAllOf(EnumValue ) && ctx.owner.isStaticOwner then flags |= JavaStatic
365+ case tree : TypeDef =>
366+ def analyzeRHS (rhs : Tree ): Unit = rhs match
367+ case _ : TypeBoundsTree | _ : MatchTypeTree =>
368+ flags |= Deferred // Typedefs with Match rhs classify as abstract
369+ case LambdaTypeTree (_, body) =>
370+ flags |= HigherKinded
371+ analyzeRHS(body)
372+ case _ =>
373+ if tree.rhs.isEmpty then flags |= Deferred else analyzeRHS(tree.rhs)
363374
364375 // to complete a constructor, move one context further out -- this
365376 // is the context enclosing the class. Note that the context in which a
@@ -370,7 +381,7 @@ class Namer { typer: Typer =>
370381 // Don't do this for Java constructors because they need to see the import
371382 // of the companion object, and it is not necessary for them because they
372383 // have no implementation.
373- val cctx = if (tree.name == nme.CONSTRUCTOR && ! tree.mods .is(JavaDefined )) ctx.outer else ctx
384+ val cctx = if (tree.name == nme.CONSTRUCTOR && ! flags .is(JavaDefined )) ctx.outer else ctx
374385
375386 val completer = tree match {
376387 case tree : TypeDef =>
@@ -380,8 +391,7 @@ class Namer { typer: Typer =>
380391 new Completer (tree)(cctx)
381392 }
382393 val info = adjustIfModule(completer, tree)
383- createOrRefine[Symbol ](tree, name, flags | deferred | method | higherKinded,
384- ctx.owner, _ => info,
394+ createOrRefine[Symbol ](tree, name, flags, ctx.owner, _ => info,
385395 (fs, _, pwithin) => ctx.newSymbol(ctx.owner, name, fs, info, pwithin, tree.nameSpan))
386396 case tree : Import =>
387397 recordSym(ctx.newImportSymbol(ctx.owner, new Completer (tree), tree.span), tree)
0 commit comments