Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the non-miniphase tree traverser #16684

Merged
merged 2 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,15 @@ class CheckUnused extends MiniPhase:
case t:tpd.ValDef =>
prepareForValDef(t)
traverseChildren(tree)(using newCtx)
transformValDef(t)
case t:tpd.DefDef =>
prepareForDefDef(t)
traverseChildren(tree)(using newCtx)
transformDefDef(t)
case t:tpd.TypeDef =>
prepareForTypeDef(t)
traverseChildren(tree)(using newCtx)
transformTypeDef(t)
case t: tpd.Bind =>
prepareForBind(t)
traverseChildren(tree)(using newCtx)
Expand Down Expand Up @@ -325,7 +328,7 @@ object CheckUnused:
* The optional name will be used to target the right import
* as the same element can be imported with different renaming
*/
def registerUsed(sym: Symbol, name: Option[Name])(using Context): Unit =
def registerUsed(sym: Symbol, name: Option[Name])(using Context): Unit =
if !isConstructorOfSynth(sym) && !doNotRegister(sym) then
if sym.isConstructor && sym.exists then
registerUsed(sym.owner, None) // constructor are "implicitly" imported with the class
Expand Down Expand Up @@ -365,7 +368,7 @@ object CheckUnused:
implicitParamInScope += memDef
else
explicitParamInScope += memDef
else if currScopeType.top == ScopeType.Local then
else if currScopeType.top == ScopeType.Local then
localDefInScope += memDef
else if currScopeType.top == ScopeType.Template && memDef.symbol.is(Private, butNot = SelfName) then
privateDefInScope += memDef
Expand Down
12 changes: 11 additions & 1 deletion tests/neg-custom-args/fatal-warnings/i15503i.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,14 @@ package foo.test.companionprivate:

object A:
private def b = c // OK
def c = List(1,2,3) // OK
def c = List(1,2,3) // OK

package foo.test.i16678:
def foo(func: Int => String, value: Int): String = func(value) // OK

def run =
println(foo(number => number.toString, value = 5)) // OK
println(foo(number => "<number>", value = 5)) // error
println(foo(func = number => "<number>", value = 5)) // error
println(foo(func = number => number.toString, value = 5)) // OK
println(foo(func = _.toString, value = 5)) // OK