Resolve callable reference expressions
#KT-1183 In Progress
This commit is contained in:
@@ -226,6 +226,8 @@ public interface BindingContext {
|
||||
ReadOnlySlice<PsiElement, DeclarationDescriptor> DECLARATION_TO_DESCRIPTOR = Slices.<PsiElement, DeclarationDescriptor>sliceBuilder()
|
||||
.setFurtherLookupSlices(DECLARATIONS_TO_DESCRIPTORS).build();
|
||||
|
||||
WritableSlice<PsiElement, FunctionDescriptor> CALLABLE_REFERENCE = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<JetReferenceExpression, PsiElement> LABEL_TARGET = Slices.<JetReferenceExpression, PsiElement>sliceBuilder().build();
|
||||
WritableSlice<JetReferenceExpression, Collection<? extends PsiElement>> AMBIGUOUS_LABEL_TARGET =
|
||||
Slices.<JetReferenceExpression, Collection<? extends PsiElement>>sliceBuilder().build();
|
||||
|
||||
+8
-1
@@ -24,8 +24,11 @@ import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CallResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CheckValueArgumentsMode;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolveMode;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
|
||||
@@ -90,6 +93,8 @@ public class ArgumentTypeResolver {
|
||||
}
|
||||
|
||||
public void checkTypesWithNoCallee(@NotNull CallResolutionContext<?> context, @NotNull ResolveArgumentsMode resolveFunctionArgumentBodies) {
|
||||
if (context.checkArguments == CheckValueArgumentsMode.DISABLED) return;
|
||||
|
||||
for (ValueArgument valueArgument : context.call.getValueArguments()) {
|
||||
JetExpression argumentExpression = valueArgument.getArgumentExpression();
|
||||
if (argumentExpression != null && !(argumentExpression instanceof JetFunctionLiteralExpression)) {
|
||||
@@ -113,6 +118,8 @@ public class ArgumentTypeResolver {
|
||||
}
|
||||
|
||||
public void checkTypesForFunctionArgumentsWithNoCallee(@NotNull CallResolutionContext<?> context) {
|
||||
if (context.checkArguments == CheckValueArgumentsMode.DISABLED) return;
|
||||
|
||||
for (ValueArgument valueArgument : context.call.getValueArguments()) {
|
||||
JetExpression argumentExpression = valueArgument.getArgumentExpression();
|
||||
if (argumentExpression != null && (argumentExpression instanceof JetFunctionLiteralExpression)) {
|
||||
|
||||
+1
-1
@@ -189,7 +189,7 @@ public class CallExpressionResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ResolvedCallWithTrace<FunctionDescriptor> getResolvedCallForFunction(
|
||||
public ResolvedCallWithTrace<FunctionDescriptor> getResolvedCallForFunction(
|
||||
@NotNull Call call, @NotNull JetExpression callExpression,
|
||||
@NotNull ResolutionContext context, @NotNull ResolveMode resolveMode,
|
||||
@NotNull CheckValueArgumentsMode checkArguments, @NotNull ResolutionResultsCache resolutionResultsCache,
|
||||
|
||||
+146
-2
@@ -24,6 +24,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorUtil;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
@@ -32,13 +34,17 @@ import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CheckValueArgumentsMode;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ExpressionPosition;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionResultsCache;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolveMode;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.ExpressionAsFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.constants.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
@@ -46,17 +52,21 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.checker.TypeCheckingProcedure;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.utils.ThrowingList;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getStaticNestedClassesScope;
|
||||
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
import static org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils.*;
|
||||
@@ -564,8 +574,142 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
@Override
|
||||
public JetTypeInfo visitCallableReferenceExpression(JetCallableReferenceExpression expression, ExpressionTypingContext context) {
|
||||
context.trace.report(UNSUPPORTED.on(expression, getClass().getCanonicalName()));
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
JetTypeReference typeReference = expression.getTypeReference();
|
||||
|
||||
JetType receiverType =
|
||||
typeReference == null
|
||||
? null
|
||||
: context.expressionTypingServices.getTypeResolver().resolveType(context.scope, typeReference, context.trace, false);
|
||||
|
||||
JetSimpleNameExpression callableReference = expression.getCallableReference();
|
||||
if (callableReference.getReferencedName().isEmpty()) {
|
||||
context.trace.report(UNRESOLVED_REFERENCE.on(callableReference, callableReference));
|
||||
JetType errorType = ErrorUtils.createErrorType("Empty callable reference");
|
||||
return DataFlowUtils.checkType(errorType, expression, context, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
JetType result = getCallableReferenceType(expression, receiverType, context);
|
||||
return DataFlowUtils.checkType(result, expression, context, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static JetType getCallableReferenceType(
|
||||
@NotNull JetCallableReferenceExpression expression,
|
||||
@Nullable JetType lhsType,
|
||||
@NotNull ExpressionTypingContext context
|
||||
) {
|
||||
JetSimpleNameExpression reference = expression.getCallableReference();
|
||||
|
||||
boolean[] result = new boolean[1];
|
||||
FunctionDescriptor descriptor = resolveCallableReferenceTarget(lhsType, context, expression, result);
|
||||
|
||||
if (!result[0]) {
|
||||
context.trace.report(UNRESOLVED_REFERENCE.on(reference, reference));
|
||||
}
|
||||
if (descriptor == null) return null;
|
||||
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor expectedThisObject = descriptor.getExpectedThisObject();
|
||||
if (receiverParameter != null && expectedThisObject != null) {
|
||||
// TODO: report "extensions in classes" are not supported
|
||||
context.trace.report(UNRESOLVED_REFERENCE.on(reference, reference));
|
||||
return null;
|
||||
}
|
||||
|
||||
JetType receiverType = null;
|
||||
if (receiverParameter != null) {
|
||||
receiverType = receiverParameter.getType();
|
||||
}
|
||||
else if (expectedThisObject != null) {
|
||||
receiverType = expectedThisObject.getType();
|
||||
}
|
||||
|
||||
//noinspection ConstantConditions
|
||||
JetType type = KotlinBuiltIns.getInstance().getKFunctionType(
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
receiverType,
|
||||
DescriptorUtils.getValueParametersTypes(descriptor.getValueParameters()),
|
||||
descriptor.getReturnType(),
|
||||
receiverParameter != null
|
||||
);
|
||||
|
||||
ExpressionAsFunctionDescriptor functionDescriptor = new ExpressionAsFunctionDescriptor(
|
||||
context.scope.getContainingDeclaration(),
|
||||
Name.special("<callable-reference>")
|
||||
);
|
||||
FunctionDescriptorUtil.initializeFromFunctionType(functionDescriptor, type, null, Modality.FINAL, Visibilities.PUBLIC);
|
||||
|
||||
context.trace.record(CALLABLE_REFERENCE, expression, functionDescriptor);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static FunctionDescriptor resolveCallableReferenceTarget(
|
||||
@Nullable JetType lhsType,
|
||||
@NotNull ExpressionTypingContext context,
|
||||
@NotNull JetCallableReferenceExpression expression,
|
||||
@NotNull boolean[] result
|
||||
) {
|
||||
JetSimpleNameExpression reference = expression.getCallableReference();
|
||||
|
||||
if (lhsType == null) {
|
||||
return resolveCallableNotCheckingArguments(reference, NO_RECEIVER, context, result);
|
||||
}
|
||||
|
||||
ClassifierDescriptor classifier = lhsType.getConstructor().getDeclarationDescriptor();
|
||||
// TODO: report an error if the classifier is not a class
|
||||
assert classifier instanceof ClassDescriptor : "TODO";
|
||||
|
||||
ReceiverValue receiver = new TransientReceiver(lhsType);
|
||||
TemporaryBindingTrace traceWithReceiver = TemporaryBindingTrace.create(context.trace,
|
||||
"trace to resolve callable reference with receiver", reference);
|
||||
FunctionDescriptor descriptor =
|
||||
resolveCallableNotCheckingArguments(reference, receiver, context.replaceBindingTrace(traceWithReceiver), result);
|
||||
if (result[0]) {
|
||||
traceWithReceiver.commit();
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
JetScope staticScope = getStaticNestedClassesScope((ClassDescriptor) classifier);
|
||||
TemporaryBindingTrace traceForStatic = TemporaryBindingTrace.create(context.trace,
|
||||
"trace to resolve callable reference in static scope", reference);
|
||||
FunctionDescriptor possibleStaticNestedClassConstructor = resolveCallableNotCheckingArguments(reference, NO_RECEIVER,
|
||||
context.replaceBindingTrace(traceForStatic).replaceScope(staticScope), result);
|
||||
if (result[0]) {
|
||||
traceForStatic.commit();
|
||||
return possibleStaticNestedClassConstructor;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static FunctionDescriptor resolveCallableNotCheckingArguments(
|
||||
@NotNull JetSimpleNameExpression reference,
|
||||
@NotNull ReceiverValue receiver,
|
||||
@NotNull ExpressionTypingContext context,
|
||||
@NotNull boolean[] result
|
||||
) {
|
||||
Call call = CallMaker.makeCall(reference, receiver, null, reference, ThrowingList.<ValueArgument>instance());
|
||||
|
||||
TemporaryBindingTrace trace = TemporaryBindingTrace.create(context.trace, "trace to resolve as function", reference);
|
||||
|
||||
ExpressionTypingContext contextForResolve = context.replaceBindingTrace(trace).replaceExpectedType(NO_EXPECTED_TYPE);
|
||||
ResolvedCallWithTrace<FunctionDescriptor> function = contextForResolve.expressionTypingServices.getCallExpressionResolver()
|
||||
.getResolvedCallForFunction(call, reference, contextForResolve, ResolveMode.TOP_LEVEL_CALL,
|
||||
CheckValueArgumentsMode.DISABLED, ResolutionResultsCache.create(), result);
|
||||
if (!result[0]) return null;
|
||||
|
||||
if (function instanceof VariableAsFunctionResolvedCall) {
|
||||
// TODO: KProperty
|
||||
context.trace.report(UNSUPPORTED.on(reference, "References to variables aren't supported yet"));
|
||||
context.trace.report(UNRESOLVED_REFERENCE.on(reference, reference));
|
||||
return null;
|
||||
}
|
||||
|
||||
trace.commit();
|
||||
return function != null ? function.getResultingDescriptor() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -792,6 +792,57 @@ public class KotlinBuiltIns {
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull List<JetType> parameterTypes,
|
||||
@NotNull JetType returnType
|
||||
) {
|
||||
List<TypeProjection> arguments = getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType);
|
||||
int size = parameterTypes.size();
|
||||
ClassDescriptor classDescriptor = receiverType == null ? getFunction(size) : getExtensionFunction(size);
|
||||
TypeConstructor constructor = classDescriptor.getTypeConstructor();
|
||||
|
||||
return new JetTypeImpl(annotations, constructor, false, arguments, classDescriptor.getMemberScope(arguments));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getKFunctionType(
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull List<JetType> parameterTypes,
|
||||
@NotNull JetType returnType,
|
||||
boolean extensionFunction
|
||||
) {
|
||||
List<TypeProjection> arguments = getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType);
|
||||
ClassDescriptor classDescriptor = getCorrespondingKFunctionClass(receiverType, extensionFunction, parameterTypes.size());
|
||||
|
||||
return new JetTypeImpl(
|
||||
annotations,
|
||||
classDescriptor.getTypeConstructor(),
|
||||
false,
|
||||
arguments,
|
||||
classDescriptor.getMemberScope(arguments)
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ClassDescriptor getCorrespondingKFunctionClass(
|
||||
@Nullable JetType receiverType,
|
||||
boolean extensionFunction,
|
||||
int numberOfParameters
|
||||
) {
|
||||
if (receiverType == null) {
|
||||
return getKFunction(numberOfParameters);
|
||||
}
|
||||
else if (extensionFunction) {
|
||||
return getKExtensionFunction(numberOfParameters);
|
||||
}
|
||||
else {
|
||||
return getKMemberFunction(numberOfParameters);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<TypeProjection> getFunctionTypeArgumentProjections(
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull List<JetType> parameterTypes,
|
||||
@NotNull JetType returnType
|
||||
) {
|
||||
List<TypeProjection> arguments = new ArrayList<TypeProjection>();
|
||||
if (receiverType != null) {
|
||||
@@ -801,10 +852,7 @@ public class KotlinBuiltIns {
|
||||
arguments.add(defaultProjection(parameterType));
|
||||
}
|
||||
arguments.add(defaultProjection(returnType));
|
||||
int size = parameterTypes.size();
|
||||
ClassDescriptor classDescriptor = receiverType == null ? getFunction(size) : getExtensionFunction(size);
|
||||
TypeConstructor constructor = classDescriptor.getTypeConstructor();
|
||||
return new JetTypeImpl(annotations, constructor, false, arguments, classDescriptor.getMemberScope(arguments));
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private static TypeProjection defaultProjection(JetType returnType) {
|
||||
@@ -841,17 +889,29 @@ public class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
public boolean isFunctionType(@NotNull JetType type) {
|
||||
return setContainsClassOf(functionClassesSet, type);
|
||||
if (setContainsClassOf(functionClassesSet, type)) return true;
|
||||
|
||||
for (JetType superType : type.getConstructor().getSupertypes()) {
|
||||
if (isFunctionType(superType)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isExtensionFunctionType(@NotNull JetType type) {
|
||||
return setContainsClassOf(extensionFunctionClassesSet, type);
|
||||
if (setContainsClassOf(extensionFunctionClassesSet, type)) return true;
|
||||
|
||||
for (JetType superType : type.getConstructor().getSupertypes()) {
|
||||
if (isExtensionFunctionType(superType)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetType getReceiverType(@NotNull JetType type) {
|
||||
assert isFunctionOrExtensionFunctionType(type) : type;
|
||||
if (setContainsClassOf(extensionFunctionClassesSet, type)) {
|
||||
if (isExtensionFunctionType(type)) {
|
||||
return type.getArguments().get(0).getType();
|
||||
}
|
||||
return null;
|
||||
@@ -883,7 +943,7 @@ public class KotlinBuiltIns {
|
||||
public List<TypeProjection> getParameterTypeProjectionsFromFunctionType(@NotNull JetType type) {
|
||||
assert isFunctionOrExtensionFunctionType(type);
|
||||
List<TypeProjection> arguments = type.getArguments();
|
||||
int first = setContainsClassOf(extensionFunctionClassesSet, type) ? 1 : 0;
|
||||
int first = isExtensionFunctionType(type) ? 1 : 0;
|
||||
int last = arguments.size() - 2;
|
||||
List<TypeProjection> parameterTypes = Lists.newArrayList();
|
||||
for (int i = first; i <= last; i++) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
trait A
|
||||
abstract class B
|
||||
annotation class C
|
||||
enum class D
|
||||
|
||||
fun main() {
|
||||
::<!UNRESOLVED_REFERENCE!>A<!>
|
||||
::<!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B<!>
|
||||
::C // KT-3465
|
||||
::<!INVISIBLE_MEMBER!>D<!>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun foo(x: Int, <!UNUSED_PARAMETER!>y<!>: Any) = x
|
||||
fun foo(<!UNUSED_PARAMETER!>x<!>: Any, y: Int) = y
|
||||
|
||||
fun main() {
|
||||
::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
|
||||
|
||||
::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> : (Int, Any) -> Unit
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class A {
|
||||
fun main() {
|
||||
val x = ::A
|
||||
|
||||
x : KFunction0<A>
|
||||
}
|
||||
}
|
||||
|
||||
class SomeOtherClass {
|
||||
fun main() {
|
||||
val x = ::A
|
||||
|
||||
x : KFunction0<A>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class A
|
||||
class B
|
||||
|
||||
fun A.ext() {
|
||||
val x = ::A
|
||||
val y = ::B
|
||||
|
||||
x : KFunction0<A>
|
||||
y : KFunction0<B>
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
class A
|
||||
|
||||
class B {
|
||||
fun A.ext() {
|
||||
val x = ::A
|
||||
val y = ::B
|
||||
|
||||
x : KFunction0<A>
|
||||
y : KFunction0<B>
|
||||
}
|
||||
|
||||
fun B.ext() {
|
||||
val x = ::A
|
||||
val y = ::B
|
||||
|
||||
x : KFunction0<A>
|
||||
y : KFunction0<B>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
val x = ::A
|
||||
|
||||
x : KFunction0<A>
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package first
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package other
|
||||
|
||||
import first.A
|
||||
|
||||
fun main() {
|
||||
val x = first.A::foo
|
||||
val y = first.A::bar
|
||||
val z = A::baz
|
||||
|
||||
x : KMemberFunction0<A, Unit>
|
||||
y : KMemberFunction1<A, Int, Unit>
|
||||
z : KMemberFunction0<A, String>
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package first
|
||||
|
||||
class A
|
||||
|
||||
fun A.foo() {}
|
||||
fun A.bar() {}
|
||||
fun A.baz() {}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package other
|
||||
|
||||
import first.A
|
||||
import first.foo
|
||||
|
||||
fun main() {
|
||||
val x = first.A::foo
|
||||
first.A::<!UNRESOLVED_REFERENCE!>bar<!>
|
||||
A::<!UNRESOLVED_REFERENCE!>baz<!>
|
||||
|
||||
x : KExtensionFunction0<A, Unit>
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package first
|
||||
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package other
|
||||
|
||||
import first.foo
|
||||
import first.bar
|
||||
import first.baz
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KFunction0<Unit>
|
||||
y : KFunction1<Int, Unit>
|
||||
z : KFunction0<String>
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
val x = :: <!SYNTAX!><!>;
|
||||
val y = A::
|
||||
<!SYNTAX!><!>}
|
||||
@@ -0,0 +1,15 @@
|
||||
class A {
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KExtensionFunction0<A, Unit>
|
||||
y : KExtensionFunction1<A, Int, Unit>
|
||||
z : KExtensionFunction0<A, String>
|
||||
}
|
||||
}
|
||||
|
||||
fun A.foo() {}
|
||||
fun A.bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun A.baz() = "OK"
|
||||
@@ -0,0 +1,15 @@
|
||||
class A
|
||||
|
||||
fun A.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KExtensionFunction0<A, Unit>
|
||||
y : KExtensionFunction1<A, Int, Unit>
|
||||
z : KExtensionFunction0<A, String>
|
||||
}
|
||||
|
||||
fun A.foo() {}
|
||||
fun A.bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun A.baz() = "OK"
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class B
|
||||
|
||||
class A {
|
||||
fun B.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KExtensionFunction0<A, Unit>
|
||||
y : KExtensionFunction1<A, Int, Unit>
|
||||
z : KExtensionFunction0<A, String>
|
||||
}
|
||||
}
|
||||
|
||||
fun A.foo() {}
|
||||
fun A.bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun A.baz() = "OK"
|
||||
@@ -0,0 +1,15 @@
|
||||
class A
|
||||
|
||||
fun A.foo() {}
|
||||
fun A.bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun A.baz() = "OK"
|
||||
|
||||
fun main() {
|
||||
val x = A::foo
|
||||
val y = A::bar
|
||||
val z = A::baz
|
||||
|
||||
x : KExtensionFunction0<A, Unit>
|
||||
y : KExtensionFunction1<A, Int, Unit>
|
||||
z : KExtensionFunction0<A, String>
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class A<T>(val t: T) {
|
||||
fun foo(): T = t
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
val x = A<String>::foo
|
||||
|
||||
x : KMemberFunction0<A<String>, String>
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import A.Inner
|
||||
|
||||
class A {
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
fun main() {
|
||||
::<!UNRESOLVED_REFERENCE!>Inner<!>
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
class A {
|
||||
inner class Inner
|
||||
|
||||
fun main() {
|
||||
val x = ::Inner
|
||||
val y = A::Inner
|
||||
|
||||
x : KMemberFunction0<A, A.Inner>
|
||||
y : KMemberFunction0<A, Inner>
|
||||
}
|
||||
|
||||
class object {
|
||||
fun main() {
|
||||
::<!UNRESOLVED_REFERENCE!>Inner<!>
|
||||
val y = A::Inner
|
||||
|
||||
y : KMemberFunction0<A, A.Inner>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
fun main() {
|
||||
::<!UNRESOLVED_REFERENCE!>Inner<!>
|
||||
val y = A::Inner
|
||||
|
||||
y : KMemberFunction0<A, A.Inner>
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
class A {
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
fun A.main() {
|
||||
val x = ::Inner
|
||||
val y = A::Inner
|
||||
|
||||
x : KMemberFunction0<A, A.Inner>
|
||||
y : KMemberFunction0<A, A.Inner>
|
||||
}
|
||||
|
||||
fun Int.main() {
|
||||
::<!UNRESOLVED_REFERENCE!>Inner<!>
|
||||
val y = A::Inner
|
||||
|
||||
y : KMemberFunction0<A, A.Inner>
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class A {
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
fun main() {
|
||||
::<!UNRESOLVED_REFERENCE!>Inner<!>
|
||||
val y = A::Inner
|
||||
|
||||
y : KMemberFunction0<A, A.Inner>
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun main() {
|
||||
class A
|
||||
|
||||
val x = ::A
|
||||
x : KFunction0<A>
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
fun main() {
|
||||
class A
|
||||
|
||||
class B {
|
||||
fun Int.foo() {
|
||||
val x = ::A
|
||||
x : KFunction0<A>
|
||||
}
|
||||
fun A.foo() {
|
||||
val x = ::A
|
||||
x : KFunction0<A>
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun main() {
|
||||
class A
|
||||
|
||||
class B {
|
||||
val x = ::A
|
||||
val f: KFunction0<A> = x
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fun main() {
|
||||
class A
|
||||
|
||||
fun A.foo() {
|
||||
val x = ::A
|
||||
x : KFunction0<A>
|
||||
}
|
||||
|
||||
fun Int.foo() {
|
||||
val x = ::A
|
||||
x : KFunction0<A>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fun main() {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KFunction0<Unit>
|
||||
y : KFunction1<Int, Unit>
|
||||
z : KFunction0<String>
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
class B {
|
||||
fun A.ext() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KFunction0<Unit>
|
||||
y : KFunction1<Int, Unit>
|
||||
z : KFunction0<String>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
fun main() {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
class A {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
fun main() {
|
||||
x : KFunction0<Unit>
|
||||
y : KFunction1<Int, Unit>
|
||||
z : KFunction0<String>
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
fun A.ext() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KFunction0<Unit>
|
||||
y : KFunction1<Int, Unit>
|
||||
z : KFunction0<String>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package a.b.c
|
||||
|
||||
class D {
|
||||
fun foo() = 42
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
fun main() {
|
||||
val x = a.b.c.D::foo
|
||||
|
||||
x : KMemberFunction0<a.b.c.D, Int>
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package a.b.c
|
||||
|
||||
class D<E, F> {
|
||||
fun foo(<!UNUSED_PARAMETER!>e<!>: E, <!UNUSED_PARAMETER!>f<!>: F) = this
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
fun main() {
|
||||
val x = a.b.c.D<String, Int>::foo
|
||||
|
||||
x : KMemberFunction2<a.b.c.D<String, Int>, String, Int, a.b.c.D<String, Int>>
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KMemberFunction0<A, Unit>
|
||||
y : KMemberFunction1<A, Int, Unit>
|
||||
z : KMemberFunction0<A, String>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
}
|
||||
|
||||
fun A.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KMemberFunction0<A, Unit>
|
||||
y : KMemberFunction1<A, Int, Unit>
|
||||
z : KMemberFunction0<A, String>
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
}
|
||||
|
||||
class B {
|
||||
fun A.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KMemberFunction0<A, Unit>
|
||||
y : KMemberFunction1<A, Int, Unit>
|
||||
z : KMemberFunction0<A, String>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val x = A::foo
|
||||
val y = A::bar
|
||||
val z = A::baz
|
||||
|
||||
x : KMemberFunction0<A, Unit>
|
||||
y : KMemberFunction1<A, Int, Unit>
|
||||
z : KMemberFunction0<A, String>
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
class A {
|
||||
class Nested
|
||||
|
||||
fun main() {
|
||||
val x = ::Nested
|
||||
val y = A::Nested
|
||||
|
||||
x : KFunction0<Nested>
|
||||
y : KFunction0<Nested>
|
||||
}
|
||||
|
||||
class object {
|
||||
fun main() {
|
||||
::<!UNRESOLVED_REFERENCE!>Nested<!> // KT-3261
|
||||
val y = A::Nested
|
||||
|
||||
y : KFunction0<A.Nested>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
fun main() {
|
||||
::<!UNRESOLVED_REFERENCE!>Nested<!>
|
||||
val y = A::Nested
|
||||
|
||||
y : KFunction0<A.Nested>
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class A {
|
||||
class Nested
|
||||
}
|
||||
|
||||
fun A.main() {
|
||||
::<!UNRESOLVED_REFERENCE!>Nested<!>
|
||||
val y = A::Nested
|
||||
|
||||
y : KFunction0<A.Nested>
|
||||
}
|
||||
|
||||
fun Int.main() {
|
||||
::<!UNRESOLVED_REFERENCE!>Nested<!>
|
||||
val y = A::Nested
|
||||
|
||||
y : KFunction0<A.Nested>
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class A {
|
||||
class Nested
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val x = A::Nested
|
||||
|
||||
x : KFunction0<A.Nested>
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun bar() = 42
|
||||
|
||||
fun main() {
|
||||
fun bar() = 239
|
||||
|
||||
::bar
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class A {
|
||||
fun foo() = 42
|
||||
}
|
||||
|
||||
fun A.foo() {}
|
||||
|
||||
fun main() {
|
||||
val x = A::foo
|
||||
|
||||
x : KMemberFunction0<A, Int>
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fun foo() {}
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
|
||||
x : KMemberFunction0<A, Unit>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package other
|
||||
|
||||
fun foo() {}
|
||||
|
||||
class A {
|
||||
fun bar() = 42
|
||||
}
|
||||
|
||||
fun A.baz(<!UNUSED_PARAMETER!>x<!>: String) {}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
import other.foo as foofoo
|
||||
import other.A as AA
|
||||
import other.baz as bazbaz
|
||||
|
||||
fun main() {
|
||||
val x = ::foofoo
|
||||
val y = AA::bar
|
||||
val z = AA::bazbaz
|
||||
|
||||
x : KFunction0<Unit>
|
||||
y : KMemberFunction0<AA, Int>
|
||||
z : KExtensionFunction1<AA, String, Unit>
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
class A {
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KFunction0<Unit>
|
||||
y : KFunction1<Int, Unit>
|
||||
z : KFunction0<String>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class A
|
||||
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
fun A.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KFunction0<Unit>
|
||||
y : KFunction1<Int, Unit>
|
||||
z : KFunction0<String>
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class A
|
||||
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
class B {
|
||||
fun A.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KFunction0<Unit>
|
||||
y : KFunction1<Int, Unit>
|
||||
z : KFunction0<String>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
x : KFunction0<Unit>
|
||||
y : KFunction1<Int, Unit>
|
||||
z : KFunction0<String>
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
val <!UNUSED_VARIABLE!>foo<!> = ::<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
|
||||
::<!UNRESOLVED_REFERENCE!>bar<!>
|
||||
|
||||
A::<!UNRESOLVED_REFERENCE!>bar<!>
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>B<!>::<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>bar<!>
|
||||
}
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve;
|
||||
@InnerTestClasses({JetDiagnosticsTestGenerated.Tests.class, JetDiagnosticsTestGenerated.Script.class})
|
||||
public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEagerResolve {
|
||||
@TestMetadata("compiler/testData/diagnostics/tests")
|
||||
@InnerTestClasses({Tests.Annotations.class, Tests.BackingField.class, Tests.Cast.class, Tests.CheckArguments.class, Tests.ControlFlowAnalysis.class, Tests.ControlStructures.class, Tests.DataClasses.class, Tests.DataFlow.class, Tests.DataFlowInfoTraversal.class, Tests.DeclarationChecks.class, Tests.Deparenthesize.class, Tests.Enum.class, Tests.Extensions.class, Tests.FunctionLiterals.class, Tests.Generics.class, Tests.IncompleteCode.class, Tests.Inference.class, Tests.Infos.class, Tests.Inner.class, Tests.J_k.class, Tests.Jdk_annotations.class, Tests.Library.class, Tests.NullabilityAndAutoCasts.class, Tests.NullableTypes.class, Tests.Objects.class, Tests.OperatorsOverloading.class, Tests.Overload.class, Tests.Override.class, Tests.Recovery.class, Tests.Redeclarations.class, Tests.Regressions.class, Tests.Resolve.class, Tests.Scopes.class, Tests.SenselessComparison.class, Tests.Shadowing.class, Tests.SmartCasts.class, Tests.Substitutions.class, Tests.Subtyping.class, Tests.ThisAndSuper.class, Tests.Varargs.class})
|
||||
@InnerTestClasses({Tests.Annotations.class, Tests.BackingField.class, Tests.CallableReference.class, Tests.Cast.class, Tests.CheckArguments.class, Tests.ControlFlowAnalysis.class, Tests.ControlStructures.class, Tests.DataClasses.class, Tests.DataFlow.class, Tests.DataFlowInfoTraversal.class, Tests.DeclarationChecks.class, Tests.Deparenthesize.class, Tests.Enum.class, Tests.Extensions.class, Tests.FunctionLiterals.class, Tests.Generics.class, Tests.IncompleteCode.class, Tests.Inference.class, Tests.Infos.class, Tests.Inner.class, Tests.J_k.class, Tests.Jdk_annotations.class, Tests.Library.class, Tests.NullabilityAndAutoCasts.class, Tests.NullableTypes.class, Tests.Objects.class, Tests.OperatorsOverloading.class, Tests.Overload.class, Tests.Override.class, Tests.Recovery.class, Tests.Redeclarations.class, Tests.Regressions.class, Tests.Resolve.class, Tests.Scopes.class, Tests.SenselessComparison.class, Tests.Shadowing.class, Tests.SmartCasts.class, Tests.Substitutions.class, Tests.Subtyping.class, Tests.ThisAndSuper.class, Tests.Varargs.class})
|
||||
public static class Tests extends AbstractDiagnosticsTestWithEagerResolve {
|
||||
@TestMetadata("Abstract.kt")
|
||||
public void testAbstract() throws Exception {
|
||||
@@ -705,6 +705,239 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/callableReference")
|
||||
public static class CallableReference extends AbstractDiagnosticsTestWithEagerResolve {
|
||||
@TestMetadata("abstractClassConstructors.kt")
|
||||
public void testAbstractClassConstructors() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/abstractClassConstructors.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCallableReference() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/callableReference"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("ambiguityTopLevelVsTopLevel.kt")
|
||||
public void testAmbiguityTopLevelVsTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/ambiguityTopLevelVsTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorFromClass.kt")
|
||||
public void testConstructorFromClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/constructorFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorFromExtension.kt")
|
||||
public void testConstructorFromExtension() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/constructorFromExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorFromExtensionInClass.kt")
|
||||
public void testConstructorFromExtensionInClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/constructorFromExtensionInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorFromTopLevel.kt")
|
||||
public void testConstructorFromTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/constructorFromTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("differentPackageClass.kt")
|
||||
public void testDifferentPackageClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/differentPackageClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("differentPackageExtension.kt")
|
||||
public void testDifferentPackageExtension() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/differentPackageExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("differentPackageTopLevel.kt")
|
||||
public void testDifferentPackageTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/differentPackageTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("empty.kt")
|
||||
public void testEmpty() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/empty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFromClass.kt")
|
||||
public void testExtensionFromClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/extensionFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFromExtension.kt")
|
||||
public void testExtensionFromExtension() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/extensionFromExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFromExtensionInClass.kt")
|
||||
public void testExtensionFromExtensionInClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/extensionFromExtensionInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFromTopLevel.kt")
|
||||
public void testExtensionFromTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/extensionFromTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericClassFromTopLevel.kt")
|
||||
public void testGenericClassFromTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/genericClassFromTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("importedInnerConstructor.kt")
|
||||
public void testImportedInnerConstructor() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/importedInnerConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerConstructorFromClass.kt")
|
||||
public void testInnerConstructorFromClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/innerConstructorFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerConstructorFromExtension.kt")
|
||||
public void testInnerConstructorFromExtension() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/innerConstructorFromExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerConstructorFromTopLevel.kt")
|
||||
public void testInnerConstructorFromTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/innerConstructorFromTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localConstructor.kt")
|
||||
public void testLocalConstructor() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/localConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localConstructorFromExtensionInLocalClass.kt")
|
||||
public void testLocalConstructorFromExtensionInLocalClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/localConstructorFromExtensionInLocalClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localConstructorFromLocalClass.kt")
|
||||
public void testLocalConstructorFromLocalClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/localConstructorFromLocalClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localConstructorFromLocalExtension.kt")
|
||||
public void testLocalConstructorFromLocalExtension() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/localConstructorFromLocalExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localNamedFun.kt")
|
||||
public void testLocalNamedFun() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/localNamedFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localNamedFunFromExtensionInLocalClass.kt")
|
||||
public void testLocalNamedFunFromExtensionInLocalClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/localNamedFunFromExtensionInLocalClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localNamedFunFromLocalClass.kt")
|
||||
public void testLocalNamedFunFromLocalClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/localNamedFunFromLocalClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localNamedFunFromLocalExtension.kt")
|
||||
public void testLocalNamedFunFromLocalExtension() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/localNamedFunFromLocalExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("longQualifiedName.kt")
|
||||
public void testLongQualifiedName() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/longQualifiedName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("longQualifiedNameGeneric.kt")
|
||||
public void testLongQualifiedNameGeneric() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/longQualifiedNameGeneric.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberFromClass.kt")
|
||||
public void testMemberFromClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/memberFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberFromExtension.kt")
|
||||
public void testMemberFromExtension() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/memberFromExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberFromExtensionInClass.kt")
|
||||
public void testMemberFromExtensionInClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/memberFromExtensionInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberFromTopLevel.kt")
|
||||
public void testMemberFromTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/memberFromTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedConstructorFromClass.kt")
|
||||
public void testNestedConstructorFromClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/nestedConstructorFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedConstructorFromExtension.kt")
|
||||
public void testNestedConstructorFromExtension() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/nestedConstructorFromExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedConstructorFromTopLevel.kt")
|
||||
public void testNestedConstructorFromTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/nestedConstructorFromTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noAmbiguityLocalVsTopLevel.kt")
|
||||
public void testNoAmbiguityLocalVsTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/noAmbiguityLocalVsTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noAmbiguityMemberVsExtension.kt")
|
||||
public void testNoAmbiguityMemberVsExtension() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/noAmbiguityMemberVsExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noAmbiguityMemberVsTopLevel.kt")
|
||||
public void testNoAmbiguityMemberVsTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/noAmbiguityMemberVsTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("renameOnImport.kt")
|
||||
public void testRenameOnImport() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/renameOnImport.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFromClass.kt")
|
||||
public void testTopLevelFromClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/topLevelFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFromExtension.kt")
|
||||
public void testTopLevelFromExtension() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/topLevelFromExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFromExtensionInClass.kt")
|
||||
public void testTopLevelFromExtensionInClass() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/topLevelFromExtensionInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFromTopLevel.kt")
|
||||
public void testTopLevelFromTopLevel() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/topLevelFromTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unresolved.kt")
|
||||
public void testUnresolved() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/callableReference/unresolved.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/cast")
|
||||
public static class Cast extends AbstractDiagnosticsTestWithEagerResolve {
|
||||
public void testAllFilesPresentInCast() throws Exception {
|
||||
@@ -4500,6 +4733,7 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
suite.addTestSuite(Tests.class);
|
||||
suite.addTestSuite(Annotations.class);
|
||||
suite.addTestSuite(BackingField.class);
|
||||
suite.addTestSuite(CallableReference.class);
|
||||
suite.addTestSuite(Cast.class);
|
||||
suite.addTestSuite(CheckArguments.class);
|
||||
suite.addTestSuite(ControlFlowAnalysis.class);
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.AbstractList;
|
||||
|
||||
public class ThrowingList<E> extends AbstractList<E> {
|
||||
private static final ThrowingList<?> INSTANCE = new ThrowingList<Object>();
|
||||
|
||||
private ThrowingList() {}
|
||||
|
||||
@NotNull
|
||||
public static <E> ThrowingList<E> instance() {
|
||||
//noinspection unchecked
|
||||
return (ThrowingList<E>) INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
throw new UnsupportedOperationException(getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
throw new UnsupportedOperationException(getClass().getName());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user