aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/ast/CheckTrees.scala2
-rw-r--r--tests/neg/blockescapesNeg.scala5
-rw-r--r--tests/pos/blockescapes.scala11
3 files changed, 17 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/ast/CheckTrees.scala b/src/dotty/tools/dotc/ast/CheckTrees.scala
index b99548162..290d18b0c 100644
--- a/src/dotty/tools/dotc/ast/CheckTrees.scala
+++ b/src/dotty/tools/dotc/ast/CheckTrees.scala
@@ -31,7 +31,7 @@ object CheckTrees {
}
def leakingTypes(tp: Type): Set[NamedType] =
tp namedPartsWith (tp => isLocal(tp.symbol))
- def typeLeaks(tp: Type): Boolean = leakingTypes(tp).isEmpty
+ def typeLeaks(tp: Type): Boolean = leakingTypes(tp).nonEmpty
def classLeaks(sym: ClassSymbol): Boolean =
(sym.info.parents exists typeLeaks) ||
(sym.decls.toList exists (t => typeLeaks(t.info)))
diff --git a/tests/neg/blockescapesNeg.scala b/tests/neg/blockescapesNeg.scala
new file mode 100644
index 000000000..028ef5162
--- /dev/null
+++ b/tests/neg/blockescapesNeg.scala
@@ -0,0 +1,5 @@
+object blockescapesNeg {
+ def m0 = { object Foo { class Bar } ; new Foo.Bar }
+ class A[T]
+ def m1 = { val x = 1; new A[x.type]}
+} \ No newline at end of file
diff --git a/tests/pos/blockescapes.scala b/tests/pos/blockescapes.scala
new file mode 100644
index 000000000..35d40974b
--- /dev/null
+++ b/tests/pos/blockescapes.scala
@@ -0,0 +1,11 @@
+object blockescapes {
+
+ { val x = 0; () }
+ val x0 = { class Foo; new Foo }
+ val x1 = {}
+ val x2 = { val z = 0 }
+ val m1 = { val x = 2; x }
+
+ trait T
+ def m0: T = { object Foo { class Bar extends T } ; new Foo.Bar }
+} \ No newline at end of file