Version 1.6.2
svn merge -c 40028 https://dart.googlecode.com/svn/branches/bleeding_edge 1.6
R=kasperl@google.com
Review URL: https://codereview.chromium.org//558953002
git-svn-id: http://dart.googlecode.com/svn/branches/1.6@40138 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart b/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart
index 3d0941d..1966d85 100644
--- a/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart
+++ b/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart
@@ -573,6 +573,11 @@
}
T visitFunctionExpression(ast.FunctionExpression node) {
+ // We loose track of [this] in closures (see issue 20840). To be on
+ // the safe side, we mark [this] as exposed here. We could do better by
+ // analyzing the closure.
+ // TODO(herhut): Analyze whether closure exposes this.
+ isThisExposed = true;
LocalFunctionElement element = elements.getFunctionDefinition(node);
// We don't put the closure in the work queue of the
// inferrer, because it will share information with its enclosing
diff --git a/tests/language/regress_20840_test.dart b/tests/language/regress_20840_test.dart
new file mode 100644
index 0000000..117fa0e
--- /dev/null
+++ b/tests/language/regress_20840_test.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for issue 20840.
+
+class SomeClass {
+ Object someField;
+
+ SomeClass() {
+ [1].forEach((o) => someMethod());
+ someField = new Object();
+ }
+
+ void someMethod() {
+ if (someField != null) {
+ throw "FAIL";
+ }
+ }
+}
+
+void main() {
+ new SomeClass();
+}
+
diff --git a/tools/VERSION b/tools/VERSION
index 61efb2e..e28b058 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -26,6 +26,6 @@
CHANNEL stable
MAJOR 1
MINOR 6
-PATCH 1
+PATCH 2
PRERELEASE 0
PRERELEASE_PATCH 0