diff --git a/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/ExpressionTransformer.java b/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/ExpressionTransformer.java index 9245d648c36..375f960fef7 100644 --- a/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/ExpressionTransformer.java +++ b/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/ExpressionTransformer.java @@ -8146,14 +8146,15 @@ private void putAnnotation( annotationSet.put(annotationClass, list.append(annotation)); } - public void transformAnonymousAnnotation(Tree.AnonymousAnnotation annotation, Map> annos) { - Type docType = ((TypeDeclaration)typeFact().getLanguageModuleDeclaration("DocAnnotation")).getType(); - JCAnnotation docAnnotation = at(annotation).Annotation( - makeJavaType(docType, JT_ANNOTATION), - List.of(make().Assign(naming.makeUnquotedIdent("description"), - transform(annotation.getStringLiteral())))); - putAnnotation(annos, docAnnotation, (Class)docType.getDeclaration()); + HasErrorException firstExpressionErrorAndMarkBrokenness = errors().getFirstExpressionErrorAndMarkBrokenness(annotation); + if (firstExpressionErrorAndMarkBrokenness == null) { + Type docType = ((TypeDeclaration) typeFact().getLanguageModuleDeclaration("DocAnnotation")).getType(); + JCAnnotation docAnnotation = at(annotation).Annotation(makeJavaType(docType, JT_ANNOTATION), + List.of(make().Assign(naming.makeUnquotedIdent("description"), + transform(annotation.getStringLiteral())))); + putAnnotation(annos, docAnnotation, (Class) docType.getDeclaration()); + } } public JCExpression makeMetaLiteralStringLiteralForAnnotation(Tree.MetaLiteral literal) { diff --git a/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/recovery/DeclarationErrorVisitor.java b/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/recovery/DeclarationErrorVisitor.java index c96937651cb..d281b343f03 100644 --- a/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/recovery/DeclarationErrorVisitor.java +++ b/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/recovery/DeclarationErrorVisitor.java @@ -29,6 +29,7 @@ import org.eclipse.ceylon.compiler.typechecker.tree.Node; import org.eclipse.ceylon.compiler.typechecker.tree.Tree; import org.eclipse.ceylon.compiler.typechecker.tree.Visitor; +import org.eclipse.ceylon.compiler.typechecker.tree.Tree.AnonymousAnnotation; import org.eclipse.ceylon.model.loader.model.LazyClass; import org.eclipse.ceylon.model.loader.model.LazyInterface; import org.eclipse.ceylon.model.typechecker.model.Class; @@ -109,7 +110,6 @@ public final void visitAny(Node that) { */ private void planAccordingToErrors(Node that) { List errors = that.getErrors(); - for(Message message : errors){ if(isError(that, message)) { TransformationPlan plan; @@ -167,6 +167,11 @@ private boolean isError(Node that, Message message) { } } + @Override + public void visit(AnonymousAnnotation that) { + // don't go there + } + @Override public void visit(Tree.Annotation that) { // don't go there diff --git a/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/recovery/Errors.java b/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/recovery/Errors.java index 0ef4941f8d9..b1330eb5812 100644 --- a/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/recovery/Errors.java +++ b/compiler-java/src/org/eclipse/ceylon/compiler/java/codegen/recovery/Errors.java @@ -90,6 +90,10 @@ public TransformationPlan hasDeclarationError(Tree.Declaration node) { return declarationVisitor.getRecoveryPlan(node); } + public HasErrorException getFirstExpressionErrorAndMarkBrokenness(Tree.AnonymousAnnotation node) { + return annotateBrokenness(expressionVisitor.getFirstErrorMessage(node)); + } + /** * Visit the given tree of expressions returning the first error found, * or null if the tree is free of errors. diff --git a/compiler-java/test/src/org/eclipse/ceylon/compiler/java/test/issues/IssuesTests_6500_6999.java b/compiler-java/test/src/org/eclipse/ceylon/compiler/java/test/issues/IssuesTests_6500_6999.java index db8cf3b432f..167c1d03e58 100644 --- a/compiler-java/test/src/org/eclipse/ceylon/compiler/java/test/issues/IssuesTests_6500_6999.java +++ b/compiler-java/test/src/org/eclipse/ceylon/compiler/java/test/issues/IssuesTests_6500_6999.java @@ -32,6 +32,7 @@ import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.Arrays; +import java.util.Collections; import java.util.TreeSet; import java.util.jar.JarFile; import java.util.zip.ZipEntry; @@ -39,6 +40,7 @@ import org.eclipse.ceylon.compiler.java.launcher.Main.ExitState; import org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel; import org.eclipse.ceylon.compiler.java.test.CompilerError; +import org.eclipse.ceylon.compiler.java.test.CompilerError.Classification; import org.eclipse.ceylon.compiler.java.test.CompilerTests; import org.eclipse.ceylon.compiler.java.test.ErrorCollector; import org.eclipse.ceylon.javax.tools.Diagnostic.Kind; @@ -441,4 +443,13 @@ public void testBug6982() throws Throwable { public void testBug6997() throws Throwable { compareWithJavaSource("bug69xx/Bug6997"); } + @Test + public void testBug6763() { + assertErrors("bug67xx/Bug6763", Collections.emptyList(), null, + new CompilerError( + Kind.ERROR,"Bug6763",1, + "illegal escape sequence: '\\i' is not a recognized escape sequence", + Classification.FRONTEND) + ); + } } diff --git a/compiler-java/test/src/org/eclipse/ceylon/compiler/java/test/issues/bug67xx/Bug6763.ceylon b/compiler-java/test/src/org/eclipse/ceylon/compiler/java/test/issues/bug67xx/Bug6763.ceylon new file mode 100644 index 00000000000..0cddd8f33ae --- /dev/null +++ b/compiler-java/test/src/org/eclipse/ceylon/compiler/java/test/issues/bug67xx/Bug6763.ceylon @@ -0,0 +1,3 @@ +"\i" +class C() {} +C f(C c) => c; \ No newline at end of file