Wise exception propagation for inlines errors
This commit is contained in:
@@ -132,13 +132,13 @@ public class InlineCodegen implements ParentCodegenAware, CallGenerator {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
String text = getNodeText(node);
|
||||
boolean generateNodeText = !(e instanceof InlineException);
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(bindingContext, this.codegen.getContext().getContextDescriptor());
|
||||
throw new CompilationException("Couldn't inline method call '" +
|
||||
functionDescriptor.getName() +
|
||||
"' into \n" + (element != null ? element.getText() : "null psi element " + this.codegen.getContext().getContextDescriptor()) +
|
||||
"\ncause: " +
|
||||
text, e, call.getCallElement());
|
||||
(generateNodeText ? ("\ncause: " + getNodeText(node)) : ""),
|
||||
e, call.getCallElement());
|
||||
}
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ public class InlineCodegen implements ParentCodegenAware, CallGenerator {
|
||||
codegen.getInlineNameGenerator().subGenerator(functionDescriptor.getName().asString()),
|
||||
codegen.getContext(), call, Collections.<String, String>emptyMap(), false, false);
|
||||
|
||||
MethodInliner inliner = new MethodInliner(node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule, "InlineCodegenRoot " + call.getCallElement()); //with captured
|
||||
MethodInliner inliner = new MethodInliner(node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule, "Method inlining " + call.getCallElement().getText()); //with captured
|
||||
|
||||
VarRemapper.ParamRemapper remapper = new VarRemapper.ParamRemapper(parameters, initialFrameSize);
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.codegen.inline;
|
||||
|
||||
public class InlineException extends RuntimeException {
|
||||
|
||||
public InlineException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InlineException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -94,9 +94,9 @@ public class MethodInliner {
|
||||
transformedNode.accept(visitor);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(errorPrefix + ": couldn't inline method call " + transformedNode + "\ncause: " +
|
||||
InlineCodegen.getNodeText(transformedNode), e);
|
||||
throw wrapException(e, transformedNode, "couldn't inline method call");
|
||||
}
|
||||
|
||||
visitor.visitLabel(end);
|
||||
|
||||
return result;
|
||||
@@ -277,8 +277,7 @@ public class MethodInliner {
|
||||
sources = analyzer.analyze("fake", node);
|
||||
}
|
||||
catch (AnalyzerException e) {
|
||||
throw new RuntimeException("Couldn't inline method call " + node + "\ncause: " +
|
||||
InlineCodegen.getNodeText(node), e);
|
||||
throw wrapException(e, node, "couldn't inline method call");
|
||||
}
|
||||
|
||||
AbstractInsnNode cur = node.instructions.getFirst();
|
||||
@@ -482,4 +481,14 @@ public class MethodInliner {
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
public RuntimeException wrapException(@NotNull Exception originalException, @NotNull MethodNode node, @NotNull String errorSuffix) {
|
||||
if (originalException instanceof InlineException) {
|
||||
return new InlineException(errorPrefix + ": " + errorSuffix, originalException);
|
||||
} else {
|
||||
return new InlineException(errorPrefix + ": " + errorSuffix + "\ncause: " +
|
||||
InlineCodegen.getNodeText(node), originalException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user