Skip to content

Commit 6b2ef64

Browse files
committed
Fix #8856: Keep transparent flag
1 parent 37bc11d commit 6b2ef64

File tree

11 files changed

+17
-10
lines changed

11 files changed

+17
-10
lines changed

compiler/src/dotty/tools/dotc/ast/untpd.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
196196

197197
case class Inline()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Inline)
198198

199-
case class Transparent()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.EmptyFlags)
199+
case class Transparent()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Transparent)
200200
}
201201

202202
/** Modifiers and annotations for definitions

compiler/src/dotty/tools/dotc/core/Flags.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,11 @@ object Flags {
347347
/** Labeled with `erased` modifier (erased value) */
348348
val (_, Erased @ _, _) = newFlags(42, "erased")
349349

350+
/** Labelled with `transparent` modifier */
351+
val (Transparent @ _, _, _) = newFlags(43, "transparent")
352+
350353
/** An opaque type alias or a class containing one */
351-
val (Opaque @ _, _, _) = newFlags(43, "opaque")
354+
val (Opaque @ _, _, _) = newFlags(44, "opaque")
352355

353356

354357
// ------------ Flags following this one are not pickled ----------------------------------

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

-2
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
865865
if (rawFlags.is(Param)) flagMask = flagMask &~ Given
866866
val flags = rawFlags & flagMask
867867
var flagsText = toTextFlags(sym, flags)
868-
if mods.hasMod(classOf[untpd.Mod.Transparent]) then
869-
flagsText = "transparent " ~ flagsText
870868
val annotations =
871869
if (sym.exists) sym.annotations.filterNot(ann => dropAnnotForModText(ann.symbol)).map(_.tree)
872870
else mods.annotations.filterNot(tree => dropAnnotForModText(tree.symbol))

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
18471847
def Flags_Lazy: Flags = core.Flags.Lazy
18481848
def Flags_Override: Flags = core.Flags.Override
18491849
def Flags_Inline: Flags = core.Flags.Inline
1850+
def Flags_Transparent: Flags = core.Flags.Transparent
18501851
def Flags_Macro: Flags = core.Flags.Macro
18511852
def Flags_Static: Flags = core.Flags.JavaStatic
18521853
def Flags_JavaDefined: Flags = core.Flags.JavaDefined

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ class Namer { typer: Typer =>
866866
case original: untpd.DefDef if sym.isInlineMethod =>
867867
def rhsToInline(using Context): tpd.Tree =
868868
val mdef = typedAheadExpr(original).asInstanceOf[tpd.DefDef]
869-
PrepareInlineable.wrapRHS(original, mdef.tpt, mdef.rhs)
869+
PrepareInlineable.wrapRHS(sym, mdef.tpt, mdef.rhs)
870870
PrepareInlineable.registerInlineInfo(sym, rhsToInline)(using localContext(sym))
871871
case _ =>
872872
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ object PrepareInlineable {
204204
def isLocal(sym: Symbol, inlineMethod: Symbol)(using Context): Boolean =
205205
isLocalOrParam(sym, inlineMethod) && !(sym.is(Param) && sym.owner == inlineMethod)
206206

207-
/** The type ascription `rhs: tpt`, unless `original` is `transparent`. */
208-
def wrapRHS(original: untpd.DefDef, tpt: Tree, rhs: Tree)(using Context): Tree =
209-
if original.mods.hasMod(classOf[untpd.Mod.Transparent]) then rhs
207+
/** The type ascription `rhs: tpt`, unless `sym` is `transparent`. */
208+
def wrapRHS(sym: Symbol, tpt: Tree, rhs: Tree)(using Context): Tree =
209+
if sym.is(Transparent) then rhs
210210
else Typed(rhs, tpt)
211211

212212
/** Register inline info for given inlineable method `sym`.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,7 @@ class Typer extends Namer
18651865

18661866
if (sym.isInlineMethod) rhsCtx.addMode(Mode.InlineableBody)
18671867
val rhs1 = typedExpr(ddef.rhs, tpt1.tpe.widenExpr)(using rhsCtx)
1868-
val rhsToInline = PrepareInlineable.wrapRHS(ddef, tpt1, rhs1)
1868+
val rhsToInline = PrepareInlineable.wrapRHS(sym, tpt1, rhs1)
18691869

18701870
if (sym.isInlineMethod)
18711871
PrepareInlineable.registerInlineInfo(sym, rhsToInline)

library/src/scala/tasty/Reflection.scala

+3
Original file line numberDiff line numberDiff line change
@@ -2607,6 +2607,9 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
26072607
/** Is this symbol `inline` */
26082608
def Inline: Flags = internal.Flags_Inline
26092609

2610+
/** Is this symbol a `transparent` */
2611+
def Transparent: Flags = internal.Flags_Transparent
2612+
26102613
/** Is this symbol marked as a macro. An inline method containing toplevel splices */
26112614
def Macro: Flags = internal.Flags_Macro
26122615

library/src/scala/tasty/reflect/CompilerInterface.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,7 @@ trait CompilerInterface {
13971397
def Flags_Lazy: Flags
13981398
def Flags_Override: Flags
13991399
def Flags_Inline: Flags
1400+
def Flags_Transparent: Flags
14001401
def Flags_Macro: Flags
14011402
def Flags_Static: Flags
14021403
def Flags_JavaDefined: Flags

library/src/scala/tasty/reflect/SourceCodePrinter.scala

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
3434
if (flags.is(Flags.Lazy)) flagList += "lazy"
3535
if (flags.is(Flags.Override)) flagList += "override"
3636
if (flags.is(Flags.Inline)) flagList += "inline"
37+
if (flags.is(Flags.Transparent)) flagList += "transparent"
3738
if (flags.is(Flags.Macro)) flagList += "macro"
3839
if (flags.is(Flags.JavaDefined)) flagList += "javaDefined"
3940
if (flags.is(Flags.Static)) flagList += "javaStatic"

tasty/src/dotty/tools/tasty/TastyFormat.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ Standard Section: "Comments" Comment*
248248
object TastyFormat {
249249

250250
final val header: Array[Int] = Array(0x5C, 0xA1, 0xAB, 0x1F)
251-
val MajorVersion: Int = 22
251+
val MajorVersion: Int = 23
252252
val MinorVersion: Int = 0
253253

254254
/** Tags used to serialize names, should update [[nameTagToString]] if a new constant is added */

0 commit comments

Comments
 (0)