Skip to content

Fix #10546: Parse singleton applications only under a command line flag #10574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
8 changes: 6 additions & 2 deletions library/src/scala/runtime/stdLibPatches/language.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/neg-custom-args/deptypes.scala
Original file line number Diff line number Diff line change
@@ -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
10 changes: 0 additions & 10 deletions tests/neg/deptypes.scala

This file was deleted.

5 changes: 5 additions & 0 deletions tests/neg/i10546.scala
Original file line number Diff line number Diff line change
@@ -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