Skip to content

Commit

Permalink
Merge pull request #15340 from dotty-staging/backport-15217
Browse files Browse the repository at this point in the history
[backport] Eta expand export forwarders that have contetx function types
  • Loading branch information
Kordyjan committed Jun 1, 2022
2 parents 7fb87cb + 96b9bca commit a59f414
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ object Erasure {
case _: FunProto | AnyFunctionProto => tree
case _ => tree.tpe.widen match
case mt: MethodType if tree.isTerm =>
assert(mt.paramInfos.isEmpty)
assert(mt.paramInfos.isEmpty)//, i"bad adapt for $tree: $mt")
adaptToType(tree.appliedToNone, pt)
case tpw =>
if (pt.isInstanceOf[ProtoType] || tree.tpe <:< pt)
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,8 @@ class Namer { typer: Typer =>
import tpd._
val ref = path.select(sym.asTerm)
val ddef = tpd.DefDef(forwarder.asTerm, prefss =>
ref.appliedToArgss(adaptForwarderParams(Nil, sym.info, prefss)))
ref.appliedToArgss(adaptForwarderParams(Nil, sym.info, prefss))
.etaExpandCFT(using ctx.withOwner(forwarder)))
if forwarder.isInlineMethod then
PrepareInlineable.registerInlineInfo(forwarder, ddef.rhs)
buf += ddef.withSpan(span)
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotc/pos-test-pickling.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ i7740b.scala
i6507b.scala
i12299a.scala
i13871.scala
i15181.scala

# Tree is huge and blows stack for printing Text
i7034.scala
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i15181.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object prelude:
//def scombine[A](x: A, y: A): Semigroup[A] ?=> A = Semigroup.scombine(x,y)
export Semigroup.*

trait Semigroup[A]:
def scombine(x: A, y: A): A

object Semigroup:
def scombine[A](x: A, y: A) = (s: Semigroup[A]) ?=> s.scombine(x,y)

0 comments on commit a59f414

Please sign in to comment.