Skip to content
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

Fix creating forwarders for simple alias givens #16193

Merged
merged 2 commits into from
Oct 16, 2022
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
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ object Flags {
val GivenOrImplicit: FlagSet = Given | Implicit
val GivenOrImplicitVal: FlagSet = GivenOrImplicit.toTermFlags
val GivenMethod: FlagSet = Given | Method
val LazyGiven: FlagSet = Given | Lazy
val InlineOrProxy: FlagSet = Inline | InlineProxy // An inline method or inline argument proxy */
val InlineMethod: FlagSet = Inline | Method
val InlineParam: FlagSet = Inline | Param
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class UncacheGivenAliases extends MiniPhase with IdentityDenotTransformer:
*/
override def transformValDef(tree: ValDef)(using Context): Tree =
val sym = tree.symbol
if sym.isAllOf(Given, Lazy) && !needsCache(sym, tree.rhs) then
if sym.isAllOf(LazyGiven) && !needsCache(sym, tree.rhs) then
sym.copySymDenotation(
initFlags = sym.flags &~ Lazy | Method,
info = ExprType(sym.info))
Expand Down
1 change: 1 addition & 0 deletions tests/run-deep-subtype/i16191.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
List(private final Context C.ctx)
16 changes: 16 additions & 0 deletions tests/run-deep-subtype/i16191.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This does not need deep-sub-type. It was placed here to avoid being run from JS tests.
class Context

def foo =
val ctx: Context = new Context
given a: Context = ctx

class C:
private val ctx: Context = new Context
given Context = ctx
given C = this

@main def Test =
val c = new C()
println(c.getClass.getDeclaredFields.toList)