@@ -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) =>
@@ -1930,10 +1931,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19301931
19311932 def typedPolyFunction (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
19321933 val tree1 = desugar.normalizePolyFunction(tree)
1933- val tree2 = if Feature .enabled(Feature .modularity) then desugar.expandPolyFunctionContextBounds(tree1)
1934- else tree1
1935- if (ctx.mode is Mode .Type ) typed(desugar.makePolyFunctionType(tree2), pt)
1936- else typedPolyFunctionValue(tree2, pt)
1934+ if (ctx.mode is Mode .Type ) typed(desugar.makePolyFunctionType(tree1), pt)
1935+ else typedPolyFunctionValue(tree1, pt)
19371936
19381937 def typedPolyFunctionValue (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
19391938 val untpd .PolyFunction (tparams : List [untpd.TypeDef ] @ unchecked, fun) = tree : @ unchecked
@@ -1958,15 +1957,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19581957 val resultTpt =
19591958 untpd.InLambdaTypeTree (isResult = true , (tsyms, vsyms) =>
19601959 mt.resultType.substParams(mt, vsyms.map(_.termRef)).substParams(poly, tsyms.map(_.typeRef)))
1961- val desugared = desugar.makeClosure(tparams, inferredVParams, body, resultTpt, tree.span)
1960+ val desugared @ Block (List (defdef), _) = desugar.makeClosure(tparams, inferredVParams, body, resultTpt, tree.span)
1961+ defdef.putAttachment(PolyFunctionApply , ())
19621962 typed(desugared, pt)
19631963 else
19641964 val msg =
19651965 em """ |Provided polymorphic function value doesn't match the expected type $dpt.
19661966 |Expected type should be a polymorphic function with the same number of type and value parameters. """
19671967 errorTree(EmptyTree , msg, tree.srcPos)
19681968 case _ =>
1969- val desugared = desugar.makeClosure(tparams, vparams, body, untpd.TypeTree (), tree.span)
1969+ val desugared @ Block (List (defdef), _) = desugar.makeClosure(tparams, vparams, body, untpd.TypeTree (), tree.span)
1970+ defdef.putAttachment(PolyFunctionApply , ())
19701971 typed(desugared, pt)
19711972 end typedPolyFunctionValue
19721973
@@ -2463,12 +2464,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
24632464 if tycon.tpe.typeParams.nonEmpty then
24642465 val tycon0 = tycon.withType(tycon.tpe.etaCollapse)
24652466 typed(untpd.AppliedTypeTree (spliced(tycon0), tparam :: Nil ))
2466- else if Feature .enabled(Feature . modularity) && tycon.tpe.member(tpnme.Self ).symbol.isAbstractOrParamType then
2467+ else if Feature .enabled(modularity) && tycon.tpe.member(tpnme.Self ).symbol.isAbstractOrParamType then
24672468 val tparamSplice = untpd.TypedSplice (typedExpr(tparam))
24682469 typed(untpd.RefinedTypeTree (spliced(tycon), List (untpd.TypeDef (tpnme.Self , tparamSplice))))
24692470 else
24702471 def selfNote =
2471- if Feature .enabled(Feature . modularity) then
2472+ if Feature .enabled(modularity) then
24722473 " and\n does not have an abstract type member named `Self` either"
24732474 else " "
24742475 errorTree(tree,
@@ -3602,6 +3603,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
36023603
36033604 protected def makeContextualFunction (tree : untpd.Tree , pt : Type )(using Context ): Tree = {
36043605 val defn .FunctionOf (formals, _, true ) = pt.dropDependentRefinement: @ unchecked
3606+ println(i " make contextual function $tree / $pt" )
36053607 val paramNamesOrNil = pt match
36063608 case RefinedType (_, _, rinfo : MethodType ) => rinfo.paramNames
36073609 case _ => Nil
@@ -4697,7 +4699,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
46974699 cpy.Ident (qual)(qual.symbol.name.sourceModuleName.toTypeName)
46984700 case _ =>
46994701 errorTree(tree, em " cannot convert from $tree to an instance creation expression " )
4700- val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature .enabled(Feature . modularity))
4702+ val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature .enabled(modularity))
47014703 typed(
47024704 untpd.Select (
47034705 untpd.New (untpd.TypedSplice (tpt.withType(tycon))),
0 commit comments