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 {
67
67
this == Given || this == ExtensionFollow
68
68
def acceptsVariance =
69
69
this == Class || this == CaseClass || this == Type
70
-
71
70
end ParamOwner
72
71
73
72
enum ParseKind :
@@ -3283,7 +3282,7 @@ object Parsers {
3283
3282
ok
3284
3283
3285
3284
def typeParam (): TypeDef = {
3286
- val isAbstractOwner = paramOwner == ParamOwner .Type || paramOwner == ParamOwner .TypeParam
3285
+ val isAbstractOwner = ( paramOwner == ParamOwner .Type || paramOwner == ParamOwner .TypeParam )
3287
3286
val start = in.offset
3288
3287
var mods = annotsAsMods() | Param
3289
3288
if paramOwner == ParamOwner .Class || paramOwner == ParamOwner .CaseClass then
@@ -3304,7 +3303,13 @@ object Parsers {
3304
3303
}
3305
3304
else ident().toTypeName
3306
3305
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
3308
3313
TypeDef (name, lambdaAbstract(hkparams, bounds)).withMods(mods)
3309
3314
}
3310
3315
}
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
225
225
case FormatInterpolationErrorID // errorNumber: 209
226
226
case ValueClassCannotExtendAliasOfAnyValID // errorNumber: 210
227
227
case MatchIsNotPartialFunctionID // errorNumber: 211
228
+ case OnlyFullyDependentAppliedConstructorTypeID // errorNumber: 212
229
+ case PointlessAppliedConstructorTypeID // errorNumber: 213
230
+ case IllegalContextBoundsID // errorNumber: 214
228
231
229
232
def errorNumber = ordinal - 1
230
233
Original file line number Diff line number Diff line change @@ -3255,3 +3255,11 @@ class MatchIsNotPartialFunction(using Context) extends SyntaxMsg(MatchIsNotParti
3255
3255
|
3256
3256
|Efficient operations will use `applyOrElse` to avoid computing the match twice,
3257
3257
|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 --------------------------------------------------------------------
2
2
3 | 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 --------------------------------------------------------------------
6
6
4 | 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 --------------------------------------------------------------------
10
10
5 | 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