aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-08-16 18:34:36 +0200
committerGuillaume Martres <smarter@ubuntu.com>2016-08-20 20:31:13 -0700
commite5315cce416c665d7c6d2740d171343829b30f4c (patch)
tree95a6c77e958a0cdc779e02408c6848d36254b9f4 /tests
parent5a5f9d7ed37ca6449ef61ee5e0f6fbf9731df795 (diff)
downloaddotty-e5315cce416c665d7c6d2740d171343829b30f4c.tar.gz
dotty-e5315cce416c665d7c6d2740d171343829b30f4c.tar.bz2
dotty-e5315cce416c665d7c6d2740d171343829b30f4c.zip
Fix #1444: Add implicit arguments to supertraits
If a super trait is given as a type (i.e. no argument list), implicit args were not passed. This is fixed now. Also, we now check for parameterized traits lacking type arguments in Typer instead of in Mixin. Fixes #1444.
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/i1263.scala33
-rw-r--r--tests/neg/traitParamsMixin.scala2
-rw-r--r--tests/neg/traitParamsTyper.scala2
-rw-r--r--tests/pos/i1444.scala14
-rw-r--r--tests/run/i1263.scala3
5 files changed, 49 insertions, 5 deletions
diff --git a/tests/neg/i1263.scala b/tests/neg/i1263.scala
new file mode 100644
index 000000000..e6d8c37b5
--- /dev/null
+++ b/tests/neg/i1263.scala
@@ -0,0 +1,33 @@
+object Test {
+ trait Foo(val s: String)
+
+ val foo1 = new Foo("bar") {}
+ val foo2 = new Foo { override val s = "bar" } // error: parameterized trait lacks argument list
+ def main(args: Array[String]): Unit = {
+ assert(foo1.s == "bar")
+ assert(foo2.s == "bar")
+ }
+}
+object Test1 {
+ trait Foo(private val s0: String) {
+ def s = s0
+ }
+
+ val foo1 = new Foo("bar") {}
+ def main(args: Array[String]): Unit = {
+ assert(foo1.s == "bar")
+ }
+}
+object Test2 {
+ trait Foo(protected val s: String)
+
+ val foo1 = new Foo("bar") {}
+}
+object Test3 {
+ trait Foo(final val s: String)
+
+ val foo1 = new Foo("bar") {}
+ def main(args: Array[String]): Unit = {
+ assert(foo1.s == "bar")
+ }
+}
diff --git a/tests/neg/traitParamsMixin.scala b/tests/neg/traitParamsMixin.scala
index dfb9fbe2f..aa91012d5 100644
--- a/tests/neg/traitParamsMixin.scala
+++ b/tests/neg/traitParamsMixin.scala
@@ -2,8 +2,6 @@ trait T(x: Int) {
def f = x
}
-class C extends T // error
-
trait U extends T
class D extends U { // error
diff --git a/tests/neg/traitParamsTyper.scala b/tests/neg/traitParamsTyper.scala
index e97906b50..c4b612033 100644
--- a/tests/neg/traitParamsTyper.scala
+++ b/tests/neg/traitParamsTyper.scala
@@ -2,6 +2,8 @@ trait T(x: Int) {
def f = x
}
+class C extends T // error
+
class C(x: Int) extends T() // error
trait U extends C with T
diff --git a/tests/pos/i1444.scala b/tests/pos/i1444.scala
new file mode 100644
index 000000000..da858d50f
--- /dev/null
+++ b/tests/pos/i1444.scala
@@ -0,0 +1,14 @@
+object Test {
+
+class Cls(implicit x:X)
+class ClsImpl extends Cls //this works
+
+trait Tr1(implicit x:X)
+class TrtImpl extends Tr1 //Compiler: Error: parameterized trait Tr1 lacks argument list
+
+trait Tr2()(implicit x:X)
+class Tr2Impl extends Tr2() //this works
+
+trait X
+implicit object AnX extends X
+}
diff --git a/tests/run/i1263.scala b/tests/run/i1263.scala
index 630e5758e..e97606ef6 100644
--- a/tests/run/i1263.scala
+++ b/tests/run/i1263.scala
@@ -2,10 +2,8 @@ object Test {
trait Foo(val s: String)
val foo1 = new Foo("bar") {}
- val foo2 = new Foo { override val s = "bar" }
def main(args: Array[String]): Unit = {
assert(foo1.s == "bar")
- assert(foo2.s == "bar")
}
}
object Test1 {
@@ -22,7 +20,6 @@ object Test2 {
trait Foo(protected val s: String)
val foo1 = new Foo("bar") {}
- val foo2 = new Foo { override val s = "bar" }
}
object Test3 {
trait Foo(final val s: String)