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 @@ -827,12 +827,10 @@ object Erasure {
827
827
val Apply (fun, args) = tree
828
828
val origFun = fun.asInstanceOf [tpd.Tree ]
829
829
val origFunType = origFun.tpe.widen(using preErasureCtx)
830
- val erasedCompanion = if origFunType.hasErasedParams then
831
- Some (origFunType.asInstanceOf [MethodType ].erasedParams)
832
- else None
833
- val ownArgs = erasedCompanion.map { isErased =>
834
- args.zip(isErased).collect { case (arg, isErased) if ! isErased => arg }
835
- }.getOrElse(args)
830
+ val ownArgs = origFunType match
831
+ case mt : MethodType if mt.hasErasedParams =>
832
+ args.zip(mt.erasedParams).collect { case (arg, false ) => arg }
833
+ case _ => args
836
834
val fun1 = typedExpr(fun, AnyFunctionProto )
837
835
fun1.tpe.widen match
838
836
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 @@ -1239,7 +1239,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1239
1239
val pt1 = pt.strippedDealias.normalized
1240
1240
if (pt1 ne pt1.dropDependentRefinement)
1241
1241
&& defn.isContextFunctionType(pt1.nonPrivateMember(nme.apply).info.finalResultType)
1242
- && pt1.nonPrivateMember(nme.apply).info.asInstanceOf [MethodType ].isResultDependent
1243
1242
then
1244
1243
report.error(
1245
1244
em """ Implementation restriction: Expected result type $pt1
@@ -1354,8 +1353,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1354
1353
val resTpt = TypeTree (mt.nonDependentResultApprox).withSpan(body.span)
1355
1354
val typeArgs = appDef.termParamss.head.map(_.tpt) :+ resTpt
1356
1355
val core =
1357
- if mt.hasErasedParams
1358
- then TypeTree (defn.ErasedFunctionClass .typeRef)
1356
+ if mt.hasErasedParams then TypeTree (defn.ErasedFunctionClass .typeRef)
1359
1357
else
1360
1358
val funSym = defn.FunctionSymbol (numArgs, isContextual, isImpure)
1361
1359
val tycon = TypeTree (funSym.typeRef)
You can’t perform that action at this time.
0 commit comments