Skip to content

Commit 134c015

Browse files
committed
Hide context bounds expansion for poly functions under modularity feature
1 parent 408aa74 commit 134c015

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

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

+4-2
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

@@ -3460,7 +3460,9 @@ object Parsers {
34603460
else ident().toTypeName
34613461
val hkparams = typeParamClauseOpt(ParamOwner.Hk)
34623462
val bounds =
3463-
if paramOwner.acceptsCtxBounds then typeAndCtxBounds(name) else typeBounds()
3463+
if paramOwner.acceptsCtxBounds then typeAndCtxBounds(name)
3464+
else if in.featureEnabled(Feature.modularity) && paramOwner == ParamOwner.Type then typeAndCtxBounds(name)
3465+
else typeBounds()
34643466
TypeDef(name, lambdaAbstract(hkparams, bounds)).withMods(mods)
34653467
}
34663468
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19231923

19241924
def typedPolyFunction(tree: untpd.PolyFunction, pt: Type)(using Context): Tree =
19251925
val tree1 = desugar.normalizePolyFunction(tree)
1926-
val tree2 = desugar.expandPolyFunctionContextBounds(tree1)
1926+
val tree2 = if Feature.enabled(Feature.modularity) then desugar.expandPolyFunctionContextBounds(tree1)
1927+
else tree1
19271928
if (ctx.mode is Mode.Type) typed(desugar.makePolyFunctionType(tree2), pt)
19281929
else typedPolyFunctionValue(tree2, pt)
19291930

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

-1
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)