Skip to content

Commit 054251e

Browse files
committed
Hide context bounds expansion for poly functions under modularity feature
1 parent 44af0d6 commit 054251e

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ object Parsers {
6868
def acceptsVariance =
6969
this == Class || this == CaseClass || this == Hk
7070
def acceptsCtxBounds =
71-
!(this == Hk)
71+
!(this == Type || this == Hk)
7272
def acceptsWildcard =
7373
this == Type || this == Hk
7474

@@ -3452,7 +3452,9 @@ object Parsers {
34523452
else ident().toTypeName
34533453
val hkparams = typeParamClauseOpt(ParamOwner.Hk)
34543454
val bounds =
3455-
if paramOwner.acceptsCtxBounds then typeAndCtxBounds(name) else typeBounds()
3455+
if paramOwner.acceptsCtxBounds then typeAndCtxBounds(name)
3456+
else if in.featureEnabled(Feature.modularity) && paramOwner == ParamOwner.Type then typeAndCtxBounds(name)
3457+
else typeBounds()
34563458
TypeDef(name, lambdaAbstract(hkparams, bounds)).withMods(mods)
34573459
}
34583460
}

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19301930

19311931
def typedPolyFunction(tree: untpd.PolyFunction, pt: Type)(using Context): Tree =
19321932
val tree1 = desugar.normalizePolyFunction(tree)
1933-
val tree2 = desugar.expandPolyFunctionContextBounds(tree1)
1933+
val tree2 = if Feature.enabled(Feature.modularity) then desugar.expandPolyFunctionContextBounds(tree1)
1934+
else tree1
19341935
if (ctx.mode is Mode.Type) typed(desugar.makePolyFunctionType(tree2), pt)
19351936
else typedPolyFunctionValue(tree2, pt)
19361937

tests/pos/contextbounds-for-poly-functions.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import scala.language.experimental.modularity
22
import scala.language.future
33

4-
54
trait Ord[X]:
65
def compare(x: X, y: X): Int
76

0 commit comments

Comments
 (0)