diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index fe6c8b7ba9dd..e1d2a44982f5 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -27,7 +27,7 @@ import util.Chars import scala.annotation.{tailrec, switch} import rewrites.Rewrites.{patch, overlapsPatch} import reporting._ -import config.Feature.{sourceVersion, migrateTo3} +import config.Feature.{sourceVersion, migrateTo3, dependentEnabled} import config.SourceVersion._ import config.SourceVersion @@ -1613,7 +1613,7 @@ object Parsers { typeIdent() else def singletonArgs(t: Tree): Tree = - if in.token == LPAREN + if in.token == LPAREN && dependentEnabled then singletonArgs(AppliedTypeTree(t, inParens(commaSeparated(singleton)))) else t singletonArgs(simpleType1()) diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 2515b5865b35..b431f15b2944 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -163,6 +163,7 @@ class CompilationTests { compileFile("tests/neg-custom-args/kind-projector.scala", defaultOptions.and("-Ykind-projector")), compileFile("tests/neg-custom-args/typeclass-derivation2.scala", defaultOptions.and("-Yerased-terms")), compileFile("tests/neg-custom-args/i5498-postfixOps.scala", defaultOptions withoutLanguageFeature "postfixOps"), + compileFile("tests/neg-custom-args/deptypes.scala", defaultOptions.and("-language:experimental.dependent")), ).checkExpectedErrors() } diff --git a/library/src/scala/runtime/stdLibPatches/language.scala b/library/src/scala/runtime/stdLibPatches/language.scala index 30ce6f550c57..b9eec5d00eb6 100644 --- a/library/src/scala/runtime/stdLibPatches/language.scala +++ b/library/src/scala/runtime/stdLibPatches/language.scala @@ -18,8 +18,12 @@ object language: */ object experimental: - /** Experimental support for richer dependent types */ - object dependent + /* Experimental support for richer dependent types (disabled for now) + * One can still run the compiler with support for parsing singleton applications + * using command line option `-language:experimental.dependent`. + * But one cannot use a feature import for this as long as this entry is commented out. + */ + //object dependent /** Experimental support for named type arguments */ object namedTypeArguments diff --git a/tests/neg-custom-args/deptypes.scala b/tests/neg-custom-args/deptypes.scala new file mode 100644 index 000000000000..f01be10f2217 --- /dev/null +++ b/tests/neg-custom-args/deptypes.scala @@ -0,0 +1,10 @@ + +type Vec[T] = (n: Int) =>> Array[T] // error: not yet implemented + +type Matrix[T](m: Int, n: Int) = Vec[Vec[T](n)](m) // error: not yet implemented + +type Tensor2[T](m: Int)(n: Int) = Matrix[T](m, n) // error: not yet implemented + +val x: Vec[Int](10) = ??? // error: not yet implemented +val n = 10 +type T = Vec[String](n) // error: not yet implemented \ No newline at end of file diff --git a/tests/neg/deptypes.scala b/tests/neg/deptypes.scala deleted file mode 100644 index ee6d1c95c0f2..000000000000 --- a/tests/neg/deptypes.scala +++ /dev/null @@ -1,10 +0,0 @@ - -type Vec[T] = (n: Int) =>> Array[T] // error: needs to be enabled - -type Matrix[T](m: Int, n: Int) = Vec[Vec[T](n)](m) // error: needs to be enabled - -type Tensor2[T](m: Int)(n: Int) = Matrix[T](m, n) // error: needs to be enabled - -val x: Vec[Int](10) = ??? // error: needs to be enabled -val n = 10 -type T = Vec[String](n) // error: needs to be enabled \ No newline at end of file diff --git a/tests/neg/i10546.scala b/tests/neg/i10546.scala new file mode 100644 index 000000000000..33407872f77e --- /dev/null +++ b/tests/neg/i10546.scala @@ -0,0 +1,5 @@ +object test: + def times(num : Int)(block : => Unit) : Unit = () + times(10): println("ah") // error: end of statement expected but '(' found // error + + def foo: Set(Int) = Set(1) // error: end of statement expected but '(' found // error // error