From 53edb83a56f8d502b94461652fea642fac5eafac Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 17 Jul 2015 18:56:29 +0300 Subject: [PATCH] Minor. More strict precondition for SAM adapter creation Descriptor should be initialized before creating SAM adapter --- .../java/sam/SingleAbstractMethodUtils.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java index 5e3f2dcb8f2..fc46df77c06 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java @@ -197,7 +197,7 @@ public class SingleAbstractMethodUtils { public void initialize( @NotNull List typeParameters, @NotNull List valueParameters, - @Nullable JetType returnType + @NotNull JetType returnType ) { result.initialize( null, @@ -220,7 +220,7 @@ public class SingleAbstractMethodUtils { public void initialize( @NotNull List typeParameters, @NotNull List valueParameters, - @Nullable JetType returnType + @NotNull JetType returnType ) { result.initialize(typeParameters, valueParameters, original.getVisibility()); result.setReturnType(returnType); @@ -237,15 +237,12 @@ public class SingleAbstractMethodUtils { TypeParameters typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter); JetType returnTypeUnsubstituted = original.getReturnType(); - JetType returnType; - if (returnTypeUnsubstituted == null) { // return type may be null for not yet initialized constructors - returnType = null; - } - else { - returnType = typeParameters.substitutor.substitute(returnTypeUnsubstituted, Variance.OUT_VARIANCE); - assert returnType != null : "couldn't substitute type: " + returnTypeUnsubstituted + + assert returnTypeUnsubstituted != null : "Creating SAM adapter for not initialized original: " + original; + + JetType returnType = typeParameters.substitutor.substitute(returnTypeUnsubstituted, Variance.OUT_VARIANCE); + assert returnType != null : "couldn't substitute type: " + returnTypeUnsubstituted + ", substitutor = " + typeParameters.substitutor; - } + List originalValueParameters = original.getValueParameters(); List valueParameters = new ArrayList(originalValueParameters.size()); @@ -330,7 +327,7 @@ public class SingleAbstractMethodUtils { public abstract void initialize( @NotNull List typeParameters, @NotNull List valueParameters, - @Nullable JetType returnType + @NotNull JetType returnType ); }