Skip to content

Commit 44e13c3

Browse files
committed
Fix #10546: Parse singleton applications only under a command line flag
This now needs -language:experimental.dependent Fixes #10546. Fixes #10536.
1 parent 31751b9 commit 44e13c3

File tree

6 files changed

+24
-14
lines changed

6 files changed

+24
-14
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import util.Chars
2727
import scala.annotation.{tailrec, switch}
2828
import rewrites.Rewrites.{patch, overlapsPatch}
2929
import reporting._
30-
import config.Feature.{sourceVersion, migrateTo3}
30+
import config.Feature.{sourceVersion, migrateTo3, dependentEnabled}
3131
import config.SourceVersion._
3232
import config.SourceVersion
3333

@@ -1613,7 +1613,7 @@ object Parsers {
16131613
typeIdent()
16141614
else
16151615
def singletonArgs(t: Tree): Tree =
1616-
if in.token == LPAREN
1616+
if in.token == LPAREN && dependentEnabled
16171617
then singletonArgs(AppliedTypeTree(t, inParens(commaSeparated(singleton))))
16181618
else t
16191619
singletonArgs(simpleType1())

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class CompilationTests {
163163
compileFile("tests/neg-custom-args/kind-projector.scala", defaultOptions.and("-Ykind-projector")),
164164
compileFile("tests/neg-custom-args/typeclass-derivation2.scala", defaultOptions.and("-Yerased-terms")),
165165
compileFile("tests/neg-custom-args/i5498-postfixOps.scala", defaultOptions withoutLanguageFeature "postfixOps"),
166+
compileFile("tests/neg-custom-args/deptypes.scala", defaultOptions.and("-language:experimental.dependent")),
166167
).checkExpectedErrors()
167168
}
168169

library/src/scala/runtime/stdLibPatches/language.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ object language:
1818
*/
1919
object experimental:
2020

21-
/** Experimental support for richer dependent types */
22-
object dependent
21+
/* Experimental support for richer dependent types (disabled for now)
22+
* One can still run the compiler with support for parsing singleton applications
23+
* using command line option `-language:experimental.dependent`.
24+
* But one cannot use a feature import for this as long as this entry is commented out.
25+
*/
26+
//object dependent
2327

2428
/** Experimental support for named type arguments */
2529
object namedTypeArguments

tests/neg-custom-args/deptypes.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
type Vec[T] = (n: Int) =>> Array[T] // error: not yet implemented
3+
4+
type Matrix[T](m: Int, n: Int) = Vec[Vec[T](n)](m) // error: not yet implemented
5+
6+
type Tensor2[T](m: Int)(n: Int) = Matrix[T](m, n) // error: not yet implemented
7+
8+
val x: Vec[Int](10) = ??? // error: not yet implemented
9+
val n = 10
10+
type T = Vec[String](n) // error: not yet implemented

tests/neg/deptypes.scala

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/neg/i10546.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object test:
2+
def times(num : Int)(block : => Unit) : Unit = ()
3+
times(10): println("ah") // error: end of statement expected but '(' found // error
4+
5+
def foo: Set(Int) = Set(1) // error: end of statement expected but '(' found // error // error

0 commit comments

Comments
 (0)