File tree Expand file tree Collapse file tree 6 files changed +34
-12
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 6 files changed +34
-12
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,6 @@ object Parsers {
6767 this == Given || this == ExtensionFollow
6868 def acceptsVariance =
6969 this == Class || this == CaseClass || this == Type
70-
7170 end ParamOwner
7271
7372 enum ParseKind :
@@ -3283,7 +3282,7 @@ object Parsers {
32833282 ok
32843283
32853284 def typeParam (): TypeDef = {
3286- val isAbstractOwner = paramOwner == ParamOwner .Type || paramOwner == ParamOwner .TypeParam
3285+ val isAbstractOwner = ( paramOwner == ParamOwner .Type || paramOwner == ParamOwner .TypeParam )
32873286 val start = in.offset
32883287 var mods = annotsAsMods() | Param
32893288 if paramOwner == ParamOwner .Class || paramOwner == ParamOwner .CaseClass then
@@ -3304,7 +3303,13 @@ object Parsers {
33043303 }
33053304 else ident().toTypeName
33063305 val hkparams = typeParamClauseOpt(ParamOwner .Type )
3307- val bounds = if (isAbstractOwner) typeBounds() else typeParamBounds(name)
3306+ // val bounds = if (isAbstractOwner) typeBounds() else typeParamBounds(name)
3307+ val bounds = typeParamBounds(name) match
3308+ case bounds : TypeBoundsTree => bounds
3309+ case bounds : ContextBounds if ! isAbstractOwner => bounds
3310+ case ContextBounds (bounds, cxBounds) =>
3311+ for cbound <- cxBounds do report.error(IllegalContextBounds (), cbound.srcPos)
3312+ bounds
33083313 TypeDef (name, lambdaAbstract(hkparams, bounds)).withMods(mods)
33093314 }
33103315 }
Original file line number Diff line number Diff line change @@ -225,6 +225,9 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe
225225 case FormatInterpolationErrorID // errorNumber: 209
226226 case ValueClassCannotExtendAliasOfAnyValID // errorNumber: 210
227227 case MatchIsNotPartialFunctionID // errorNumber: 211
228+ case OnlyFullyDependentAppliedConstructorTypeID // errorNumber: 212
229+ case PointlessAppliedConstructorTypeID // errorNumber: 213
230+ case IllegalContextBoundsID // errorNumber: 214
228231
229232 def errorNumber = ordinal - 1
230233
Original file line number Diff line number Diff line change @@ -3255,3 +3255,11 @@ class MatchIsNotPartialFunction(using Context) extends SyntaxMsg(MatchIsNotParti
32553255 |
32563256 |Efficient operations will use `applyOrElse` to avoid computing the match twice,
32573257 |but the `apply` body would be executed "per element" in the example. """
3258+
3259+ final class IllegalContextBounds (using Context ) extends SyntaxMsg (IllegalContextBoundsID ):
3260+ override protected def msg (using Context ): String =
3261+ i " Context bounds are not allowed in this position "
3262+
3263+ override protected def explain (using Context ): String = " "
3264+
3265+ end IllegalContextBounds
Original file line number Diff line number Diff line change 1- -- [E040 ] Syntax Error: tests/neg/i22552.scala:3:10 --------------------------------------------------------------------
1+ -- [E214 ] Syntax Error: tests/neg/i22552.scala:3:10 --------------------------------------------------------------------
223 | type A[X: TC] // error
3- | ^
4- | ']' expected, but ':' found
5- -- [E040 ] Syntax Error: tests/neg/i22552.scala:4:13 --------------------------------------------------------------------
3+ | ^^^^
4+ | Context bounds are not allowed in this position
5+ -- [E214 ] Syntax Error: tests/neg/i22552.scala:4:13 --------------------------------------------------------------------
664 | type C = [X: TC] =>> List[X] // error
7- | ^
8- | ']' expected, but ':' found
9- -- [E040 ] Syntax Error: tests/neg/i22552.scala:5:13 --------------------------------------------------------------------
7+ | ^^^^
8+ | Context bounds are not allowed in this position
9+ -- [E214 ] Syntax Error: tests/neg/i22552.scala:5:13 --------------------------------------------------------------------
10105 | type D = [X: TC] => () => List[X] // error
11- | ^
12- | ']' expected, but ':' found
11+ | ^^^^
12+ | Context bounds are not allowed in this position
Original file line number Diff line number Diff line change 1+ -- [E214] Syntax Error: tests/neg/i22660.scala:2:10 --------------------------------------------------------------------
2+ 2 |type Foo[T: Equatable] // error
3+ | ^^^^^^^^^^^
4+ | Context bounds are not allowed in this position
Original file line number Diff line number Diff line change 1+ trait Equatable [T ]
2+ type Foo [T : Equatable ] // error
You can’t perform that action at this time.
0 commit comments