@@ -33,6 +33,8 @@ object Parsers {
3333 import reporting .Message
3434 import reporting .messages ._
3535
36+ val AllowOldWhiteboxSyntax = true
37+
3638 case class OpInfo (operand : Tree , operator : Ident , offset : Offset )
3739
3840 class ParensCounters {
@@ -2692,6 +2694,7 @@ object Parsers {
26922694 case nme.inline => Mod .Inline ()
26932695 case nme.opaque => Mod .Opaque ()
26942696 case nme.open => Mod .Open ()
2697+ case nme.transparent => Mod .Transparent ()
26952698 }
26962699 }
26972700
@@ -2748,7 +2751,7 @@ object Parsers {
27482751 * | AccessModifier
27492752 * | override
27502753 * | opaque
2751- * LocalModifier ::= abstract | final | sealed | open | implicit | lazy | erased | inline
2754+ * LocalModifier ::= abstract | final | sealed | open | implicit | lazy | erased | inline | transparent
27522755 */
27532756 def modifiers (allowed : BitSet = modifierTokens, start : Modifiers = Modifiers ()): Modifiers = {
27542757 @ tailrec
@@ -2766,7 +2769,11 @@ object Parsers {
27662769 }
27672770 else
27682771 mods
2769- normalize(loop(start))
2772+ val result = normalize(loop(start))
2773+ for case mod @ Mod .Transparent () <- result.mods do
2774+ if ! result.is(Inline ) then
2775+ syntaxError(em " `transparent` can only be used in conjunction with `inline` " , mod.span)
2776+ result
27702777 }
27712778
27722779 val funTypeArgMods : BitSet = BitSet (ERASED )
@@ -3248,9 +3255,10 @@ object Parsers {
32483255 case rparamss =>
32493256 leadingVparamss ::: rparamss
32503257 var tpt = fromWithinReturnType {
3251- if in.token == SUBTYPE && mods.is(Inline ) then
3258+ if in.token == SUBTYPE && mods.is(Inline ) && AllowOldWhiteboxSyntax then
32523259 in.nextToken()
3253- TypeBoundsTree (EmptyTree , toplevelTyp())
3260+ mods1 = addMod(mods1, Mod .Transparent ())
3261+ toplevelTyp()
32543262 else typedOpt()
32553263 }
32563264 if (in.isScala2CompatMode) newLineOptWhenFollowedBy(LBRACE )
@@ -3516,12 +3524,13 @@ object Parsers {
35163524 accept(EQUALS )
35173525 mods1 |= Final
35183526 DefDef (name, tparams, vparamss, tpt, subExpr())
3519- if in.token == USCORE then
3527+ if in.token == USCORE && AllowOldWhiteboxSyntax then
35203528 if ! mods.is(Inline ) then
35213529 syntaxError(" `_ <:` is only allowed for given with `inline` modifier" )
35223530 in.nextToken()
35233531 accept(SUBTYPE )
3524- givenAlias(TypeBoundsTree (EmptyTree , toplevelTyp()))
3532+ mods1 = addMod(mods1, Mod .Transparent ())
3533+ givenAlias(toplevelTyp())
35253534 else
35263535 val parents = constrApps(commaOK = true , templateCanFollow = true )
35273536 if in.token == EQUALS && parents.length == 1 && parents.head.isType then
0 commit comments