File tree 7 files changed +14
-22
lines changed
compiler/src/dotty/tools/dotc 7 files changed +14
-22
lines changed Original file line number Diff line number Diff line change @@ -2117,11 +2117,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2117
2117
case nil =>
2118
2118
formals2.isEmpty
2119
2119
}
2120
- // Check if methods are erased, then the erased parameters match
2121
- val erasedValid =
2122
- if tp1.hasErasedParams && tp2.hasErasedParams then
2123
- tp1.erasedParams == tp2.erasedParams
2124
- else ! tp1.hasErasedParams && ! tp2.hasErasedParams
2120
+ // If methods have erased parameters, then the erased parameters must match
2121
+ val erasedValid = (! tp1.hasErasedParams && ! tp2.hasErasedParams) || (tp1.erasedParams == tp2.erasedParams)
2125
2122
2126
2123
erasedValid && loop(tp1.paramInfos, tp2.paramInfos)
2127
2124
}
Original file line number Diff line number Diff line change @@ -1473,7 +1473,7 @@ object Types {
1473
1473
1474
1474
/** Dealias, and if result is a dependent function type, drop the `apply` refinement. */
1475
1475
final def dropDependentRefinement (using Context ): Type = dealias match {
1476
- case RefinedType (parent, nme.apply, mt) if ! defn.isErasedFunctionType (parent) => parent
1476
+ case RefinedType (parent, nme.apply, mt) if defn.isNonRefinedFunction (parent) => parent
1477
1477
case tp => tp
1478
1478
}
1479
1479
Original file line number Diff line number Diff line change @@ -3253,7 +3253,6 @@ object Parsers {
3253
3253
val firstParamMod =
3254
3254
var mods = EmptyModifiers
3255
3255
if isErased then mods = addModifier(mods)
3256
- // if in.name == nme.inline then mods = addModifier(mods)
3257
3256
mods
3258
3257
if givenOnly && ! impliedMods.is(Given ) then
3259
3258
syntaxError(em " `using` expected " )
Original file line number Diff line number Diff line change @@ -829,12 +829,10 @@ object Erasure {
829
829
val Apply (fun, args) = tree
830
830
val origFun = fun.asInstanceOf [tpd.Tree ]
831
831
val origFunType = origFun.tpe.widen(using preErasureCtx)
832
- val erasedCompanion = if origFunType.hasErasedParams then
833
- Some (origFunType.asInstanceOf [MethodType ].erasedParams)
834
- else None
835
- val ownArgs = erasedCompanion.map { isErased =>
836
- args.zip(isErased).collect { case (arg, isErased) if ! isErased => arg }
837
- }.getOrElse(args)
832
+ val ownArgs = origFunType match
833
+ case mt : MethodType if mt.hasErasedParams =>
834
+ args.zip(mt.erasedParams).collect { case (arg, false ) => arg }
835
+ case _ => args
838
836
val fun1 = typedExpr(fun, AnyFunctionProto )
839
837
fun1.tpe.widen match
840
838
case mt : MethodType =>
Original file line number Diff line number Diff line change @@ -312,8 +312,7 @@ object GenericSignatures {
312
312
// erased method parameters do not make it to the bytecode.
313
313
def effectiveParamInfoss (t : Type )(using Context ): List [List [Type ]] = t match {
314
314
case t : MethodType if t.hasErasedParams =>
315
- t.paramInfos.zip(t.erasedParams)
316
- .flatMap((i, e) => if e then None else Some (i))
315
+ t.paramInfos.zip(t.erasedParams).collect{ case (i, false ) => i }
317
316
:: effectiveParamInfoss(t.resType)
318
317
case t : MethodType => t.paramInfos :: effectiveParamInfoss(t.resType)
319
318
case _ => Nil
Original file line number Diff line number Diff line change @@ -39,10 +39,11 @@ class PruneErasedDefs extends MiniPhase with SymTransformer { thisTransform =>
39
39
else sym.copySymDenotation(initFlags = sym.flags | Private )
40
40
41
41
override def transformApply (tree : Apply )(using Context ): Tree =
42
- if ! tree.fun.tpe.widen.hasErasedParams then tree
43
- else
44
- val erasedParams = tree.fun.tpe.widen.asInstanceOf [MethodType ].erasedParams
45
- cpy.Apply (tree)(tree.fun, tree.args.zip(erasedParams).map((a, e) => if e then trivialErasedTree(a) else a))
42
+ tree.fun.tpe.widen match
43
+ case mt : MethodType if mt.hasErasedParams =>
44
+ cpy.Apply (tree)(tree.fun, tree.args.zip(mt.erasedParams).map((a, e) => if e then trivialErasedTree(a) else a))
45
+ case _ =>
46
+ tree
46
47
47
48
override def transformValDef (tree : ValDef )(using Context ): Tree =
48
49
checkErasedInExperimental(tree.symbol)
Original file line number Diff line number Diff line change @@ -1241,7 +1241,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1241
1241
val pt1 = pt.strippedDealias.normalized
1242
1242
if (pt1 ne pt1.dropDependentRefinement)
1243
1243
&& defn.isContextFunctionType(pt1.nonPrivateMember(nme.apply).info.finalResultType)
1244
- && pt1.nonPrivateMember(nme.apply).info.asInstanceOf [MethodType ].isResultDependent
1245
1244
then
1246
1245
report.error(
1247
1246
em """ Implementation restriction: Expected result type $pt1
@@ -1356,8 +1355,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1356
1355
val resTpt = TypeTree (mt.nonDependentResultApprox).withSpan(body.span)
1357
1356
val typeArgs = appDef.termParamss.head.map(_.tpt) :+ resTpt
1358
1357
val core =
1359
- if mt.hasErasedParams
1360
- then TypeTree (defn.ErasedFunctionClass .typeRef)
1358
+ if mt.hasErasedParams then TypeTree (defn.ErasedFunctionClass .typeRef)
1361
1359
else
1362
1360
val funSym = defn.FunctionSymbol (numArgs, isContextual, isImpure)
1363
1361
val tycon = TypeTree (funSym.typeRef)
You can’t perform that action at this time.
0 commit comments