Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java

Issue 10450015: Fix for getter access expression type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
index 8e1952d4b96b9f50d10201dc3e4c3135382a7904..5e24f62a3771f7cf24fc70867ac28103e29365ca 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -1327,7 +1327,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertVariableTypeString(libraryResult, "v1", "String");
}
- public void test_binaryExpressionType() throws Exception {
+ public void test_getType_binaryExpression() throws Exception {
AnalyzeLibraryResult libraryResult = analyzeLibrary(
"f() {",
" var v1 = 1 + 2;",
@@ -1367,6 +1367,32 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
+ * There was problem that using <code>() -> bool</code> getter in negation ('!') caused assignment
+ * warnings. Actual reason was that with negation getter access is visited twice and on the second
+ * time type of getter method, instead of return type, was returned.
+ */
+ public void test_getType_getterInNegation() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "class A {",
+ " int get intProperty() => 42;",
+ " bool get boolProperty() => true;",
+ "}",
+ "f() {",
+ " var a = new A();",
+ " var v1 = a.intProperty;",
+ " var v2 = a.boolProperty;",
+ " if (a.boolProperty) {",
+ " }",
+ " if (!a.boolProperty) {",
+ " }",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ assertVariableTypeString(libraryResult, "v1", "int");
+ assertVariableTypeString(libraryResult, "v2", "bool");
+ }
+
+ /**
* Asserts that {@link VariableElement} with given name has expected type.
*/
private void assertVariableTypeString(
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698