@@ -40,7 +40,7 @@ import annotation.tailrec
40
40
import Implicits .*
41
41
import util .Stats .record
42
42
import config .Printers .{gadts , typr }
43
- import config .Feature , Feature .{migrateTo3 , sourceVersion , warnOnMigration }
43
+ import config .Feature , Feature .{migrateTo3 , modularity , sourceVersion , warnOnMigration }
44
44
import config .SourceVersion .*
45
45
import rewrites .Rewrites , Rewrites .patch
46
46
import staging .StagingLevel
@@ -53,6 +53,7 @@ import config.MigrationVersion
53
53
import transform .CheckUnused .OriginalName
54
54
55
55
import scala .annotation .constructorOnly
56
+ import dotty .tools .dotc .ast .desugar .PolyFunctionApply
56
57
57
58
object Typer {
58
59
@@ -1145,7 +1146,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1145
1146
if templ1.parents.isEmpty
1146
1147
&& isFullyDefined(pt, ForceDegree .flipBottom)
1147
1148
&& isSkolemFree(pt)
1148
- && isEligible(pt.underlyingClassRef(refinementOK = Feature .enabled(Feature . modularity)))
1149
+ && isEligible(pt.underlyingClassRef(refinementOK = Feature .enabled(modularity)))
1149
1150
then
1150
1151
templ1 = cpy.Template (templ)(parents = untpd.TypeTree (pt) :: Nil )
1151
1152
for case parent : RefTree <- templ1.parents do
@@ -1720,11 +1721,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1720
1721
typedFunctionType(desugar.makeFunctionWithValDefs(tree, pt), pt)
1721
1722
else
1722
1723
val funSym = defn.FunctionSymbol (numArgs, isContextual, isImpure)
1723
- val args1 = args.mapConserve {
1724
- case cb : untpd.ContextBoundTypeTree => typed(cb)
1725
- case t => t
1726
- }
1727
- val result = typed(cpy.AppliedTypeTree (tree)(untpd.TypeTree (funSym.typeRef), args1 :+ body), pt)
1724
+ // val args1 = args.mapConserve {
1725
+ // case cb: untpd.ContextBoundTypeTree => typed(cb)
1726
+ // case t => t
1727
+ // }
1728
+ val result = typed(cpy.AppliedTypeTree (tree)(untpd.TypeTree (funSym.typeRef), args :+ body), pt)
1728
1729
// if there are any erased classes, we need to re-do the typecheck.
1729
1730
result match
1730
1731
case r : AppliedTypeTree if r.args.exists(_.tpe.isErasedClass) =>
@@ -1923,10 +1924,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1923
1924
1924
1925
def typedPolyFunction (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
1925
1926
val tree1 = desugar.normalizePolyFunction(tree)
1926
- val tree2 = if Feature .enabled(Feature .modularity) then desugar.expandPolyFunctionContextBounds(tree1)
1927
- else tree1
1928
- if (ctx.mode is Mode .Type ) typed(desugar.makePolyFunctionType(tree2), pt)
1929
- else typedPolyFunctionValue(tree2, pt)
1927
+ if (ctx.mode is Mode .Type ) typed(desugar.makePolyFunctionType(tree1), pt)
1928
+ else typedPolyFunctionValue(tree1, pt)
1930
1929
1931
1930
def typedPolyFunctionValue (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
1932
1931
val untpd .PolyFunction (tparams : List [untpd.TypeDef ] @ unchecked, fun) = tree : @ unchecked
@@ -1951,15 +1950,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1951
1950
val resultTpt =
1952
1951
untpd.InLambdaTypeTree (isResult = true , (tsyms, vsyms) =>
1953
1952
mt.resultType.substParams(mt, vsyms.map(_.termRef)).substParams(poly, tsyms.map(_.typeRef)))
1954
- val desugared = desugar.makeClosure(tparams, inferredVParams, body, resultTpt, tree.span)
1953
+ val desugared @ Block (List (defdef), _) = desugar.makeClosure(tparams, inferredVParams, body, resultTpt, tree.span)
1954
+ defdef.putAttachment(PolyFunctionApply , ())
1955
1955
typed(desugared, pt)
1956
1956
else
1957
1957
val msg =
1958
1958
em """ |Provided polymorphic function value doesn't match the expected type $dpt.
1959
1959
|Expected type should be a polymorphic function with the same number of type and value parameters. """
1960
1960
errorTree(EmptyTree , msg, tree.srcPos)
1961
1961
case _ =>
1962
- val desugared = desugar.makeClosure(tparams, vparams, body, untpd.TypeTree (), tree.span)
1962
+ val desugared @ Block (List (defdef), _) = desugar.makeClosure(tparams, vparams, body, untpd.TypeTree (), tree.span)
1963
+ defdef.putAttachment(PolyFunctionApply , ())
1963
1964
typed(desugared, pt)
1964
1965
end typedPolyFunctionValue
1965
1966
@@ -2456,12 +2457,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2456
2457
if tycon.tpe.typeParams.nonEmpty then
2457
2458
val tycon0 = tycon.withType(tycon.tpe.etaCollapse)
2458
2459
typed(untpd.AppliedTypeTree (spliced(tycon0), tparam :: Nil ))
2459
- else if Feature .enabled(Feature . modularity) && tycon.tpe.member(tpnme.Self ).symbol.isAbstractOrParamType then
2460
+ else if Feature .enabled(modularity) && tycon.tpe.member(tpnme.Self ).symbol.isAbstractOrParamType then
2460
2461
val tparamSplice = untpd.TypedSplice (typedExpr(tparam))
2461
2462
typed(untpd.RefinedTypeTree (spliced(tycon), List (untpd.TypeDef (tpnme.Self , tparamSplice))))
2462
2463
else
2463
2464
def selfNote =
2464
- if Feature .enabled(Feature . modularity) then
2465
+ if Feature .enabled(modularity) then
2465
2466
" and\n does not have an abstract type member named `Self` either"
2466
2467
else " "
2467
2468
errorTree(tree,
@@ -3610,6 +3611,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3610
3611
3611
3612
protected def makeContextualFunction (tree : untpd.Tree , pt : Type )(using Context ): Tree = {
3612
3613
val defn .FunctionOf (formals, _, true ) = pt.dropDependentRefinement: @ unchecked
3614
+ println(i " make contextual function $tree / $pt" )
3613
3615
val paramNamesOrNil = pt match
3614
3616
case RefinedType (_, _, rinfo : MethodType ) => rinfo.paramNames
3615
3617
case _ => Nil
@@ -4710,7 +4712,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4710
4712
cpy.Ident (qual)(qual.symbol.name.sourceModuleName.toTypeName)
4711
4713
case _ =>
4712
4714
errorTree(tree, em " cannot convert from $tree to an instance creation expression " )
4713
- val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature .enabled(Feature . modularity))
4715
+ val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature .enabled(modularity))
4714
4716
typed(
4715
4717
untpd.Select (
4716
4718
untpd.New (untpd.TypedSplice (tpt.withType(tycon))),
0 commit comments