diff options
5 files changed, 26 insertions, 5 deletions
diff --git a/jack-tests/tests/com/android/jack/frontend/DuplicateSourceTest.java b/jack-tests/tests/com/android/jack/frontend/DuplicateSourceTest.java index 205400d..efa4c4d 100644 --- a/jack-tests/tests/com/android/jack/frontend/DuplicateSourceTest.java +++ b/jack-tests/tests/com/android/jack/frontend/DuplicateSourceTest.java @@ -35,7 +35,6 @@ public class DuplicateSourceTest { * command line. */ @Test - @Category(KnownBugs.class) public void test001() throws Exception { File output = AbstractTestTools.createTempDir(); ByteArrayOutputStream errOut = new ByteArrayOutputStream(); diff --git a/jack-tests/tests/com/android/jack/frontend/FrontEndTests.java b/jack-tests/tests/com/android/jack/frontend/FrontEndTests.java index a5692fb..875a4b6 100644 --- a/jack-tests/tests/com/android/jack/frontend/FrontEndTests.java +++ b/jack-tests/tests/com/android/jack/frontend/FrontEndTests.java @@ -69,7 +69,6 @@ public class FrontEndTests { * Test that we do not crash and that we report the error. */ @Test - @Category(KnownBugs.class) public void testConflictingPackage001() throws Exception { File outDir = AbstractTestTools.createTempDir(); @@ -118,7 +117,6 @@ public class FrontEndTests { * Test that we do not crash and that we report the error. */ @Test - @Category(KnownBugs.class) public void testDuplicated001() throws Exception { File outDir = AbstractTestTools.createTempDir(); diff --git a/jack/src/com/android/jack/frontend/java/JAstBuilder.java b/jack/src/com/android/jack/frontend/java/JAstBuilder.java index 9b250cd..0d62819 100644 --- a/jack/src/com/android/jack/frontend/java/JAstBuilder.java +++ b/jack/src/com/android/jack/frontend/java/JAstBuilder.java @@ -198,6 +198,11 @@ class JAstBuilder extends JavaParser { private void createTypes(@Nonnull JPackage enclosingPackage, @Nonnull ReferenceMapper refMap, @Nonnull TypeDeclaration typeDeclaration) { + if (hasErrors || JackIrBuilder.hasError(typeDeclaration)) { + // An error has already been detected, don't even try to handle the unit. + hasErrors = true; + return; + } EcjSourceTypeLoader.createType(refMap, enclosingPackage, typeDeclaration.binding, typeDeclaration, new FileLocation(new File(new String(typeDeclaration.compilationResult.fileName)))); diff --git a/jack/src/com/android/jack/ir/impl/EcjSourceTypeLoader.java b/jack/src/com/android/jack/ir/impl/EcjSourceTypeLoader.java index 927fe35..c6c61b5 100644 --- a/jack/src/com/android/jack/ir/impl/EcjSourceTypeLoader.java +++ b/jack/src/com/android/jack/ir/impl/EcjSourceTypeLoader.java @@ -303,6 +303,8 @@ public class EcjSourceTypeLoader implements ClassOrInterfaceLoader { ReferenceMapper referenceMapper = refMap.get(); for (TypeDeclaration memberType : declaration.memberTypes) { try { + assert !JackIrBuilder.hasError(memberType); + ((JDefinedClassOrInterface) referenceMapper.get(memberType.binding)) .getEnclosingType(); } catch (JTypeLookupException e) { diff --git a/jack/src/com/android/jack/ir/impl/JackIrBuilder.java b/jack/src/com/android/jack/ir/impl/JackIrBuilder.java index 51192bd..e45298c 100644 --- a/jack/src/com/android/jack/ir/impl/JackIrBuilder.java +++ b/jack/src/com/android/jack/ir/impl/JackIrBuilder.java @@ -1739,7 +1739,8 @@ public class JackIrBuilder { @Override public final void endVisit(TypeDeclaration typeDecl, BlockScope scope) { - if (typeDecl.binding == null || typeDecl.binding.constantPoolName() == null) { + assert !JackIrBuilder.hasError(typeDecl); + if (typeDecl.binding.constantPoolName() == null) { assert false; /* * Weird case: if JDT determines that this local class is totally @@ -2009,7 +2010,8 @@ public class JackIrBuilder { @Override public final boolean visit(TypeDeclaration typeDecl, BlockScope scope) { - if (typeDecl.binding == null || typeDecl.binding.constantPoolName() == null) { + assert !JackIrBuilder.hasError(typeDecl); + if (typeDecl.binding.constantPoolName() == null) { assert false; /* * Weird case: if JDT determines that this local class is totally @@ -2025,6 +2027,7 @@ public class JackIrBuilder { } protected void endVisit(TypeDeclaration x) { + assert !JackIrBuilder.hasError(x); try { JDefinedClassOrInterface type = curClass.type; @@ -2178,6 +2181,7 @@ public class JackIrBuilder { } protected boolean visit(TypeDeclaration x) { + assert !JackIrBuilder.hasError(x); try { JDefinedClassOrInterface type = (JDefinedClassOrInterface) getTypeMap().get(x.binding); classStack.push(curClass); @@ -2922,6 +2926,7 @@ public class JackIrBuilder { result = makeLocalRef(info, (LocalVariableBinding) path[0]); } else if (path[0] instanceof FieldBinding) { FieldBinding fb = (FieldBinding) path[0]; + assert curClass.typeDecl.binding != null; assert curClass.typeDecl.binding.isCompatibleWith(x.actualReceiverType.erasure()); JField field = getTypeMap().get(fb); assert field != null; @@ -3364,6 +3369,16 @@ public class JackIrBuilder { @Nonnull private final JSession session; + public static boolean hasError(@Nonnull TypeDeclaration typeDeclaration) { + return (typeDeclaration.hasErrors() + || (typeDeclaration.getCompilationUnitDeclaration() != null + && typeDeclaration.getCompilationUnitDeclaration().hasErrors()) + || typeDeclaration.compilationResult.hasErrors() + // This should be redundant with typeDeclaration.getCompilationUnitDeclaration().hasErrors() but + // since it could be null, lets be safe + || typeDeclaration.binding == null); + } + public JackIrBuilder(@Nonnull LookupEnvironment lookupEnvironment, @Nonnull JSession session) { this.lookupEnvironment = lookupEnvironment; @@ -3565,6 +3580,7 @@ public class JackIrBuilder { private void createMembers(TypeDeclaration x) { try { + assert !JackIrBuilder.hasError(x); SourceTypeBinding binding = x.binding; JDefinedClassOrInterface type = (JDefinedClassOrInterface) getTypeMap().get(binding); SourceInfo info = type.getSourceInfo(); @@ -3684,6 +3700,7 @@ public class JackIrBuilder { } private void createTypes(TypeDeclaration x) { + assert !JackIrBuilder.hasError(x); SourceInfo info = makeSourceInfo(x); try { JDefinedClassOrInterface type = (JDefinedClassOrInterface) getTypeMap().get(x.binding); |