Skip to content

Add Flags.Open to reflection API #10444

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 1 commit into from
Nov 22, 2020
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 @@ -2451,6 +2451,7 @@ class QuoteContextImpl private (using val ctx: Context) extends QuoteContext, Qu
def Mutable: Flags = dotc.core.Flags.Mutable
def Object: Flags = dotc.core.Flags.Module
def Opaque: Flags = dotc.core.Flags.Opaque
def Open: Flags = dotc.core.Flags.Open
def Override: Flags = dotc.core.Flags.Override
def Package: Flags = dotc.core.Flags.Package
def Param: Flags = dotc.core.Flags.Param
Expand Down
3 changes: 3 additions & 0 deletions library/src/scala/quoted/QuoteContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3199,6 +3199,9 @@ trait QuoteContext { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
/** Is this symbol `opaque` */
def Opaque: Flags

/** Is this symbol `open` */
def Open: Flags

/** Is this symbol `override` */
def Override: Flags

Expand Down
9 changes: 1 addition & 8 deletions scala3doc/src/dotty/dokka/tasty/SymOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ class SymOps[Q <: QuoteContext](val q: Q):
case (None, None, (false, false, false)) => Visibility.Unrestricted
case _ => throw new Exception(s"Visibility for symbol $sym cannot be determined")

// TODO: #49 Remove it after TASTY-Reflect release with published flag Extension
def hackIsOpen: Boolean = {
import dotty.tools.dotc
given dotc.core.Contexts.Context = qctx.asInstanceOf[scala.quoted.runtime.impl.QuoteContextImpl].ctx
val symbol = sym.asInstanceOf[dotc.core.Symbols.Symbol]
symbol.is(dotc.core.Flags.Open)
}

// Order here determines order in documenation
def getExtraModifiers(): Seq[Modifier] = Seq(
Expand All @@ -64,10 +57,10 @@ class SymOps[Q <: QuoteContext](val q: Q):
Flags.Implicit -> Modifier.Implicit,
Flags.Inline -> Modifier.Inline,
Flags.Lazy -> Modifier.Lazy,
Flags.Open -> Modifier.Open,
Flags.Override -> Modifier.Override,
Flags.Case -> Modifier.Case,
).collect { case (flag, mod) if sym.flags.is(flag) => mod }
++ (if(sym.hackIsOpen) Seq(Modifier.Open) else Nil)

def isHiddenByVisibility: Boolean =
import VisibilityScope._
Expand Down