From e5315cce416c665d7c6d2740d171343829b30f4c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 16 Aug 2016 18:34:36 +0200 Subject: 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. --- tests/neg/i1263.scala | 33 +++++++++++++++++++++++++++++++++ tests/neg/traitParamsMixin.scala | 2 -- tests/neg/traitParamsTyper.scala | 2 ++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/neg/i1263.scala (limited to 'tests/neg') 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 -- cgit v1.2.3 From 2302886d79b3de8846d9295871a3cea6dd94d65e Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 17 Aug 2016 08:23:14 +0200 Subject: Fix test --- tests/neg/traitParamsTyper.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/neg') diff --git a/tests/neg/traitParamsTyper.scala b/tests/neg/traitParamsTyper.scala index c4b612033..caed2727d 100644 --- a/tests/neg/traitParamsTyper.scala +++ b/tests/neg/traitParamsTyper.scala @@ -2,7 +2,7 @@ trait T(x: Int) { def f = x } -class C extends T // error +class C0 extends T // error class C(x: Int) extends T() // error -- cgit v1.2.3