diff options
author | Martin Odersky <odersky@gmail.com> | 2009-08-14 19:30:49 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-08-14 19:30:49 +0000 |
commit | d601240fe665e303436093b108dd203ace42c743 (patch) | |
tree | 110656b58b54b6843e6666a9e9e1736ae94c0987 | |
parent | 5e1deae36170e68a15dd6ffbbc3d902673892f59 (diff) | |
download | scala-d601240fe665e303436093b108dd203ace42c743.tar.gz scala-d601240fe665e303436093b108dd203ace42c743.tar.bz2 scala-d601240fe665e303436093b108dd203ace42c743.zip |
Blocks can now end in definitions.
-rwxr-xr-x | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 5 | ||||
-rw-r--r-- | test/files/neg/bug555.check | 4 | ||||
-rw-r--r-- | test/files/neg/bug555.scala | 5 | ||||
-rw-r--r-- | test/files/neg/bug987.check | 29 | ||||
-rw-r--r-- | test/files/pos/bug1001.scala | 2 | ||||
-rw-r--r-- | test/files/pos/ticket2251.scala | 23 |
7 files changed, 21 insertions, 49 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 7ff5aa3dca..787e96d1d8 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2520,7 +2520,7 @@ self => } else if (isDefIntro || isLocalModifier || in.token == AT) { stats ++= localDef if (in.token == RBRACE || in.token == CASE) { - syntaxError("block must end in result expression, not in definition", false) + //syntaxError("block must end in result expression, not in definition", false) stats += Literal(()).setPos(o2p(in.offset)) } else acceptStatSep() } else if (isStatSep) { diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 5e8fbca81b..b716f6ac16 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -860,8 +860,9 @@ abstract class RefChecks extends InfoTransform { var result = tree def doTypeTraversal(f: (Type) => Unit) = - if (!inPattern) - new ForEachTypeTraverser(f) traverse tree.tpe + if (!inPattern) { + for (tp <- tree.tpe) f(tp) + } // Apply RefChecks to annotations. Makes sure the annotations conform to // type bounds (bug #935), issues deprecation warnings for symbols used diff --git a/test/files/neg/bug555.check b/test/files/neg/bug555.check deleted file mode 100644 index e72714d36c..0000000000 --- a/test/files/neg/bug555.check +++ /dev/null @@ -1,4 +0,0 @@ -bug555.scala:4: error: block must end in result expression, not in definition - } - ^ -one error found diff --git a/test/files/neg/bug555.scala b/test/files/neg/bug555.scala deleted file mode 100644 index 26dbe6cc0d..0000000000 --- a/test/files/neg/bug555.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Main extends Application { - def tata = { - def titi = {} - } -} diff --git a/test/files/neg/bug987.check b/test/files/neg/bug987.check index ec2ca621fd..4cad622ab8 100644 --- a/test/files/neg/bug987.check +++ b/test/files/neg/bug987.check @@ -1,16 +1,19 @@ -bug987.scala:15: error: the type intersection D with ScalaObject is malformed - --- because --- -no common type instance of base types B[C], and B[D] exists. +bug987.scala:15: error: illegal inheritance; + class E inherits different type instances of trait B: +B[D] and B[C] class E extends D - ^ -bug987.scala:20: error: the type intersection D with ScalaObject is malformed - --- because --- -no common type instance of base types B[C], and B[D] exists. + ^ +bug987.scala:20: error: illegal inheritance; + class F inherits different type instances of trait B: +B[D] and B[C] class F extends D - ^ -bug987.scala:25: error: the type intersection C with B[D] with ScalaObject is malformed - --- because --- -no common type instance of base types B[D], and B[C] exists. + ^ +bug987.scala:25: error: illegal inheritance; + class D inherits different type instances of trait B: +B[D] and B[C] abstract class D extends C with B[D] {} - ^ -three errors found + ^ +bug987.scala:25: error: type arguments [D] do not conform to trait B's type parameter bounds [T <: B[T]] +abstract class D extends C with B[D] {} + ^ +four errors found diff --git a/test/files/pos/bug1001.scala b/test/files/pos/bug1001.scala index 1b909fb2ad..776a334dad 100644 --- a/test/files/pos/bug1001.scala +++ b/test/files/pos/bug1001.scala @@ -101,5 +101,5 @@ object N26 extends Ee object N31 extends Ee { // If we use List[C](N26,N25), we achieve successful compilation - val data = List(N26,N25) + val data = List[C](N26,N25) } diff --git a/test/files/pos/ticket2251.scala b/test/files/pos/ticket2251.scala deleted file mode 100644 index 1e8727e999..0000000000 --- a/test/files/pos/ticket2251.scala +++ /dev/null @@ -1,23 +0,0 @@ -// derived from pos/bug1001 -class A -trait B[T <: B[T]] extends A -class C extends B[C] -class D extends B[D] - -class Data { - // force computing lub of C and D (printLubs enabled:) - -/* -lub of List(D, C) at depth 2 - lub of List(D, C) at depth 1 - lub of List(D, C) at depth 0 - lub of List(D, C) is A - lub of List(D, C) is B[_1] forSome { type _1 >: D with C <: A } -lub of List(D, C) is B[_2] forSome { type _2 >: D with C{} <: B[_1] forSome { type _1 >: D with C{} <: A } } -*/ -// --> result = WRONG - - // should be: B[X] forSome {type X <: B[X]} -- can this be done automatically? for now, just detect f-bounded polymorphism and fall back to more coarse approximation - - val data: List[A] = List(new C, new D) -} |