Diagnostric for default
This commit is contained in:
+24
@@ -18,11 +18,15 @@ package org.jetbrains.jet.lang.resolve.extension;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||||
import org.jetbrains.jet.lang.resolve.FunctionAnalyzerExtension;
|
import org.jetbrains.jet.lang.resolve.FunctionAnalyzerExtension;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class InlineAnalyzerExtension implements FunctionAnalyzerExtension.AnalyzerExtension {
|
public class InlineAnalyzerExtension implements FunctionAnalyzerExtension.AnalyzerExtension {
|
||||||
|
|
||||||
public static final InlineAnalyzerExtension INSTANCE = new InlineAnalyzerExtension();
|
public static final InlineAnalyzerExtension INSTANCE = new InlineAnalyzerExtension();
|
||||||
@@ -35,6 +39,10 @@ public class InlineAnalyzerExtension implements FunctionAnalyzerExtension.Analyz
|
|||||||
public void process(
|
public void process(
|
||||||
@NotNull final FunctionDescriptor descriptor, @NotNull JetNamedFunction function, @NotNull final BindingTrace trace
|
@NotNull final FunctionDescriptor descriptor, @NotNull JetNamedFunction function, @NotNull final BindingTrace trace
|
||||||
) {
|
) {
|
||||||
|
assert descriptor instanceof SimpleFunctionDescriptor && ((SimpleFunctionDescriptor) descriptor).isInline() :
|
||||||
|
"This method should be invoced on inline function: " + descriptor;
|
||||||
|
|
||||||
|
checkDefaults(descriptor, function, trace);
|
||||||
|
|
||||||
JetVisitorVoid visitor = new JetVisitorVoid() {
|
JetVisitorVoid visitor = new JetVisitorVoid() {
|
||||||
|
|
||||||
@@ -62,4 +70,20 @@ public class InlineAnalyzerExtension implements FunctionAnalyzerExtension.Analyz
|
|||||||
|
|
||||||
function.acceptChildren(visitor);
|
function.acceptChildren(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkDefaults(
|
||||||
|
@NotNull FunctionDescriptor functionDescriptor,
|
||||||
|
@NotNull JetFunction function,
|
||||||
|
@NotNull BindingTrace trace
|
||||||
|
) {
|
||||||
|
int index = 0;
|
||||||
|
List<JetParameter> jetParameters = function.getValueParameters();
|
||||||
|
for (ValueParameterDescriptor parameter : functionDescriptor.getValueParameters()) {
|
||||||
|
if (parameter.hasDefaultValue()) {
|
||||||
|
JetParameter jetParameter = jetParameters.get(index);
|
||||||
|
trace.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(jetParameter, jetParameter, functionDescriptor));
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,4 +23,18 @@ inline fun unsupported() {
|
|||||||
<!NOT_YET_SUPPORTED_IN_INLINE!>fun local() {
|
<!NOT_YET_SUPPORTED_IN_INLINE!>fun local() {
|
||||||
fun localInner() {}
|
fun localInner() {}
|
||||||
}<!>
|
}<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun unsupportedDefault(<!NOT_YET_SUPPORTED_IN_INLINE!>s : Int = 10<!>) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Base {
|
||||||
|
open fun foo(a: Int = 1) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Derived: Base() {
|
||||||
|
inline final override fun foo(<!NOT_YET_SUPPORTED_IN_INLINE!>a: Int<!>) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user