@@ -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
@@ -1145,7 +1146,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
11451146 if templ1.parents.isEmpty
11461147 && isFullyDefined(pt, ForceDegree .flipBottom)
11471148 && isSkolemFree(pt)
1148- && isEligible(pt.underlyingClassRef(refinementOK = Feature .enabled(Feature . modularity)))
1149+ && isEligible(pt.underlyingClassRef(refinementOK = Feature .enabled(modularity)))
11491150 then
11501151 templ1 = cpy.Template (templ)(parents = untpd.TypeTree (pt) :: Nil )
11511152 for case parent : RefTree <- templ1.parents do
@@ -1720,11 +1721,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
17201721 typedFunctionType(desugar.makeFunctionWithValDefs(tree, pt), pt)
17211722 else
17221723 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)
17281729 // if there are any erased classes, we need to re-do the typecheck.
17291730 result match
17301731 case r : AppliedTypeTree if r.args.exists(_.tpe.isErasedClass) =>
@@ -1923,10 +1924,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19231924
19241925 def typedPolyFunction (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
19251926 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)
19301929
19311930 def typedPolyFunctionValue (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
19321931 val untpd .PolyFunction (tparams : List [untpd.TypeDef ] @ unchecked, fun) = tree : @ unchecked
@@ -1951,15 +1950,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19511950 val resultTpt =
19521951 untpd.InLambdaTypeTree (isResult = true , (tsyms, vsyms) =>
19531952 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 , ())
19551955 typed(desugared, pt)
19561956 else
19571957 val msg =
19581958 em """ |Provided polymorphic function value doesn't match the expected type $dpt.
19591959 |Expected type should be a polymorphic function with the same number of type and value parameters. """
19601960 errorTree(EmptyTree , msg, tree.srcPos)
19611961 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 , ())
19631964 typed(desugared, pt)
19641965 end typedPolyFunctionValue
19651966
@@ -2456,12 +2457,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
24562457 if tycon.tpe.typeParams.nonEmpty then
24572458 val tycon0 = tycon.withType(tycon.tpe.etaCollapse)
24582459 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
24602461 val tparamSplice = untpd.TypedSplice (typedExpr(tparam))
24612462 typed(untpd.RefinedTypeTree (spliced(tycon), List (untpd.TypeDef (tpnme.Self , tparamSplice))))
24622463 else
24632464 def selfNote =
2464- if Feature .enabled(Feature . modularity) then
2465+ if Feature .enabled(modularity) then
24652466 " and\n does not have an abstract type member named `Self` either"
24662467 else " "
24672468 errorTree(tree,
@@ -3610,6 +3611,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
36103611
36113612 protected def makeContextualFunction (tree : untpd.Tree , pt : Type )(using Context ): Tree = {
36123613 val defn .FunctionOf (formals, _, true ) = pt.dropDependentRefinement: @ unchecked
3614+ println(i " make contextual function $tree / $pt" )
36133615 val paramNamesOrNil = pt match
36143616 case RefinedType (_, _, rinfo : MethodType ) => rinfo.paramNames
36153617 case _ => Nil
@@ -4710,7 +4712,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
47104712 cpy.Ident (qual)(qual.symbol.name.sourceModuleName.toTypeName)
47114713 case _ =>
47124714 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))
47144716 typed(
47154717 untpd.Select (
47164718 untpd.New (untpd.TypedSplice (tpt.withType(tycon))),
0 commit comments