Skip to content

Always expand inline accessor names #15619

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

Merged
merged 2 commits into from
Jul 20, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object PrepareInlineable {
abstract class MakeInlineableMap(val inlineSym: Symbol) extends TreeMap with Insert {
def accessorNameOf(name: TermName, site: Symbol)(using Context): TermName =
val accName = InlineAccessorName(name)
if site.is(Trait) then accName.expandedName(site) else accName
if site.isExtensibleClass then accName.expandedName(site) else accName

/** A definition needs an accessor if it is private, protected, or qualified private
* and it is not part of the tree that gets inlined. The latter test is implemented
Expand Down
11 changes: 0 additions & 11 deletions tests/neg/i15323.scala

This file was deleted.

23 changes: 23 additions & 0 deletions tests/pos/i15612.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import scala.reflect.TypeTest

class ForSyntax[E](using E: TypeTest[E | Any, E]):
extension [A](aOrE: E | A)
inline def flatMap[B](f: A => E | B): E | B =
aOrE match
case e: E => ???
case _ => ???


class UnhappyCase[E](using E: TypeTest[E | Any, E]) extends ForSyntax[E]:
extension [A](aOrE: E | A)
inline def fold[B](inline fe: E => B, inline fa: A => B): B =
aOrE match
case e: E => ???
case _ => ???

class A:
private val a = 1
inline def foo() = a
class B extends A:
private val a = 2
inline def bar() = a
2 changes: 1 addition & 1 deletion tests/run-macros/i5119.check
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Select(Typed(Apply(Select(New(TypeIdent("StringContextOps")), "<init>"), List(Apply(Select(Select(Select(Ident("_root_"), "scala"), "StringContext"), "apply"), List(Typed(Repeated(List(Literal(StringConstant("Hello World ")), Literal(StringConstant("!"))), Inferred()), Inferred()))))), TypeIdent("StringContextOps")), "inline$sc")
Select(Typed(Apply(Select(New(TypeIdent("StringContextOps")), "<init>"), List(Apply(Select(Select(Select(Ident("_root_"), "scala"), "StringContext"), "apply"), List(Typed(Repeated(List(Literal(StringConstant("Hello World ")), Literal(StringConstant("!"))), Inferred()), Inferred()))))), TypeIdent("StringContextOps")), "Macro$StringContextOps$$inline$sc")
Typed(Repeated(List(Literal(IntConstant(1))), Inferred()), Inferred())