Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Always transform Inlined.call in CheckUnused #23280

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1499,9 +1499,8 @@ object Trees {
protected def skipTransform(tree: Tree)(using Context): Boolean = false

/** For untyped trees, this is just the identity.
* For typed trees, a context derived form `ctx` that records `call` as the
* innermost enclosing call for which the inlined version is currently
* processed.
* For typed trees, a context derived from `ctx` that records `call` as the
* innermost enclosing call for which the inlined version is currently processed.
*/
protected def inlineContext(tree: Inlined)(using Context): Context = ctx

Expand Down
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
case _ =>
tree

// bindings and expansion are always transformed.
// Inlined.call was not necessarily witnessed, due to transparent inline or macros at inlining.
override def prepareForInlined(tree: Inlined)(using Context): Context =
refInfos.inlined.push(tree.call.srcPos)
ctx
override def transformInlined(tree: Inlined)(using Context): tree.type =
//transformAllDeep(tree.expansion) // traverse expansion with nonempty inlined stack to avoid registering defs
val _ = refInfos.inlined.pop()
if !tree.call.isEmpty && phaseMode.eq(PhaseMode.Aggregate) then
if !tree.call.isEmpty then
transformAllDeep(tree.call)
tree

Expand Down
12 changes: 6 additions & 6 deletions library/src/scala/compiletime/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ inline def summonAll[T <: Tuple]: T =
def byName[T](x: => T): T = x

/** Casts a value to be `Matchable`. This is needed if the value's type is an unconstrained
* type parameter and the value is the scrutinee of a match expression.
* This is normally disallowed since it violates parametricity and allows
* to uncover implementation details that were intended to be hidden.
* The `asMatchable` escape hatch should be used sparingly. It's usually
* better to constrain the scrutinee type to be `Matchable` in the first place.
*/
* type parameter and the value is the scrutinee of a match expression.
* This is normally disallowed since it violates parametricity and allows
* to uncover implementation details that were intended to be hidden.
* The `asMatchable` escape hatch should be used sparingly. It's usually
* better to constrain the scrutinee type to be `Matchable` in the first place.
*/
extension [T](x: T)
transparent inline def asMatchable: x.type & Matchable = x.asInstanceOf[x.type & Matchable]
Loading