Resurrect assert for property default values in FULL mode
Respond to https://github.com/JetBrains/kotlin/commit/4980a3357231c833ebdb7111d16e7be5bd342521#commitcomment-7078429 #KT-5505 Fixed
This commit is contained in:
@@ -169,17 +169,19 @@ public class PropertyCodegen {
|
|||||||
Type type = typeMapper.mapType(descriptor);
|
Type type = typeMapper.mapType(descriptor);
|
||||||
String name = p.getName();
|
String name = p.getName();
|
||||||
assert name != null : "Annotation parameter has no name: " + p.getText();
|
assert name != null : "Annotation parameter has no name: " + p.getText();
|
||||||
MethodVisitor visitor = v.newMethod(OtherOrigin(p, descriptor), ACC_PUBLIC | ACC_ABSTRACT, name, "()" + type.getDescriptor(), null, null);
|
MethodVisitor mv = v.newMethod(OtherOrigin(p, descriptor), ACC_PUBLIC | ACC_ABSTRACT, name, "()" + type.getDescriptor(), null, null);
|
||||||
JetExpression defaultValue = p.getDefaultValue();
|
|
||||||
if (defaultValue != null) {
|
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
|
||||||
CompileTimeConstant<?> constant = ExpressionCodegen.getCompileTimeConstant(defaultValue, bindingContext);
|
JetExpression defaultValue = p.getDefaultValue();
|
||||||
if (constant != null) {
|
if (defaultValue != null) {
|
||||||
AnnotationCodegen annotationCodegen = AnnotationCodegen.forAnnotationDefaultValue(visitor, typeMapper);
|
CompileTimeConstant<?> constant = ExpressionCodegen.getCompileTimeConstant(defaultValue, bindingContext);
|
||||||
|
assert constant != null : "Default value for annotation parameter should be compile time value: " + defaultValue.getText();
|
||||||
|
AnnotationCodegen annotationCodegen = AnnotationCodegen.forAnnotationDefaultValue(mv, typeMapper);
|
||||||
annotationCodegen.generateAnnotationDefaultValue(constant, descriptor.getType());
|
annotationCodegen.generateAnnotationDefaultValue(constant, descriptor.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visitor.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean generateBackingField(@NotNull JetNamedDeclaration p, @NotNull PropertyDescriptor descriptor) {
|
private boolean generateBackingField(@NotNull JetNamedDeclaration p, @NotNull PropertyDescriptor descriptor) {
|
||||||
|
|||||||
Reference in New Issue
Block a user