File tree 3 files changed +21
-6
lines changed
compiler/src/dotty/tools/dotc
3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -768,9 +768,16 @@ object Parsers {
768
768
accept(RPAREN )
769
769
if (imods.is(Implicit ) || isValParamList || in.token == ARROW ) functionRest(ts)
770
770
else {
771
- for (t <- ts)
772
- if (t.isInstanceOf [ByNameTypeTree ])
773
- syntaxError(ByNameParameterNotSupported ())
771
+ val ts1 =
772
+ for (t <- ts) yield {
773
+ t match {
774
+ case t@ ByNameTypeTree (t1) =>
775
+ syntaxError(ByNameParameterNotSupported (t), t.pos)
776
+ t1
777
+ case _ =>
778
+ t
779
+ }
780
+ }
774
781
val tuple = atPos(start) { makeTupleOrParens(ts) }
775
782
infixTypeRest(
776
783
refinedTypeRest(
Original file line number Diff line number Diff line change @@ -696,10 +696,10 @@ object messages {
696
696
}
697
697
}
698
698
699
- case class ByNameParameterNotSupported ()(implicit ctx : Context )
699
+ case class ByNameParameterNotSupported (tpe : untpd. TypTree )(implicit ctx : Context )
700
700
extends Message (ByNameParameterNotSupportedID ) {
701
701
val kind = " Syntax"
702
- val msg = " By-name parameter type not allowed here."
702
+ val msg = hl " By-name parameter type ${tpe} not allowed here. "
703
703
704
704
val explanation =
705
705
hl """ |By-name parameters act like functions that are only evaluated when referenced,
Original file line number Diff line number Diff line change @@ -21,5 +21,13 @@ object Test {
21
21
22
22
// Open questions:
23
23
type T5 = TypeConstr [_ { type S }] // error
24
- type T5 = TypeConstr [_[Int ]] // error
24
+ type T6 = TypeConstr [_[Int ]] // error
25
+
26
+ // expression types
27
+ type T7 = (=> Int ) | (Int => Int ) // error
28
+ type T8 = (=> Int ) & (Int => Int ) // error
29
+ type T9 = (=> Int ) with (Int => Int ) // error
30
+ type T10 = (Int => Int ) | (=> Int ) // error
31
+ type T11 = (Int => Int ) & (=> Int ) // error
32
+ type T12 = (Int => Int ) with (=> Int ) // error
25
33
}
You can’t perform that action at this time.
0 commit comments