aboutsummaryrefslogtreecommitdiff
path: root/java/com/google/turbine/types/Canonicalize.java
diff options
context:
space:
mode:
authorcushon <cushon@google.com>2017-12-22 09:16:08 -0800
committerLiam Miller-Cushon <cushon@google.com>2017-12-23 14:10:54 -0800
commit8032a85b81783fff5687543ed866aed19d017207 (patch)
tree4c40be3aafcf4510ae571f782a0335fc9a6954a4 /java/com/google/turbine/types/Canonicalize.java
parent3dd7b4b55a1dddd3c8544acf69f078a8e815e8db (diff)
downloadturbine-8032a85b81783fff5687543ed866aed19d017207.tar.gz
Fix infinite recursion in canonicalize
It's possible for a class A to be both a sub-class and the enclosing instance of another class B: ``` class Test { class B {} class A extends B { A.B f; } } ``` During canonicalization we don't need to consider both possibilities simultaneously. When canonicalizing B as a member of A we end up canonicalizing A's super-type, but the enclosing instance for the second step should be A's outer class, not A itself. This was causing canonicalization to get stuck in an infinite loop on examples like the one above. MOE_MIGRATED_REVID=179932866
Diffstat (limited to 'java/com/google/turbine/types/Canonicalize.java')
-rw-r--r--java/com/google/turbine/types/Canonicalize.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/java/com/google/turbine/types/Canonicalize.java b/java/com/google/turbine/types/Canonicalize.java
index b4e320d..fc5d907 100644
--- a/java/com/google/turbine/types/Canonicalize.java
+++ b/java/com/google/turbine/types/Canonicalize.java
@@ -195,7 +195,8 @@ public class Canonicalize {
}
break;
}
- curr = canon(env, curr.sym(), env.get(curr.sym()).superClassType());
+ TypeBoundClass info = env.get(curr.sym());
+ curr = canon(env, info.owner(), info.superClassType());
}
simples.add(ty);
return new ClassTy(simples.build());