@@ -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) =>
@@ -1930,10 +1931,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1930
1931
1931
1932
def typedPolyFunction (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
1932
1933
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)
1937
1936
1938
1937
def typedPolyFunctionValue (tree : untpd.PolyFunction , pt : Type )(using Context ): Tree =
1939
1938
val untpd .PolyFunction (tparams : List [untpd.TypeDef ] @ unchecked, fun) = tree : @ unchecked
@@ -1958,15 +1957,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1958
1957
val resultTpt =
1959
1958
untpd.InLambdaTypeTree (isResult = true , (tsyms, vsyms) =>
1960
1959
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 , ())
1962
1962
typed(desugared, pt)
1963
1963
else
1964
1964
val msg =
1965
1965
em """ |Provided polymorphic function value doesn't match the expected type $dpt.
1966
1966
|Expected type should be a polymorphic function with the same number of type and value parameters. """
1967
1967
errorTree(EmptyTree , msg, tree.srcPos)
1968
1968
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 , ())
1970
1971
typed(desugared, pt)
1971
1972
end typedPolyFunctionValue
1972
1973
@@ -2463,12 +2464,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2463
2464
if tycon.tpe.typeParams.nonEmpty then
2464
2465
val tycon0 = tycon.withType(tycon.tpe.etaCollapse)
2465
2466
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
2467
2468
val tparamSplice = untpd.TypedSplice (typedExpr(tparam))
2468
2469
typed(untpd.RefinedTypeTree (spliced(tycon), List (untpd.TypeDef (tpnme.Self , tparamSplice))))
2469
2470
else
2470
2471
def selfNote =
2471
- if Feature .enabled(Feature . modularity) then
2472
+ if Feature .enabled(modularity) then
2472
2473
" and\n does not have an abstract type member named `Self` either"
2473
2474
else " "
2474
2475
errorTree(tree,
@@ -3602,6 +3603,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3602
3603
3603
3604
protected def makeContextualFunction (tree : untpd.Tree , pt : Type )(using Context ): Tree = {
3604
3605
val defn .FunctionOf (formals, _, true ) = pt.dropDependentRefinement: @ unchecked
3606
+ println(i " make contextual function $tree / $pt" )
3605
3607
val paramNamesOrNil = pt match
3606
3608
case RefinedType (_, _, rinfo : MethodType ) => rinfo.paramNames
3607
3609
case _ => Nil
@@ -4697,7 +4699,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4697
4699
cpy.Ident (qual)(qual.symbol.name.sourceModuleName.toTypeName)
4698
4700
case _ =>
4699
4701
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))
4701
4703
typed(
4702
4704
untpd.Select (
4703
4705
untpd.New (untpd.TypedSplice (tpt.withType(tycon))),
0 commit comments