Skip to content

Commit 0b25662

Browse files
authored
Merge pull request #15752 from dotty-staging/backport-15619
Backport #15619: Always expand inline accessor names
2 parents 0aab2b7 + c3d3341 commit 0b25662

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

compiler/src/dotty/tools/dotc/typer/PrepareInlineable.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ object PrepareInlineable {
5454
abstract class MakeInlineableMap(val inlineSym: Symbol) extends TreeMap with Insert {
5555
def accessorNameOf(name: TermName, site: Symbol)(using Context): TermName =
5656
val accName = InlineAccessorName(name)
57-
if site.is(Trait) then accName.expandedName(site) else accName
57+
if site.isExtensibleClass then accName.expandedName(site) else accName
5858

5959
/** A definition needs an accessor if it is private, protected, or qualified private
6060
* and it is not part of the tree that gets inlined. The latter test is implemented

tests/neg/i15323.scala

-11
This file was deleted.

tests/pos/i15612.scala

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import scala.reflect.TypeTest
2+
3+
class ForSyntax[E](using E: TypeTest[E | Any, E]):
4+
extension [A](aOrE: E | A)
5+
inline def flatMap[B](f: A => E | B): E | B =
6+
aOrE match
7+
case e: E => ???
8+
case _ => ???
9+
10+
11+
class UnhappyCase[E](using E: TypeTest[E | Any, E]) extends ForSyntax[E]:
12+
extension [A](aOrE: E | A)
13+
inline def fold[B](inline fe: E => B, inline fa: A => B): B =
14+
aOrE match
15+
case e: E => ???
16+
case _ => ???
17+
18+
class A:
19+
private val a = 1
20+
inline def foo() = a
21+
class B extends A:
22+
private val a = 2
23+
inline def bar() = a

tests/run-macros/i5119.check

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
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")
1+
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")
22
Typed(Repeated(List(Literal(IntConstant(1))), Inferred()), Inferred())

0 commit comments

Comments
 (0)