Skip to content

Commit

Permalink
Merge SourceInvisible and Invisible flags
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Oct 10, 2024
1 parent 932d797 commit 07f729e
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 24 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ object Denotations {
def filterDisjoint(denots: PreDenotation)(using Context): SingleDenotation =
if (denots.exists && denots.matches(this)) NoDenotation else this
def filterWithFlags(required: FlagSet, excluded: FlagSet)(using Context): SingleDenotation =
val realExcluded = if ctx.isAfterTyper then excluded else excluded | Invisible | (if ctx.mode.is(Mode.ResolveFromTASTy) then EmptyFlags else SourceInvisible)
val realExcluded = if ctx.isAfterTyper then excluded else excluded | (if ctx.mode.is(Mode.ResolveFromTASTy) then EmptyFlags else Invisible)
def symd: SymDenotation = this match
case symd: SymDenotation => symd
case _ => symbol.denot
Expand Down
7 changes: 2 additions & 5 deletions compiler/src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,6 @@ object Flags {
/** Tracked modifier for class parameter / a class with some tracked parameters */
val (Tracked @ _, _, Dependent @ _) = newFlags(46, "tracked")

/** Symbol can not be resolved from source during typer. PROVISIONAL (possibly replace with `Invisible` with new semantics) */
val (SourceInvisible @ _, _, _) = newFlags(47, "<source-invisible>")

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

/** Symbol is not a member of its owner */
Expand Down Expand Up @@ -474,7 +471,7 @@ object Flags {
Scala2SpecialFlags, MutableOrOpen, Opaque, Touched, JavaStatic,
OuterOrCovariant, LabelOrContravariant, CaseAccessor, Tracked,
Extension, NonMember, Implicit, Given, Permanent, Synthetic, Exported,
SuperParamAliasOrScala2x, Inline, Macro, ConstructorProxy, Invisible, SourceInvisible)
SuperParamAliasOrScala2x, Inline, Macro, ConstructorProxy, Invisible)

/** Flags that are not (re)set when completing the denotation, or, if symbol is
* a top-level class or object, when completing the denotation once the class
Expand Down Expand Up @@ -528,7 +525,7 @@ object Flags {
val RetainedModuleValAndClassFlags: FlagSet =
AccessFlags | Package | Case |
Synthetic | JavaDefined | JavaStatic | Artifact |
Lifted | MixedIn | Specialized | ConstructorProxy | Invisible | SourceInvisible | Erased
Lifted | MixedIn | Specialized | ConstructorProxy | Invisible | Erased

/** Flags that can apply to a module val */
val RetainedModuleValFlags: FlagSet = RetainedModuleValAndClassFlags |
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/NamerOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ object NamerOps:
else NoSymbol.assertingErrorsReported(em"no companion $name in $scope")

/** If a class has one of these flags, it does not get a constructor companion */
private val NoConstructorProxyNeededFlags = Abstract | Trait | Case | Synthetic | Module | Invisible | SourceInvisible
private val NoConstructorProxyNeededFlags = Abstract | Trait | Case | Synthetic | Module | Invisible

/** The flags of a constructor companion */
private val ConstructorCompanionFlags = Synthetic | ConstructorProxy
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ object SymDenotations {
case _ =>
// Otherwise, no completion is necessary, see the preconditions of `markAbsent()`.
(myInfo `eq` NoType)
|| (is(Invisible) || is(SourceInvisible) && !ctx.mode.is(Mode.ResolveFromTASTy)) && ctx.isTyper
|| (is(Invisible) && !ctx.mode.is(Mode.ResolveFromTASTy)) && ctx.isTyper
|| is(ModuleVal, butNot = Package) && moduleClass.isAbsent(canForce)
}

Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,6 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
if flags.is(Transparent) then writeModTag(TRANSPARENT)
if flags.is(Infix) then writeModTag(INFIX)
if flags.is(Invisible) then writeModTag(INVISIBLE)
if flags.is(SourceInvisible) then writeModTag(SOURCEINVISIBLE)
if (flags.is(Erased)) writeModTag(ERASED)
if (flags.is(Exported)) writeModTag(EXPORTED)
if (flags.is(Given)) writeModTag(GIVEN)
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,6 @@ class TreeUnpickler(reader: TastyReader,
case EXPORTED => addFlag(Exported)
case OPEN => addFlag(Open)
case INVISIBLE => addFlag(Invisible)
case SOURCEINVISIBLE => addFlag(SourceInvisible)
case TRANSPARENT => addFlag(Transparent)
case INFIX => addFlag(Infix)
case TRACKED => addFlag(Tracked)
Expand Down Expand Up @@ -1583,7 +1582,7 @@ class TreeUnpickler(reader: TastyReader,
(if !d.exists then lookupInSuper else d).asSeenFrom(prefix)

val denot = inContext(ctx.addMode(Mode.ResolveFromTASTy)):
searchDenot // able to resolve SourceInvisible members
searchDenot // able to resolve Invisible members


val sel = makeSelect(qual, name, denot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import dotty.tools.unreachable
/**Implementation of SIP-61.
* Runs when `@unroll` annotations are found in a compilation unit, installing new definitions
*
* Note that it only generates `SourceInvisible` methods, so no interactions with Zinc/SemanticDB
* Note that it only generates `Invisible` methods, so no interactions with Zinc/SemanticDB
*/
class UnrollDefinitions extends MacroTransform, IdentityDenotTransformer {
self =>
Expand Down Expand Up @@ -127,7 +127,7 @@ class UnrollDefinitions extends MacroTransform, IdentityDenotTransformer {
defdef.symbol.owner,
defdef.name,
defdef.symbol.flags &~ HasDefaultParams |
SourceInvisible | Synthetic,
Invisible | Synthetic,
NoType, // fill in later
coord = nextSymbol.span.shift(1) // shift by 1 to avoid "secondary constructor must call preceding" error
).entered
Expand Down
1 change: 0 additions & 1 deletion compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2955,7 +2955,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
def Infix: Flags = dotc.core.Flags.Infix
def Inline: Flags = dotc.core.Flags.Inline
def Invisible: Flags = dotc.core.Flags.Invisible
def SourceInvisible: Flags = dotc.core.Flags.SourceInvisible
def JavaDefined: Flags = dotc.core.Flags.JavaDefined
def JavaStatic: Flags = dotc.core.Flags.JavaStatic
def JavaAnnotation: Flags = dotc.core.Flags.JavaAnnotation
Expand Down
4 changes: 0 additions & 4 deletions library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4588,10 +4588,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
/** Is this symbol invisible when typechecking? */
def Invisible: Flags

/** Is this symbol invisible when typechecking? (only from source) */
@experimental
def SourceInvisible: Flags

/** Is this symbol defined in a Java class */
def JavaDefined: Flags

Expand Down
6 changes: 1 addition & 5 deletions tasty/src/dotty/tools/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ Standard-Section: "ASTs" TopLevelStat*
PARAMalias -- Parameter is alias of a superclass parameter
EXPORTED -- An export forwarder
OPEN -- an open class
INVISIBLE -- invisible during typechecking
SOURCEINVISIBLE -- invisible in the source code
INVISIBLE -- invisible during typechecking, except when resolving from TASTy
TRACKED -- a tracked class parameter / a dependent class
Annotation
Expand Down Expand Up @@ -512,7 +511,6 @@ object TastyFormat {
final val EMPTYCLAUSE = 45
final val SPLITCLAUSE = 46
final val TRACKED = 47
final val SOURCEINVISIBLE = 48

// Tree Cat. 2: tag Nat
final val firstNatTreeTag = SHAREDterm
Expand Down Expand Up @@ -702,7 +700,6 @@ object TastyFormat {
| EXPORTED
| OPEN
| INVISIBLE
| SOURCEINVISIBLE
| ANNOTATION
| PRIVATEqualified
| PROTECTEDqualified
Expand Down Expand Up @@ -767,7 +764,6 @@ object TastyFormat {
case EXPORTED => "EXPORTED"
case OPEN => "OPEN"
case INVISIBLE => "INVISIBLE"
case SOURCEINVISIBLE => "SOURCEINVISIBLE"
case PARAMalias => "PARAMalias"
case EMPTYCLAUSE => "EMPTYCLAUSE"
case SPLITCLAUSE => "SPLITCLAUSE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ val experimentalDefinitionInLibrary = Set(
"scala.Predef$.runtimeChecked", "scala.annotation.internal.RuntimeChecked",

// New feature: SIP 61 - @unroll annotation
"scala.annotation.unroll", "scala.quoted.Quotes.reflectModule.FlagsModule.SourceInvisible"
"scala.annotation.unroll"
)


Expand Down

0 comments on commit 07f729e

Please sign in to comment.