@@ -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
@@ -1142,7 +1143,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1142
1143
if templ1.parents.isEmpty
1143
1144
&& isFullyDefined(pt, ForceDegree .flipBottom)
1144
1145
&& isSkolemFree(pt)
1145
- && isEligible(pt.underlyingClassRef(refinementOK = Feature .enabled(Feature . modularity)))
1146
+ && isEligible(pt.underlyingClassRef(refinementOK = Feature .enabled(modularity)))
1146
1147
then
1147
1148
templ1 = cpy.Template (templ)(parents = untpd.TypeTree (pt) :: Nil )
1148
1149
for case parent : RefTree <- templ1.parents do
@@ -1717,11 +1718,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1717
1718
typedFunctionType(desugar.makeFunctionWithValDefs(tree, pt), pt)
1718
1719
else
1719
1720
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)
1725
1726
// if there are any erased classes, we need to re-do the typecheck.
1726
1727
result match
1727
1728
case r : AppliedTypeTree if r.args.exists(_.tpe.isErasedClass) =>
@@ -1920,10 +1921,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1920
1921
1921
1922
def typedPolyFunction (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
1922
1923
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)
1927
1926
1928
1927
def typedPolyFunctionValue (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
1929
1928
val untpd .PolyFunction (tparams : List [untpd.TypeDef ] @ unchecked, fun) = tree : @ unchecked
@@ -1948,15 +1947,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1948
1947
val resultTpt =
1949
1948
untpd.InLambdaTypeTree (isResult = true , (tsyms, vsyms) =>
1950
1949
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 , ())
1952
1952
typed(desugared, pt)
1953
1953
else
1954
1954
val msg =
1955
1955
em """ |Provided polymorphic function value doesn't match the expected type $dpt.
1956
1956
|Expected type should be a polymorphic function with the same number of type and value parameters. """
1957
1957
errorTree(EmptyTree , msg, tree.srcPos)
1958
1958
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 , ())
1960
1961
typed(desugared, pt)
1961
1962
end typedPolyFunctionValue
1962
1963
@@ -2453,12 +2454,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2453
2454
if tycon.tpe.typeParams.nonEmpty then
2454
2455
val tycon0 = tycon.withType(tycon.tpe.etaCollapse)
2455
2456
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
2457
2458
val tparamSplice = untpd.TypedSplice (typedExpr(tparam))
2458
2459
typed(untpd.RefinedTypeTree (spliced(tycon), List (untpd.TypeDef (tpnme.Self , tparamSplice))))
2459
2460
else
2460
2461
def selfNote =
2461
- if Feature .enabled(Feature . modularity) then
2462
+ if Feature .enabled(modularity) then
2462
2463
" and\n does not have an abstract type member named `Self` either"
2463
2464
else " "
2464
2465
errorTree(tree,
@@ -3607,6 +3608,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3607
3608
3608
3609
protected def makeContextualFunction (tree : untpd.Tree , pt : Type )(using Context ): Tree = {
3609
3610
val defn .FunctionOf (formals, _, true ) = pt.dropDependentRefinement: @ unchecked
3611
+ println(i " make contextual function $tree / $pt" )
3610
3612
val paramNamesOrNil = pt match
3611
3613
case RefinedType (_, _, rinfo : MethodType ) => rinfo.paramNames
3612
3614
case _ => Nil
@@ -4705,7 +4707,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4705
4707
cpy.Ident (qual)(qual.symbol.name.sourceModuleName.toTypeName)
4706
4708
case _ =>
4707
4709
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))
4709
4711
typed(
4710
4712
untpd.Select (
4711
4713
untpd.New (untpd.TypedSplice (tpt.withType(tycon))),
0 commit comments