Save annotations of lambda on SAM's method

Also add tests checking that annotations on 'invoke' methods of common lambdas are saved properly

 #KT-6932 Fixed
This commit is contained in:
Denis Zharkov
2015-05-12 10:45:06 +03:00
parent e078eaf15b
commit e98b9ea84e
9 changed files with 180 additions and 3 deletions
@@ -2209,17 +2209,22 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Nullable
private StackValue genSamInterfaceValue(
@NotNull final JetExpression expression,
@NotNull JetExpression probablyParenthesizedExpression,
@NotNull final JetVisitor<StackValue, StackValue> visitor
) {
final SamType samType = bindingContext.get(SAM_VALUE, expression);
if (samType == null) return null;
final JetExpression expression = JetPsiUtil.deparenthesize(probablyParenthesizedExpression);
final SamType samType = bindingContext.get(SAM_VALUE, probablyParenthesizedExpression);
if (samType == null || expression == null) return null;
if (expression instanceof JetFunctionLiteralExpression) {
return genClosure(((JetFunctionLiteralExpression) expression).getFunctionLiteral(), samType,
KotlinSyntheticClass.Kind.SAM_LAMBDA);
}
if (expression instanceof JetNamedFunction) {
return genClosure((JetNamedFunction) expression, samType, KotlinSyntheticClass.Kind.SAM_LAMBDA);
}
final Type asmType =
state.getSamWrapperClasses().getSamWrapperClass(samType, expression.getContainingJetFile(), getParentCodegen());