From 4d5a901d10a28c286f8754134f5030daae0d239b Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 14 Nov 2014 16:11:31 +0100 Subject: Fix OverridingPairs OverridingPairs had several bugs which caused pairs to be lost, which caused missing overrides checks. Fixing OverridingPairs revealed several test failures (and a problem in Synthetics generation which was fixed in the last commit). Tests that became negative are all moved into neg/overrides.scala, and the original versions in pos were fixed. --- tests/neg/over.scala | 10 ++++++++ tests/neg/overrides.scala | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/neg/over.scala create mode 100644 tests/neg/overrides.scala (limited to 'tests/neg') diff --git a/tests/neg/over.scala b/tests/neg/over.scala new file mode 100644 index 000000000..488d71614 --- /dev/null +++ b/tests/neg/over.scala @@ -0,0 +1,10 @@ +trait T { + def x = 1 +} + +class C extends T { + + val x = 2 + override val y = 2 + +} diff --git a/tests/neg/overrides.scala b/tests/neg/overrides.scala new file mode 100644 index 000000000..4befe1623 --- /dev/null +++ b/tests/neg/overrides.scala @@ -0,0 +1,59 @@ + abstract class FooA { + type A <: Ax; + abstract class Ax; + abstract class InnerA { + type B <: A; + def doB : B; + } + } + trait FooB extends FooA { + type A <: Ax; + trait Ax extends super.Ax { def xxx : Int; } + abstract class InnerB extends InnerA { + // type B <: A; + val a : A = doB; + a.xxx; + doB.xxx; + } + } + +package p1 { + abstract class T1 { + protected def bug(p: Int = 1): Int // without 'protected' compiles fine + } +} +package p2 { // all being in the same package compiles fine + import p1._ + abstract class T2 extends T1 { + class A { + bug() + } + } + + abstract class T3 extends T2 { + class A { + bug() + } + } +} + +class A[T] { + + def f(x: T)(y: T = x) = y + +} + +class B extends A[Int] { + + def f(x: Int)(y: Int) = y + + f(2)() + +} + +class X { + def f: A[Int] = ??? +} +class Y extends X { + def f: A[Int] = ??? +} -- cgit v1.2.3