Annotation constructor parameters are never nullable

This commit is contained in:
Andrey Breslav
2014-01-14 15:39:46 +04:00
parent 65d90e18a2
commit bf20c3a734
16 changed files with 31 additions and 29 deletions
@@ -6,7 +6,7 @@ public trait AnnotationInParam : java.lang.Object {
public constructor A() public constructor A()
} }
test.AnnotationInParam.MyAnnotationWithParam2(value = test.AnnotationInParam.MyAnnotation2(value = {"test", "test2"}: jet.Array<jet.String>?): test.AnnotationInParam.MyAnnotation2) public open class B : java.lang.Object { test.AnnotationInParam.MyAnnotationWithParam2(value = test.AnnotationInParam.MyAnnotation2(value = {"test", "test2"}: jet.Array<jet.String>): test.AnnotationInParam.MyAnnotation2) public open class B : java.lang.Object {
public constructor B() public constructor B()
} }
@@ -15,33 +15,33 @@ public trait AnnotationInParam : java.lang.Object {
} }
public final annotation class MyAnnotation : jet.Annotation { public final annotation class MyAnnotation : jet.Annotation {
public constructor MyAnnotation(/*0*/ value: jet.String?) public constructor MyAnnotation(/*0*/ value: jet.String)
public abstract fun value(): jet.String? public abstract fun value(): jet.String?
} }
public final annotation class MyAnnotation2 : jet.Annotation { public final annotation class MyAnnotation2 : jet.Annotation {
public constructor MyAnnotation2(/*0*/ vararg value: jet.String? /*jet.Array<jet.String>?*/) public constructor MyAnnotation2(/*0*/ vararg value: jet.String /*jet.Array<jet.String>*/)
public abstract fun value(): jet.Array<jet.String>? public abstract fun value(): jet.Array<jet.String>?
} }
public final annotation class MyAnnotation3 : jet.Annotation { public final annotation class MyAnnotation3 : jet.Annotation {
public constructor MyAnnotation3(/*0*/ first: jet.String?, /*1*/ second: jet.String?) public constructor MyAnnotation3(/*0*/ first: jet.String, /*1*/ second: jet.String)
public abstract fun first(): jet.String? public abstract fun first(): jet.String?
public abstract fun second(): jet.String? public abstract fun second(): jet.String?
} }
public final annotation class MyAnnotationWithParam : jet.Annotation { public final annotation class MyAnnotationWithParam : jet.Annotation {
public constructor MyAnnotationWithParam(/*0*/ value: test.AnnotationInParam.MyAnnotation?) public constructor MyAnnotationWithParam(/*0*/ value: test.AnnotationInParam.MyAnnotation)
public abstract fun value(): test.AnnotationInParam.MyAnnotation? public abstract fun value(): test.AnnotationInParam.MyAnnotation?
} }
public final annotation class MyAnnotationWithParam2 : jet.Annotation { public final annotation class MyAnnotationWithParam2 : jet.Annotation {
public constructor MyAnnotationWithParam2(/*0*/ value: test.AnnotationInParam.MyAnnotation2?) public constructor MyAnnotationWithParam2(/*0*/ value: test.AnnotationInParam.MyAnnotation2)
public abstract fun value(): test.AnnotationInParam.MyAnnotation2? public abstract fun value(): test.AnnotationInParam.MyAnnotation2?
} }
public final annotation class MyAnnotationWithParam3 : jet.Annotation { public final annotation class MyAnnotationWithParam3 : jet.Annotation {
public constructor MyAnnotationWithParam3(/*0*/ value: test.AnnotationInParam.MyAnnotation3?) public constructor MyAnnotationWithParam3(/*0*/ value: test.AnnotationInParam.MyAnnotation3)
public abstract fun value(): test.AnnotationInParam.MyAnnotation3? public abstract fun value(): test.AnnotationInParam.MyAnnotation3?
} }
} }
@@ -2,8 +2,8 @@ package test
public trait ArrayOfEnumInParam : java.lang.Object { public trait ArrayOfEnumInParam : java.lang.Object {
java.lang.annotation.Target(value = {ElementType.FIELD, ElementType.CONSTRUCTOR}: jet.Array<java.lang.annotation.ElementType>?) public final annotation class targetAnnotation : jet.Annotation { java.lang.annotation.Target(value = {ElementType.FIELD, ElementType.CONSTRUCTOR}: jet.Array<java.lang.annotation.ElementType>) public final annotation class targetAnnotation : jet.Annotation {
public constructor targetAnnotation(/*0*/ value: jet.String?) public constructor targetAnnotation(/*0*/ value: jet.String)
public abstract fun value(): jet.String? public abstract fun value(): jet.String?
} }
} }
@@ -2,12 +2,12 @@ package test
public trait ArrayOfStringInParam : java.lang.Object { public trait ArrayOfStringInParam : java.lang.Object {
test.ArrayOfStringInParam.MyAnnotation(value = {"a", "b", "c"}: jet.Array<jet.String>?) public open class A : java.lang.Object { test.ArrayOfStringInParam.MyAnnotation(value = {"a", "b", "c"}: jet.Array<jet.String>) public open class A : java.lang.Object {
public constructor A() public constructor A()
} }
public final annotation class MyAnnotation : jet.Annotation { public final annotation class MyAnnotation : jet.Annotation {
public constructor MyAnnotation(/*0*/ vararg value: jet.String? /*jet.Array<jet.String>?*/) public constructor MyAnnotation(/*0*/ vararg value: jet.String /*jet.Array<jet.String>*/)
public abstract fun value(): jet.Array<jet.String>? public abstract fun value(): jet.Array<jet.String>?
} }
} }
@@ -4,11 +4,11 @@ public open class ClassObjectArrayInParam : java.lang.Object {
public constructor ClassObjectArrayInParam() public constructor ClassObjectArrayInParam()
public final annotation class Anno : jet.Annotation { public final annotation class Anno : jet.Annotation {
public constructor Anno(/*0*/ vararg value: java.lang.Class<out jet.Any?>? /*jet.Array<java.lang.Class<out jet.Any?>>?*/) public constructor Anno(/*0*/ vararg value: java.lang.Class<out jet.Any?> /*jet.Array<java.lang.Class<out jet.Any?>>*/)
public abstract fun value(): jet.Array<java.lang.Class<out jet.Any?>>? public abstract fun value(): jet.Array<java.lang.Class<out jet.Any?>>?
} }
test.ClassObjectArrayInParam.Anno(value = {test.ClassObjectArrayInParam?.class, test.ClassObjectArrayInParam.Nested?.class, jet.String?.class}: jet.Array<java.lang.Class<out jet.Any?>>?) public open class Nested : java.lang.Object { test.ClassObjectArrayInParam.Anno(value = {test.ClassObjectArrayInParam?.class, test.ClassObjectArrayInParam.Nested?.class, jet.String?.class}: jet.Array<java.lang.Class<out jet.Any?>>) public open class Nested : java.lang.Object {
public constructor Nested() public constructor Nested()
} }
} }
@@ -4,7 +4,7 @@ public open class ClassObjectInParam : java.lang.Object {
public constructor ClassObjectInParam() public constructor ClassObjectInParam()
public final annotation class Anno : jet.Annotation { public final annotation class Anno : jet.Annotation {
public constructor Anno(/*0*/ value: java.lang.Class<out jet.Any?>?) public constructor Anno(/*0*/ value: java.lang.Class<out jet.Any?>)
public abstract fun value(): java.lang.Class<out jet.Any?>? public abstract fun value(): java.lang.Class<out jet.Any?>?
} }
@@ -3,7 +3,7 @@ package test
public trait CustomAnnotation : java.lang.Object { public trait CustomAnnotation : java.lang.Object {
public final annotation class MyAnnotation : jet.Annotation { public final annotation class MyAnnotation : jet.Annotation {
public constructor MyAnnotation(/*0*/ value: test.CustomAnnotation.MyEnum?) public constructor MyAnnotation(/*0*/ value: test.CustomAnnotation.MyEnum)
public abstract fun value(): test.CustomAnnotation.MyEnum? public abstract fun value(): test.CustomAnnotation.MyEnum?
} }
@@ -3,7 +3,7 @@ package test
public trait CustomAnnotationWithDefaultParameter : java.lang.Object { public trait CustomAnnotationWithDefaultParameter : java.lang.Object {
public final annotation class MyAnnotation : jet.Annotation { public final annotation class MyAnnotation : jet.Annotation {
public constructor MyAnnotation(/*0*/ first: jet.String?, /*1*/ second: jet.String? = ...) public constructor MyAnnotation(/*0*/ first: jet.String, /*1*/ second: jet.String = ...)
public abstract fun first(): jet.String? public abstract fun first(): jet.String?
public abstract fun second(): jet.String? public abstract fun second(): jet.String?
} }
@@ -2,12 +2,12 @@ package test
public trait EmptyArrayInParam : java.lang.Object { public trait EmptyArrayInParam : java.lang.Object {
test.EmptyArrayInParam.MyAnnotation(value = {}: jet.Array<jet.String>?) public open class A : java.lang.Object { test.EmptyArrayInParam.MyAnnotation(value = {}: jet.Array<jet.String>) public open class A : java.lang.Object {
public constructor A() public constructor A()
} }
public final annotation class MyAnnotation : jet.Annotation { public final annotation class MyAnnotation : jet.Annotation {
public constructor MyAnnotation(/*0*/ vararg value: jet.String? /*jet.Array<jet.String>?*/) public constructor MyAnnotation(/*0*/ vararg value: jet.String /*jet.Array<jet.String>*/)
public abstract fun value(): jet.Array<jet.String>? public abstract fun value(): jet.Array<jet.String>?
} }
} }
@@ -3,7 +3,7 @@ package test
public trait EnumInParam : java.lang.Object { public trait EnumInParam : java.lang.Object {
java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) public final annotation class RetentionAnnotation : jet.Annotation { java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) public final annotation class RetentionAnnotation : jet.Annotation {
public constructor RetentionAnnotation(/*0*/ value: jet.String?) public constructor RetentionAnnotation(/*0*/ value: jet.String)
public abstract fun value(): jet.String? public abstract fun value(): jet.String?
} }
} }
@@ -7,7 +7,7 @@ public trait PrimitiveValueInParam : java.lang.Object {
} }
public final annotation class Ann : jet.Annotation { public final annotation class Ann : jet.Annotation {
public constructor Ann(/*0*/ i: jet.Int, /*1*/ l: jet.Long, /*2*/ d: jet.Double, /*3*/ f: jet.Float, /*4*/ bool: jet.Boolean, /*5*/ str: jet.String?) public constructor Ann(/*0*/ i: jet.Int, /*1*/ l: jet.Long, /*2*/ d: jet.Double, /*3*/ f: jet.Float, /*4*/ bool: jet.Boolean, /*5*/ str: jet.String)
public abstract fun bool(): jet.Boolean public abstract fun bool(): jet.Boolean
public abstract fun d(): jet.Double public abstract fun d(): jet.Double
public abstract fun f(): jet.Float public abstract fun f(): jet.Float
@@ -3,12 +3,12 @@ package test
public trait RecursiveAnnotation : java.lang.Object { public trait RecursiveAnnotation : java.lang.Object {
test.RecursiveAnnotation.B(value = test.RecursiveAnnotation.A(value = "test": jet.String): test.RecursiveAnnotation.A) public final annotation class A : jet.Annotation { test.RecursiveAnnotation.B(value = test.RecursiveAnnotation.A(value = "test": jet.String): test.RecursiveAnnotation.A) public final annotation class A : jet.Annotation {
public constructor A(/*0*/ value: jet.String?) public constructor A(/*0*/ value: jet.String)
public abstract fun value(): jet.String? public abstract fun value(): jet.String?
} }
test.RecursiveAnnotation.B(value = test.RecursiveAnnotation.A(value = "test": jet.String): test.RecursiveAnnotation.A) public final annotation class B : jet.Annotation { test.RecursiveAnnotation.B(value = test.RecursiveAnnotation.A(value = "test": jet.String): test.RecursiveAnnotation.A) public final annotation class B : jet.Annotation {
public constructor B(/*0*/ value: test.RecursiveAnnotation.A?) public constructor B(/*0*/ value: test.RecursiveAnnotation.A)
public abstract fun value(): test.RecursiveAnnotation.A? public abstract fun value(): test.RecursiveAnnotation.A?
} }
} }
@@ -3,12 +3,12 @@ package test
public trait RecursiveAnnotation2 : java.lang.Object { public trait RecursiveAnnotation2 : java.lang.Object {
public final annotation class A : jet.Annotation { public final annotation class A : jet.Annotation {
public constructor A(/*0*/ value: test.RecursiveAnnotation2.B?) public constructor A(/*0*/ value: test.RecursiveAnnotation2.B)
public abstract fun value(): test.RecursiveAnnotation2.B? public abstract fun value(): test.RecursiveAnnotation2.B?
} }
test.RecursiveAnnotation2.A(value = test.RecursiveAnnotation2.B(value = "test": jet.String): test.RecursiveAnnotation2.B) public final annotation class B : jet.Annotation { test.RecursiveAnnotation2.A(value = test.RecursiveAnnotation2.B(value = "test": jet.String): test.RecursiveAnnotation2.B) public final annotation class B : jet.Annotation {
public constructor B(/*0*/ value: jet.String?) public constructor B(/*0*/ value: jet.String)
public abstract fun value(): jet.String? public abstract fun value(): jet.String?
} }
} }
@@ -3,7 +3,7 @@ package test
public trait StringConcatenationInParam : java.lang.Object { public trait StringConcatenationInParam : java.lang.Object {
public final annotation class Anno : jet.Annotation { public final annotation class Anno : jet.Annotation {
public constructor Anno(/*0*/ value: jet.String?) public constructor Anno(/*0*/ value: jet.String)
public abstract fun value(): jet.String? public abstract fun value(): jet.String?
} }
@@ -3,7 +3,7 @@ package test
public trait StringConstantInParam : java.lang.Object { public trait StringConstantInParam : java.lang.Object {
public final annotation class Anno : jet.Annotation { public final annotation class Anno : jet.Annotation {
public constructor Anno(/*0*/ value: jet.String?) public constructor Anno(/*0*/ value: jet.String)
public abstract fun value(): jet.String? public abstract fun value(): jet.String?
} }
@@ -3,7 +3,7 @@ package test
public trait StringInParam : java.lang.Object { public trait StringInParam : java.lang.Object {
public final annotation class Anno : jet.Annotation { public final annotation class Anno : jet.Annotation {
public constructor Anno(/*0*/ value: jet.String?) public constructor Anno(/*0*/ value: jet.String)
public abstract fun value(): jet.String? public abstract fun value(): jet.String?
} }
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.java.structure.JavaClass;
import org.jetbrains.jet.lang.resolve.java.structure.JavaMethod; import org.jetbrains.jet.lang.resolve.java.structure.JavaMethod;
import org.jetbrains.jet.lang.resolve.java.structure.JavaType; import org.jetbrains.jet.lang.resolve.java.structure.JavaType;
import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.*; import java.util.*;
@@ -159,9 +160,10 @@ public final class JavaConstructorResolver {
index, index,
Collections.<AnnotationDescriptor>emptyList(), Collections.<AnnotationDescriptor>emptyList(),
method.getName(), method.getName(),
typeTransformer.transformToType(returnType, typeVariableResolver), // Parameters of annotation constructors in Java are never nullable
TypeUtils.makeNotNullable(typeTransformer.transformToType(returnType, typeVariableResolver)),
method.hasAnnotationParameterDefaultValue(), method.hasAnnotationParameterDefaultValue(),
varargElementType)); varargElementType == null ? null : TypeUtils.makeNotNullable(varargElementType)));
index++; index++;
} }