diff options
-rw-r--r-- | sources/scalac/ast/Tree.java | 1 | ||||
-rw-r--r-- | test/files/neg/matthias2.scala | 8 | ||||
-rw-r--r-- | test/files/pos/matthias3.scala | 13 | ||||
-rw-r--r-- | test/files/pos/matthias4.scala | 84 | ||||
-rw-r--r-- | test/files/pos/matthias5.scala | 12 | ||||
-rw-r--r-- | test/neg/matthias2.scala | 8 | ||||
-rw-r--r-- | test/pos/matthias3.scala | 13 | ||||
-rw-r--r-- | test/pos/matthias4.scala | 84 | ||||
-rw-r--r-- | test/pos/matthias5.scala | 12 |
9 files changed, 234 insertions, 1 deletions
diff --git a/sources/scalac/ast/Tree.java b/sources/scalac/ast/Tree.java index ee6018717f..d7e54dfc52 100644 --- a/sources/scalac/ast/Tree.java +++ b/sources/scalac/ast/Tree.java @@ -331,7 +331,6 @@ public class Tree { public case This(Tree qualifier) { if (!qualifier.isType()) throw unexpected("This expects type", qualifier); - assert Global.instance.currentPhase.id <= 2 || qualifier.symbol() != null; } /** diff --git a/test/files/neg/matthias2.scala b/test/files/neg/matthias2.scala new file mode 100644 index 0000000000..ab9296798f --- /dev/null +++ b/test/files/neg/matthias2.scala @@ -0,0 +1,8 @@ +class A() { + val x: A = this; + val y: x.type = x; + type T = y.type; +} +abstract class B() extends A() { + override val y: T; +} diff --git a/test/files/pos/matthias3.scala b/test/files/pos/matthias3.scala new file mode 100644 index 0000000000..c76d291245 --- /dev/null +++ b/test/files/pos/matthias3.scala @@ -0,0 +1,13 @@ + +abstract class A() { + val y: A; +} +class B() extends A() { + val x = this; + val y: x.type = x; +} +abstract class C() { + val b: B = new B(); + val a: A with { val y: b.type }; +} + diff --git a/test/files/pos/matthias4.scala b/test/files/pos/matthias4.scala new file mode 100644 index 0000000000..751c8b1c88 --- /dev/null +++ b/test/files/pos/matthias4.scala @@ -0,0 +1,84 @@ +/* +module A requires B { + B.X getX() { + return B.getX(); + } + void setX(B.X x) {} +} +module B { + class X {} + X getX() { + return new X(); + } + void setX(X x) {} +} +module C requires B { + module A; + void test() { + A.setX(B.getX()); + } +} +*/ + +trait _a extends Object with _b { + val a: _a; + val A: A; + type A <: a.AModule; + trait AModule { + def getX(): B.X; + def setX(x: B.X): Unit; + } +} +abstract class a() extends Object with _a with _b { + val a: this.type = this; + val A: A = new A(); + class A() extends AModule { + def getX(): B.X = B.getX(); + def setX(x: B.X) = B.setX(x); + } +} + +trait _b { + val b: _b; + val B: B; + type B <: b.BModule; + trait BModule { + type X; + def getX(): X; + def setX(x: X): Unit; + } +} +abstract class b() extends Object with _b { + val b: this.type = this; + val B: B = new B(); + class B() extends BModule { + class X() {} + def getX(): X = new X(); + def setX(x: X) = (); + } +} + +trait _m { + val m: _m; + val M: M; + type M <: m.MModule; + trait MModule {} +} +abstract class m() extends Object with _m with _b { + val m: this.type = this; + val M: M = new M(); + class M() extends MModule with a() with Linker() { + def test() = { + val x: B.X = B.getX(); + A.setX(x); + } + } + abstract class Linker() { + val b: m.this.b.type = m.this.b; + val B: m.this.B.type = m.this.B; + type B = m.this.B; + val m: m.this.m.type = m.this.m; + val M: m.this.M.type = m.this.M; + type M = m.this.M; + } +} diff --git a/test/files/pos/matthias5.scala b/test/files/pos/matthias5.scala new file mode 100644 index 0000000000..a6c9808c9e --- /dev/null +++ b/test/files/pos/matthias5.scala @@ -0,0 +1,12 @@ +abstract class A() { + val y: A; +} +class B() extends A() { + val x = this; + val y: x.type = x; +} +abstract class C() { + val b: B = new B(); + val a: A with { val y: b.type }; +} + diff --git a/test/neg/matthias2.scala b/test/neg/matthias2.scala new file mode 100644 index 0000000000..ab9296798f --- /dev/null +++ b/test/neg/matthias2.scala @@ -0,0 +1,8 @@ +class A() { + val x: A = this; + val y: x.type = x; + type T = y.type; +} +abstract class B() extends A() { + override val y: T; +} diff --git a/test/pos/matthias3.scala b/test/pos/matthias3.scala new file mode 100644 index 0000000000..c76d291245 --- /dev/null +++ b/test/pos/matthias3.scala @@ -0,0 +1,13 @@ + +abstract class A() { + val y: A; +} +class B() extends A() { + val x = this; + val y: x.type = x; +} +abstract class C() { + val b: B = new B(); + val a: A with { val y: b.type }; +} + diff --git a/test/pos/matthias4.scala b/test/pos/matthias4.scala new file mode 100644 index 0000000000..751c8b1c88 --- /dev/null +++ b/test/pos/matthias4.scala @@ -0,0 +1,84 @@ +/* +module A requires B { + B.X getX() { + return B.getX(); + } + void setX(B.X x) {} +} +module B { + class X {} + X getX() { + return new X(); + } + void setX(X x) {} +} +module C requires B { + module A; + void test() { + A.setX(B.getX()); + } +} +*/ + +trait _a extends Object with _b { + val a: _a; + val A: A; + type A <: a.AModule; + trait AModule { + def getX(): B.X; + def setX(x: B.X): Unit; + } +} +abstract class a() extends Object with _a with _b { + val a: this.type = this; + val A: A = new A(); + class A() extends AModule { + def getX(): B.X = B.getX(); + def setX(x: B.X) = B.setX(x); + } +} + +trait _b { + val b: _b; + val B: B; + type B <: b.BModule; + trait BModule { + type X; + def getX(): X; + def setX(x: X): Unit; + } +} +abstract class b() extends Object with _b { + val b: this.type = this; + val B: B = new B(); + class B() extends BModule { + class X() {} + def getX(): X = new X(); + def setX(x: X) = (); + } +} + +trait _m { + val m: _m; + val M: M; + type M <: m.MModule; + trait MModule {} +} +abstract class m() extends Object with _m with _b { + val m: this.type = this; + val M: M = new M(); + class M() extends MModule with a() with Linker() { + def test() = { + val x: B.X = B.getX(); + A.setX(x); + } + } + abstract class Linker() { + val b: m.this.b.type = m.this.b; + val B: m.this.B.type = m.this.B; + type B = m.this.B; + val m: m.this.m.type = m.this.m; + val M: m.this.M.type = m.this.M; + type M = m.this.M; + } +} diff --git a/test/pos/matthias5.scala b/test/pos/matthias5.scala new file mode 100644 index 0000000000..a6c9808c9e --- /dev/null +++ b/test/pos/matthias5.scala @@ -0,0 +1,12 @@ +abstract class A() { + val y: A; +} +class B() extends A() { + val x = this; + val y: x.type = x; +} +abstract class C() { + val b: B = new B(); + val a: A with { val y: b.type }; +} + |