@@ -40,7 +40,7 @@ import annotation.tailrec
4040import Implicits .*
4141import util .Stats .record
4242import config .Printers .{gadts , typr }
43- import config .Feature , Feature .{migrateTo3 , sourceVersion , warnOnMigration }
43+ import config .Feature , Feature .{migrateTo3 , modularity , sourceVersion , warnOnMigration }
4444import config .SourceVersion .*
4545import rewrites .Rewrites , Rewrites .patch
4646import staging .StagingLevel
@@ -53,6 +53,7 @@ import config.MigrationVersion
5353import transform .CheckUnused .OriginalName
5454
5555import scala .annotation .constructorOnly
56+ import dotty .tools .dotc .ast .desugar .PolyFunctionApply
5657
5758object Typer {
5859
@@ -1142,7 +1143,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
11421143 if templ1.parents.isEmpty
11431144 && isFullyDefined(pt, ForceDegree .flipBottom)
11441145 && isSkolemFree(pt)
1145- && isEligible(pt.underlyingClassRef(refinementOK = Feature .enabled(Feature . modularity)))
1146+ && isEligible(pt.underlyingClassRef(refinementOK = Feature .enabled(modularity)))
11461147 then
11471148 templ1 = cpy.Template (templ)(parents = untpd.TypeTree (pt) :: Nil )
11481149 for case parent : RefTree <- templ1.parents do
@@ -1717,11 +1718,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
17171718 typedFunctionType(desugar.makeFunctionWithValDefs(tree, pt), pt)
17181719 else
17191720 val funSym = defn.FunctionSymbol (numArgs, isContextual, isImpure)
1720- val args1 = args.mapConserve {
1721- case cb : untpd.ContextBoundTypeTree => typed(cb)
1722- case t => t
1723- }
1724- val result = typed(cpy.AppliedTypeTree (tree)(untpd.TypeTree (funSym.typeRef), args1 :+ body), pt)
1721+ // val args1 = args.mapConserve {
1722+ // case cb: untpd.ContextBoundTypeTree => typed(cb)
1723+ // case t => t
1724+ // }
1725+ val result = typed(cpy.AppliedTypeTree (tree)(untpd.TypeTree (funSym.typeRef), args :+ body), pt)
17251726 // if there are any erased classes, we need to re-do the typecheck.
17261727 result match
17271728 case r : AppliedTypeTree if r.args.exists(_.tpe.isErasedClass) =>
@@ -1920,10 +1921,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19201921
19211922 def typedPolyFunction (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
19221923 val tree1 = desugar.normalizePolyFunction(tree)
1923- val tree2 = if Feature .enabled(Feature .modularity) then desugar.expandPolyFunctionContextBounds(tree1)
1924- else tree1
1925- if (ctx.mode is Mode .Type ) typed(desugar.makePolyFunctionType(tree2), pt)
1926- else typedPolyFunctionValue(tree2, pt)
1924+ if (ctx.mode is Mode .Type ) typed(desugar.makePolyFunctionType(tree1), pt)
1925+ else typedPolyFunctionValue(tree1, pt)
19271926
19281927 def typedPolyFunctionValue (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
19291928 val untpd .PolyFunction (tparams : List [untpd.TypeDef ] @ unchecked, fun) = tree : @ unchecked
@@ -1948,15 +1947,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19481947 val resultTpt =
19491948 untpd.InLambdaTypeTree (isResult = true , (tsyms, vsyms) =>
19501949 mt.resultType.substParams(mt, vsyms.map(_.termRef)).substParams(poly, tsyms.map(_.typeRef)))
1951- val desugared = desugar.makeClosure(tparams, inferredVParams, body, resultTpt, tree.span)
1950+ val desugared @ Block (List (defdef), _) = desugar.makeClosure(tparams, inferredVParams, body, resultTpt, tree.span)
1951+ defdef.putAttachment(PolyFunctionApply , ())
19521952 typed(desugared, pt)
19531953 else
19541954 val msg =
19551955 em """ |Provided polymorphic function value doesn't match the expected type $dpt.
19561956 |Expected type should be a polymorphic function with the same number of type and value parameters. """
19571957 errorTree(EmptyTree , msg, tree.srcPos)
19581958 case _ =>
1959- val desugared = desugar.makeClosure(tparams, vparams, body, untpd.TypeTree (), tree.span)
1959+ val desugared @ Block (List (defdef), _) = desugar.makeClosure(tparams, vparams, body, untpd.TypeTree (), tree.span)
1960+ defdef.putAttachment(PolyFunctionApply , ())
19601961 typed(desugared, pt)
19611962 end typedPolyFunctionValue
19621963
@@ -2453,12 +2454,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
24532454 if tycon.tpe.typeParams.nonEmpty then
24542455 val tycon0 = tycon.withType(tycon.tpe.etaCollapse)
24552456 typed(untpd.AppliedTypeTree (spliced(tycon0), tparam :: Nil ))
2456- else if Feature .enabled(Feature . modularity) && tycon.tpe.member(tpnme.Self ).symbol.isAbstractOrParamType then
2457+ else if Feature .enabled(modularity) && tycon.tpe.member(tpnme.Self ).symbol.isAbstractOrParamType then
24572458 val tparamSplice = untpd.TypedSplice (typedExpr(tparam))
24582459 typed(untpd.RefinedTypeTree (spliced(tycon), List (untpd.TypeDef (tpnme.Self , tparamSplice))))
24592460 else
24602461 def selfNote =
2461- if Feature .enabled(Feature . modularity) then
2462+ if Feature .enabled(modularity) then
24622463 " and\n does not have an abstract type member named `Self` either"
24632464 else " "
24642465 errorTree(tree,
@@ -3607,6 +3608,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
36073608
36083609 protected def makeContextualFunction (tree : untpd.Tree , pt : Type )(using Context ): Tree = {
36093610 val defn .FunctionOf (formals, _, true ) = pt.dropDependentRefinement: @ unchecked
3611+ println(i " make contextual function $tree / $pt" )
36103612 val paramNamesOrNil = pt match
36113613 case RefinedType (_, _, rinfo : MethodType ) => rinfo.paramNames
36123614 case _ => Nil
@@ -4705,7 +4707,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
47054707 cpy.Ident (qual)(qual.symbol.name.sourceModuleName.toTypeName)
47064708 case _ =>
47074709 errorTree(tree, em " cannot convert from $tree to an instance creation expression " )
4708- val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature .enabled(Feature . modularity))
4710+ val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature .enabled(modularity))
47094711 typed(
47104712 untpd.Select (
47114713 untpd.New (untpd.TypedSplice (tpt.withType(tycon))),
0 commit comments