Skip to content

merge variances and Variances #1193

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 2 commits into from
Mar 31, 2016
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 test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class tests extends CompilerTest {
val dotcDir = toolsDir + "dotc/"
val coreDir = dotcDir + "core/"
val parsingDir = dotcDir + "parsing/"
val replDir = dotcDir + "repl/"
val dottyReplDir = dotcDir + "repl/"
val typerDir = dotcDir + "typer/"

@Test def pickle_pickleOK = compileDir(testsDir, "pickling", testPickling)
Expand Down Expand Up @@ -254,7 +254,7 @@ class tests extends CompilerTest {
@Test def tasty_dotc_repl = compileList("tasty_dotc_repl", List(
"AbstractFileClassLoader.scala", "ConsoleWriter.scala", "InteractiveReader.scala",
"Interpreter.scala", "Main.scala", "NewLinePrintWriter.scala", "REPL.scala", "SimpleReader.scala"
) map (replDir + _), testPickling)
) map (dottyReplDir + _), testPickling)

//@Test def tasty_dotc_reporting = compileDir(dotcDir, "reporting", testPickling)
@Test def tasty_dotc_rewrite = compileDir(dotcDir, "rewrite", testPickling)
Expand Down
15 changes: 15 additions & 0 deletions tests/neg/variances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,19 @@ object Test2 extends App {
}


trait HasY { type Y }

// These are neg-tests corresponding to the pos-test Variances.scala
// where all the variance annotations have been inverted.
trait Foo1[+X] { def bar[Y <: X](y: Y) = y } // error
trait Foo2[+X] { def bar(x: HasY { type Y <: X })(y: x.Y) = y } // error
trait Foo3[-X] { def bar[Y >: X](y: Y) = y } // error
trait Foo4[-X] { def bar(x: HasY { type Y >: X })(y: x.Y) = y } // error

// These are neg-tests corresponding to the pos-test Variances.scala
// where all the bounds have been flipped.
trait Foo5[-X] { def bar[Y >: X](y: Y) = y } // error
trait Foo6[-X] { def bar(x: HasY { type Y >: X })(y: x.Y) = y } // error
trait Foo7[+X] { def bar[Y <: X](y: Y) = y } // error
trait Foo8[+X] { def bar(x: HasY { type Y <: X })(y: x.Y) = y } // error

15 changes: 15 additions & 0 deletions tests/pos/variances.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
trait C[+T <: C[T, U], -U <: C[T, U]] {

}
trait HasY { type Y }

// This works in scalac.
trait Foo1[-X] { def bar[Y <: X](y: Y) = y }

// A variant of Foo1 using a dependent method type (doesn't work using
// scalac)
trait Foo2[-X] { def bar(x: HasY { type Y <: X })(y: x.Y) = y }

// This works in scalac.
trait Foo3[+X] { def bar[Y >: X](y: Y) = y }

// A variant of Foo3 using a dependent method type (doesn't work
// using scalac)
trait Foo4[+X] { def bar(x: HasY { type Y >: X })(y: x.Y) = y }