From f6183ef4b030030606f46fe2463d325e39ae6174 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 17 Nov 2006 17:31:51 +0000 Subject: fixed bugs 802 and 807 (recursive lub problems). Changes system so that now an approximation of lub/glb is computed. --- test/files/neg/lubs.check | 16 ++++++++++++++++ test/files/neg/lubs.scala | 26 ++++++++++++++++++++++++++ test/files/pos/bug262.scala | 14 ++++++++++++++ test/files/pos/bug802.scala | 27 +++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 test/files/neg/lubs.check create mode 100644 test/files/neg/lubs.scala create mode 100644 test/files/pos/bug262.scala create mode 100644 test/files/pos/bug802.scala (limited to 'test/files') diff --git a/test/files/neg/lubs.check b/test/files/neg/lubs.check new file mode 100644 index 0000000000..e17e897f45 --- /dev/null +++ b/test/files/neg/lubs.check @@ -0,0 +1,16 @@ +lubs.scala:11 error: type mismatch; + found : test1.this.A[test1.this.A[test1.this.A[scala.Any]]] + required: test1.this.A[test1.this.A[test1.this.A[test1.this.A[scala.Any]]]] + val x4: A[A[A[A[Any]]]] = f + ^ +lubs.scala:24 error: type mismatch; + found : test2.this.A{type T >: test2.this.C with test2.this.D <: test2.this.A} + required: test2.this.A{type T >: scala.Null <: test2.this.A{type T >: scala.Null <: test2.this.A}} + val x3: A { type T >: Null <: A { type T >: Null <: A } } = f + ^ +lubs.scala:25 error: type mismatch; + found : test2.this.A{type T >: test2.this.C with test2.this.D <: test2.this.A} + required: test2.this.A{type T >: scala.Null <: test2.this.A{type T >: scala.Null <: test2.this.A{type T >: scala.Null <: test2.this.A}}} + val x4: A { type T >: Null <: A { type T >: Null <: A { type T >: Null <: A } } } = f + ^ +three errors found diff --git a/test/files/neg/lubs.scala b/test/files/neg/lubs.scala new file mode 100644 index 0000000000..3524fa4d87 --- /dev/null +++ b/test/files/neg/lubs.scala @@ -0,0 +1,26 @@ +object test1 { + abstract class A[+T] + class C extends A[C] + class D extends A[D] + + def f = if(1 == 2) new C else new D + + val x1: A[Any] = f + val x2: A[A[Any]] = f + val x3: A[A[A[Any]]] = f + val x4: A[A[A[A[Any]]]] = f +} + +object test2 { + + abstract class A { type T } + class C extends A { type T = C } + class D extends A { type T = D } + + def f = if (1 == 2) new C else new D + + val x1: A { type T } = f + val x2: A { type T >: Null <: A } = f + val x3: A { type T >: Null <: A { type T >: Null <: A } } = f + val x4: A { type T >: Null <: A { type T >: Null <: A { type T >: Null <: A } } } = f +} diff --git a/test/files/pos/bug262.scala b/test/files/pos/bug262.scala new file mode 100644 index 0000000000..ec6187b36b --- /dev/null +++ b/test/files/pos/bug262.scala @@ -0,0 +1,14 @@ +object O { + abstract class A { + def f:A; + } + class B extends A { + def f = if(1 == 2) new C else new D; + } + class C extends A { + def f = this; + } + class D extends A { + def f = this; + } +} diff --git a/test/files/pos/bug802.scala b/test/files/pos/bug802.scala new file mode 100644 index 0000000000..2dea7036d6 --- /dev/null +++ b/test/files/pos/bug802.scala @@ -0,0 +1,27 @@ +package test; +trait Test { + abstract class BracesImpl { + type Singleton; + type Brace <: Singleton with BraceImpl; + trait BraceImpl; + trait ForFile; + } + abstract class ParensImpl extends BracesImpl { + type Brace <: Singleton with BraceImpl; + trait BraceImpl extends super.BraceImpl; + } + val parens : ParensImpl; + abstract class BracksImpl extends BracesImpl { + type Brace <: Singleton with BraceImpl; + trait BraceImpl extends super.BraceImpl; + } + val bracks : BracksImpl; + trait File { + def parens0 : parens.BraceImpl; + def bracks0 : bracks.BraceImpl; + def braces(b : BracesImpl) = b match { + case b if b == parens => parens0; + case b if b == bracks => bracks0; + } + } +} -- cgit v1.2.3