Skip to content

Commit

Permalink
Always expand inline accessor names
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky authored and bishabosha committed Oct 18, 2022
1 parent 0d523b0 commit b70ade5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/typer/PrepareInlineable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,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
InlineAccessorName(name).expandedName(site)

/** 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())

0 comments on commit b70ade5

Please sign in to comment.