Skip to content

Commit a24e86a

Browse files
committed
Handle wildcard args when expanding partial functions
Because of the previous commit, tests/fuzzy/AE-9a131723f09b9f77c99c52b709965e580a61706e.scala now passes the typer, but then crashes in ExpandSAMs because we attempt to create an anonymous class whose parent is `PartialFunction[_, Int]` and tpd.ClassDef does not handle wildcard arguments. We avoid this issue by getting the argument types for the parent from the closure DefDef whose parameter and result types can never be wildcards.
1 parent 3283f50 commit a24e86a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ class ExpandSAMs extends MiniPhase {
107107
anon.rhs match {
108108
case PartialFunctionRHS(pf) =>
109109
val anonSym = anon.symbol
110-
111-
val parents = List(defn.AbstractPartialFunctionType.appliedTo(tpe.argInfos), defn.SerializableType)
110+
val anonTpe = anon.tpe.widen
111+
val parents = List(defn.AbstractPartialFunctionType.appliedTo(anonTpe.firstParamTypes.head, anonTpe.resultType), defn.SerializableType)
112112
val pfSym = ctx.newNormalizedClassSymbol(anonSym.owner, tpnme.ANON_CLASS, Synthetic | Final, parents, coord = tree.span)
113113

114114
def overrideSym(sym: Symbol) = sym.copy(

0 commit comments

Comments
 (0)