Skip to content

Eta expand CFTs in super accessors if needed #15092

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
May 9, 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
11 changes: 6 additions & 5 deletions compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ class ResolveSuper extends MiniPhase with IdentityDenotTransformer { thisPhase =
import ops._

def superAccessors(mixin: ClassSymbol): List[Tree] =
for (superAcc <- mixin.info.decls.filter(_.isSuperAccessor))
yield {
util.Stats.record("super accessors")
DefDef(mkForwarderSym(superAcc.asTerm), forwarderRhsFn(rebindSuper(cls, superAcc)))
}
for superAcc <- mixin.info.decls.filter(_.isSuperAccessor)
yield
util.Stats.record("super accessors")
val fwd = mkForwarderSym(superAcc.asTerm)
DefDef(fwd, forwarderRhsFn(rebindSuper(cls, superAcc))
.andThen(_.etaExpandCFT(using ctx.withOwner(fwd))))

val overrides = mixins.flatMap(superAccessors)

Expand Down
13 changes: 13 additions & 0 deletions tests/pos/i14999.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
trait Foo:
def foo: String ?=> Int =
summon[String].length

trait Bar extends Foo:
override def foo =
super.foo

class Baz extends Bar

@main def Test =
given String = "hello"
assert(Baz().foo == 5)