barry-m / checker-framework

Automatically exported from code.google.com/p/checker-framework
Other
0 stars 0 forks source link

Annotations on union types where the classes in the union have a declaration annotation #384

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Cannot write annotations on a union type if the types in the union have 
declaration annotations on their type definitions.

For example, (full example attached)
...
        } catch (@NonNull InnerException1 | @NonNull  InnerException2 e) {
        }
...

@PolyUIType
    class InnerException1 extends Exception {}

@PolyUIType
class InnerException2 extends Exception {}

What steps will reproduce the problem?
 javacheck -processor NullnessChecker UnionTypeBug.java  -AprintErrorStack
What is the expected output?
no warnings

What do you see instead?
error: TypeFromElement.getLocationTypeATM: only declared types and arrays can 
have annotations with location; found type: InnerException1 | InnerException2 
location: INNER_TYPE
  Compilation unit: UnionTypeBug.java
  Exception: java.lang.Throwable; Stack trace: org.checkerframework.framework.source.SourceChecker.errorAbort(SourceChecker.java:609)
  org.checkerframework.javacutil.ErrorReporter.errorAbort(ErrorReporter.java:28)
  org.checkerframework.framework.type.TypeFromElement.getLocationTypeATM(TypeFromElement.java:752)
  org.checkerframework.framework.type.TypeFromElement.annotate(TypeFromElement.java:735)
  org.checkerframework.framework.type.TypeFromElement.annotate(TypeFromElement.java:699)
  org.checkerframework.framework.type.TypeFromElement.annotateLocal(TypeFromElement.java:391)
  org.checkerframework.framework.type.TypeFromElement.annotate(TypeFromElement.java:94)
  org.checkerframework.framework.type.TypeFromTree$TypeFromMember.visitVariable(TypeFromTree.java:468)
  org.checkerframework.framework.type.TypeFromTree$TypeFromMember.visitVariable(TypeFromTree.java:457)
  com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:864)

Original issue reported on code.google.com by Suzanne....@gmail.com on 12 Dec 2014 at 11:16

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by jtha...@cs.washington.edu on 12 Dec 2014 at 11:48