Skip to content

Commit f9dde9a

Browse files
author
Aggelos Biboudis
authored
Merge pull request #5815 from dotty-staging/fix-#4539
Fix #4539: Add missing `'[` in canStartExpressionTokens
2 parents 05cdff8 + 5ce03a6 commit f9dde9a

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ object Tokens extends TokensCommon {
215215
USCORE, NULL, THIS, SUPER, TRUE, FALSE, RETURN, XMLSTART)
216216

217217
final val canStartExpressionTokens: TokenSet = atomicExprTokens | BitSet(
218-
LBRACE, LPAREN, QBRACE, QPAREN, IF, DO, WHILE, FOR, NEW, TRY, THROW)
218+
LBRACE, LPAREN, QBRACE, QPAREN, QBRACKET, IF, DO, WHILE, FOR, NEW, TRY, THROW)
219219

220220
final val canStartTypeTokens: TokenSet = literalTokens | identifierTokens | BitSet(
221221
THIS, SUPER, USCORE, LPAREN, AT)

compiler/test-resources/repl/i4539

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
scala> val a = '[Int]
2+
val a: quoted.Type[Int] = Type(Int)
3+
scala> '[Int]
4+
val res0: quoted.Type[Int] = Type(Int)
5+
scala> '[Int]; '[Int]
6+
val res1: quoted.Type[Int] = Type(Int)
7+
val res2: quoted.Type[Int] = Type(Int)

tests/pos/i4539.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Foo {
2+
val q = '[String]
3+
'[String]
4+
}

tests/pos/i4539b.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
object Foo {
2+
def f = {
3+
{
4+
'[String]
5+
'[String]
6+
}
7+
8+
'[String] match { case _ => }
9+
try '[String] catch { case _ => }
10+
11+
'[String]
12+
'[String]
13+
}
14+
15+
def bar[T](t: quoted.Type[T]) = ???
16+
bar('[String])
17+
18+
class Baz[T](t: quoted.Type[T])
19+
new Baz('[String])
20+
21+
}

0 commit comments

Comments
 (0)