set explicit receiver kind properly for calls
This commit is contained in:
@@ -204,7 +204,8 @@ public class CallResolver {
|
|||||||
context.trace.report(NO_CONSTRUCTOR.on(reportAbsenceOn));
|
context.trace.report(NO_CONSTRUCTOR.on(reportAbsenceOn));
|
||||||
return checkArgumentTypesAndFail(context);
|
return checkArgumentTypesAndFail(context);
|
||||||
}
|
}
|
||||||
Collection<ResolutionCandidate<CallableDescriptor>> candidates = TaskPrioritizer.<CallableDescriptor>convertWithImpliedThis(context.scope, Collections.<ReceiverValue>singletonList(NO_RECEIVER), constructors);
|
Collection<ResolutionCandidate<CallableDescriptor>> candidates =
|
||||||
|
TaskPrioritizer.<CallableDescriptor>convertWithImpliedThisAndNoReceiver(context.scope, constructors);
|
||||||
prioritizedTasks = TaskPrioritizer.<CallableDescriptor, FunctionDescriptor>computePrioritizedTasksFromCandidates(
|
prioritizedTasks = TaskPrioritizer.<CallableDescriptor, FunctionDescriptor>computePrioritizedTasksFromCandidates(
|
||||||
context, functionReference, candidates, null);
|
context, functionReference, candidates, null);
|
||||||
}
|
}
|
||||||
|
|||||||
+46
-33
@@ -45,6 +45,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isClassObject;
|
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isClassObject;
|
||||||
import static org.jetbrains.jet.lang.resolve.calls.CallResolverUtil.isOrOverridesSynthesized;
|
import static org.jetbrains.jet.lang.resolve.calls.CallResolverUtil.isOrOverridesSynthesized;
|
||||||
|
import static org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind.*;
|
||||||
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER;
|
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER;
|
||||||
|
|
||||||
public class TaskPrioritizer {
|
public class TaskPrioritizer {
|
||||||
@@ -121,7 +122,7 @@ public class TaskPrioritizer {
|
|||||||
}
|
}
|
||||||
List<ReceiverValue> implicitReceivers = JetScopeUtils.getImplicitReceiversHierarchyValues(c.scope);
|
List<ReceiverValue> implicitReceivers = JetScopeUtils.getImplicitReceiversHierarchyValues(c.scope);
|
||||||
if (receiver.exists()) {
|
if (receiver.exists()) {
|
||||||
addCandidatesForExplicitReceiver(receiver, implicitReceivers, c, /*resolveInvoke=*/false);
|
addCandidatesForExplicitReceiver(receiver, implicitReceivers, c, /*isExplicit=*/true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addCandidatesForNoReceiver(implicitReceivers, c);
|
addCandidatesForNoReceiver(implicitReceivers, c);
|
||||||
@@ -131,7 +132,7 @@ public class TaskPrioritizer {
|
|||||||
@NotNull ReceiverValue receiver,
|
@NotNull ReceiverValue receiver,
|
||||||
@NotNull List<ReceiverValue> implicitReceivers,
|
@NotNull List<ReceiverValue> implicitReceivers,
|
||||||
@NotNull TaskPrioritizerContext<D, F> c,
|
@NotNull TaskPrioritizerContext<D, F> c,
|
||||||
boolean resolveInvoke
|
boolean isExplicit
|
||||||
) {
|
) {
|
||||||
|
|
||||||
List<ReceiverValue> variantsForExplicitReceiver = AutoCastUtils.getAutoCastVariants(receiver, c.context);
|
List<ReceiverValue> variantsForExplicitReceiver = AutoCastUtils.getAutoCastVariants(receiver, c.context);
|
||||||
@@ -143,7 +144,7 @@ public class TaskPrioritizer {
|
|||||||
Collection<? extends D> membersForThisVariant =
|
Collection<? extends D> membersForThisVariant =
|
||||||
callableDescriptorCollector.getMembersByName(variant.getType(), c.name, c.context.trace);
|
callableDescriptorCollector.getMembersByName(variant.getType(), c.name, c.context.trace);
|
||||||
convertWithReceivers(membersForThisVariant, Collections.singletonList(variant),
|
convertWithReceivers(membersForThisVariant, Collections.singletonList(variant),
|
||||||
Collections.singletonList(NO_RECEIVER), members, resolveInvoke);
|
Collections.singletonList(NO_RECEIVER), members, createKind(THIS_OBJECT, isExplicit));
|
||||||
}
|
}
|
||||||
c.result.addCandidates(members);
|
c.result.addCandidates(members);
|
||||||
}
|
}
|
||||||
@@ -152,26 +153,32 @@ public class TaskPrioritizer {
|
|||||||
//member extensions
|
//member extensions
|
||||||
for (ReceiverValue implicitReceiver : implicitReceivers) {
|
for (ReceiverValue implicitReceiver : implicitReceivers) {
|
||||||
addMemberExtensionCandidates(implicitReceiver, variantsForExplicitReceiver,
|
addMemberExtensionCandidates(implicitReceiver, variantsForExplicitReceiver,
|
||||||
callableDescriptorCollector, c, resolveInvoke);
|
callableDescriptorCollector, c, createKind(RECEIVER_ARGUMENT, isExplicit));
|
||||||
}
|
}
|
||||||
//extensions
|
//extensions
|
||||||
Collection<ResolutionCandidate<D>> extensions = convertWithImpliedThis(
|
Collection<ResolutionCandidate<D>> extensions = convertWithImpliedThis(
|
||||||
c.scope, variantsForExplicitReceiver, callableDescriptorCollector.getNonMembersByName(c.scope, c.name, c.context.trace));
|
c.scope, variantsForExplicitReceiver, callableDescriptorCollector.getNonMembersByName(c.scope, c.name, c.context.trace),
|
||||||
|
createKind(RECEIVER_ARGUMENT, isExplicit));
|
||||||
c.result.addCandidates(extensions);
|
c.result.addCandidates(extensions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ExplicitReceiverKind createKind(ExplicitReceiverKind kind, boolean isExplicit) {
|
||||||
|
if (isExplicit) return kind;
|
||||||
|
return ExplicitReceiverKind.NO_EXPLICIT_RECEIVER;
|
||||||
|
}
|
||||||
|
|
||||||
private static <D extends CallableDescriptor, F extends D> void addMemberExtensionCandidates(
|
private static <D extends CallableDescriptor, F extends D> void addMemberExtensionCandidates(
|
||||||
@NotNull ReceiverValue implicitReceiver,
|
@NotNull ReceiverValue thisObject,
|
||||||
@NotNull List<ReceiverValue> variantsForExplicitReceiver,
|
@NotNull List<ReceiverValue> receiverParameters,
|
||||||
@NotNull CallableDescriptorCollector<? extends D> callableDescriptorCollector, TaskPrioritizerContext<D, F> c,
|
@NotNull CallableDescriptorCollector<? extends D> callableDescriptorCollector, TaskPrioritizerContext<D, F> c,
|
||||||
boolean resolveInvoke
|
@NotNull ExplicitReceiverKind receiverKind
|
||||||
) {
|
) {
|
||||||
Collection<? extends D> memberExtensions = callableDescriptorCollector.getNonMembersByName(
|
Collection<? extends D> memberExtensions = callableDescriptorCollector.getNonMembersByName(
|
||||||
implicitReceiver.getType().getMemberScope(), c.name, c.context.trace);
|
thisObject.getType().getMemberScope(), c.name, c.context.trace);
|
||||||
List<ReceiverValue> variantsForImplicitReceiver = AutoCastUtils.getAutoCastVariants(implicitReceiver, c.context);
|
List<ReceiverValue> thisObjects = AutoCastUtils.getAutoCastVariants(thisObject, c.context);
|
||||||
c.result.addCandidates(convertWithReceivers(memberExtensions, variantsForImplicitReceiver,
|
c.result.addCandidates(convertWithReceivers(
|
||||||
variantsForExplicitReceiver, resolveInvoke));
|
memberExtensions, thisObjects, receiverParameters, receiverKind));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <D extends CallableDescriptor, F extends D> void addCandidatesForNoReceiver(
|
private static <D extends CallableDescriptor, F extends D> void addCandidatesForNoReceiver(
|
||||||
@@ -182,9 +189,8 @@ public class TaskPrioritizer {
|
|||||||
List<Collection<ResolutionCandidate<D>>> nonlocalsList = Lists.newArrayList();
|
List<Collection<ResolutionCandidate<D>>> nonlocalsList = Lists.newArrayList();
|
||||||
for (CallableDescriptorCollector<? extends D> callableDescriptorCollector : c.callableDescriptorCollectors) {
|
for (CallableDescriptorCollector<? extends D> callableDescriptorCollector : c.callableDescriptorCollectors) {
|
||||||
|
|
||||||
Collection<ResolutionCandidate<D>> members =
|
Collection<ResolutionCandidate<D>> members = convertWithImpliedThisAndNoReceiver(
|
||||||
convertWithImpliedThis(c.scope, Collections.singletonList(NO_RECEIVER), callableDescriptorCollector
|
c.scope, callableDescriptorCollector.getNonExtensionsByName(c.scope, c.name, c.context.trace));
|
||||||
.getNonExtensionsByName(c.scope, c.name, c.context.trace));
|
|
||||||
|
|
||||||
List<ResolutionCandidate<D>> nonlocals = Lists.newArrayList();
|
List<ResolutionCandidate<D>> nonlocals = Lists.newArrayList();
|
||||||
List<ResolutionCandidate<D>> locals = Lists.newArrayList();
|
List<ResolutionCandidate<D>> locals = Lists.newArrayList();
|
||||||
@@ -200,7 +206,7 @@ public class TaskPrioritizer {
|
|||||||
|
|
||||||
//try all implicit receivers as explicit
|
//try all implicit receivers as explicit
|
||||||
for (ReceiverValue implicitReceiver : implicitReceivers) {
|
for (ReceiverValue implicitReceiver : implicitReceivers) {
|
||||||
addCandidatesForExplicitReceiver(implicitReceiver, implicitReceivers, c, /*resolveInvoke=*/false);
|
addCandidatesForExplicitReceiver(implicitReceiver, implicitReceivers, c, /*isExplicit=*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//nonlocals
|
//nonlocals
|
||||||
@@ -224,7 +230,7 @@ public class TaskPrioritizer {
|
|||||||
|
|
||||||
// (1) a.foo + foo.invoke()
|
// (1) a.foo + foo.invoke()
|
||||||
if (!explicitReceiver.exists()) {
|
if (!explicitReceiver.exists()) {
|
||||||
addCandidatesForExplicitReceiver(variableReceiver, implicitReceivers, c, /*resolveInvoke=*/true);
|
addCandidatesForExplicitReceiver(variableReceiver, implicitReceivers, c, /*isExplicit=*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// (2) foo + a.invoke()
|
// (2) foo + a.invoke()
|
||||||
@@ -235,24 +241,25 @@ public class TaskPrioritizer {
|
|||||||
|
|
||||||
if (explicitReceiver.exists()) {
|
if (explicitReceiver.exists()) {
|
||||||
//a.foo()
|
//a.foo()
|
||||||
addCandidatesWhenInvokeIsMemberExtensionToExplicitReceiver(variableReceiver, explicitReceiver, c);
|
addCandidatesWhenInvokeIsMemberAndExtensionToExplicitReceiver(variableReceiver, explicitReceiver, c, BOTH_RECEIVERS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// with (a) { foo() }
|
// with (a) { foo() }
|
||||||
for (ReceiverValue implicitReceiver : implicitReceivers) {
|
for (ReceiverValue implicitReceiver : implicitReceivers) {
|
||||||
addCandidatesWhenInvokeIsMemberExtensionToExplicitReceiver(variableReceiver, implicitReceiver, c);
|
addCandidatesWhenInvokeIsMemberAndExtensionToExplicitReceiver(variableReceiver, implicitReceiver, c, THIS_OBJECT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <D extends CallableDescriptor, F extends D> void addCandidatesWhenInvokeIsMemberExtensionToExplicitReceiver(
|
private static <D extends CallableDescriptor, F extends D> void addCandidatesWhenInvokeIsMemberAndExtensionToExplicitReceiver(
|
||||||
@NotNull ReceiverValue variableReceiver,
|
@NotNull ReceiverValue thisObject,
|
||||||
@NotNull ReceiverValue explicitReceiver,
|
@NotNull ReceiverValue receiverParameter,
|
||||||
@NotNull TaskPrioritizerContext<D, F> c
|
@NotNull TaskPrioritizerContext<D, F> c,
|
||||||
|
@NotNull ExplicitReceiverKind receiverKind
|
||||||
) {
|
) {
|
||||||
List<ReceiverValue> variantsForExplicitReceiver = AutoCastUtils.getAutoCastVariants(explicitReceiver, c.context);
|
List<ReceiverValue> receiverParameters = AutoCastUtils.getAutoCastVariants(receiverParameter, c.context);
|
||||||
|
|
||||||
for (CallableDescriptorCollector<? extends D> callableDescriptorCollector : c.callableDescriptorCollectors) {
|
for (CallableDescriptorCollector<? extends D> callableDescriptorCollector : c.callableDescriptorCollectors) {
|
||||||
addMemberExtensionCandidates(variableReceiver, variantsForExplicitReceiver, callableDescriptorCollector, c, /*resolveInvoke=*/true);
|
addMemberExtensionCandidates(thisObject, receiverParameters, callableDescriptorCollector, c, receiverKind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,10 +267,10 @@ public class TaskPrioritizer {
|
|||||||
@NotNull Collection<? extends D> descriptors,
|
@NotNull Collection<? extends D> descriptors,
|
||||||
@NotNull Iterable<ReceiverValue> thisObjects,
|
@NotNull Iterable<ReceiverValue> thisObjects,
|
||||||
@NotNull Iterable<ReceiverValue> receiverParameters,
|
@NotNull Iterable<ReceiverValue> receiverParameters,
|
||||||
boolean hasExplicitThisObject
|
@NotNull ExplicitReceiverKind explicitReceiverKind
|
||||||
) {
|
) {
|
||||||
Collection<ResolutionCandidate<D>> result = Lists.newArrayList();
|
Collection<ResolutionCandidate<D>> result = Lists.newArrayList();
|
||||||
convertWithReceivers(descriptors, thisObjects, receiverParameters, result, hasExplicitThisObject);
|
convertWithReceivers(descriptors, thisObjects, receiverParameters, result, explicitReceiverKind);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +279,7 @@ public class TaskPrioritizer {
|
|||||||
@NotNull Iterable<ReceiverValue> thisObjects,
|
@NotNull Iterable<ReceiverValue> thisObjects,
|
||||||
@NotNull Iterable<ReceiverValue> receiverParameters,
|
@NotNull Iterable<ReceiverValue> receiverParameters,
|
||||||
@NotNull Collection<ResolutionCandidate<D>> result,
|
@NotNull Collection<ResolutionCandidate<D>> result,
|
||||||
boolean hasExplicitThisObject
|
@NotNull ExplicitReceiverKind explicitReceiverKind
|
||||||
) {
|
) {
|
||||||
for (ReceiverValue thisObject : thisObjects) {
|
for (ReceiverValue thisObject : thisObjects) {
|
||||||
for (ReceiverValue receiverParameter : receiverParameters) {
|
for (ReceiverValue receiverParameter : receiverParameters) {
|
||||||
@@ -284,26 +291,32 @@ public class TaskPrioritizer {
|
|||||||
ResolutionCandidate<D> candidate = ResolutionCandidate.create(extension);
|
ResolutionCandidate<D> candidate = ResolutionCandidate.create(extension);
|
||||||
candidate.setThisObject(thisObject);
|
candidate.setThisObject(thisObject);
|
||||||
candidate.setReceiverArgument(receiverParameter);
|
candidate.setReceiverArgument(receiverParameter);
|
||||||
candidate.setExplicitReceiverKind(
|
candidate.setExplicitReceiverKind(explicitReceiverKind);
|
||||||
hasExplicitThisObject ? ExplicitReceiverKind.BOTH_RECEIVERS : ExplicitReceiverKind.THIS_OBJECT);
|
|
||||||
result.add(candidate);
|
result.add(candidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <D extends CallableDescriptor> Collection<ResolutionCandidate<D>> convertWithImpliedThisAndNoReceiver(
|
||||||
|
@NotNull JetScope scope,
|
||||||
|
@NotNull Collection<? extends D> descriptors
|
||||||
|
) {
|
||||||
|
return convertWithImpliedThis(scope, Collections.singletonList(NO_RECEIVER), descriptors, NO_EXPLICIT_RECEIVER);
|
||||||
|
}
|
||||||
|
|
||||||
public static <D extends CallableDescriptor> Collection<ResolutionCandidate<D>> convertWithImpliedThis(
|
public static <D extends CallableDescriptor> Collection<ResolutionCandidate<D>> convertWithImpliedThis(
|
||||||
@NotNull JetScope scope,
|
@NotNull JetScope scope,
|
||||||
@NotNull Collection<ReceiverValue> receiverParameters,
|
@NotNull Collection<ReceiverValue> receiverParameters,
|
||||||
@NotNull Collection<? extends D> descriptors
|
@NotNull Collection<? extends D> descriptors,
|
||||||
|
ExplicitReceiverKind receiverKind
|
||||||
) {
|
) {
|
||||||
Collection<ResolutionCandidate<D>> result = Lists.newArrayList();
|
Collection<ResolutionCandidate<D>> result = Lists.newArrayList();
|
||||||
for (ReceiverValue receiverParameter : receiverParameters) {
|
for (ReceiverValue receiverParameter : receiverParameters) {
|
||||||
for (D descriptor : descriptors) {
|
for (D descriptor : descriptors) {
|
||||||
ResolutionCandidate<D> candidate = ResolutionCandidate.create(descriptor);
|
ResolutionCandidate<D> candidate = ResolutionCandidate.create(descriptor);
|
||||||
candidate.setReceiverArgument(receiverParameter);
|
candidate.setReceiverArgument(receiverParameter);
|
||||||
candidate.setExplicitReceiverKind(
|
candidate.setExplicitReceiverKind(receiverKind);
|
||||||
receiverParameter.exists() ? ExplicitReceiverKind.RECEIVER_ARGUMENT : ExplicitReceiverKind.NO_EXPLICIT_RECEIVER);
|
|
||||||
if (setImpliedThis(scope, candidate)) {
|
if (setImpliedThis(scope, candidate)) {
|
||||||
result.add(candidate);
|
result.add(candidate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !CALL: foo
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: RECEIVER_ARGUMENT
|
||||||
|
// !THIS_OBJECT: NO_RECEIVER
|
||||||
|
// !RECEIVER_ARGUMENT: a
|
||||||
|
|
||||||
|
class A {}
|
||||||
|
|
||||||
|
fun A.foo() {}
|
||||||
|
|
||||||
|
fun bar(a: A) {
|
||||||
|
a.foo()
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !CALL: foo
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT
|
||||||
|
// !THIS_OBJECT: a
|
||||||
|
// !RECEIVER_ARGUMENT: NO_RECEIVER
|
||||||
|
|
||||||
|
class A {
|
||||||
|
fun foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(a: A) {
|
||||||
|
a.foo()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// !CALL: invoke
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: BOTH_RECEIVERS
|
||||||
|
// !THIS_OBJECT: f
|
||||||
|
// !RECEIVER_ARGUMENT: 1
|
||||||
|
|
||||||
|
fun bar(f: Int.()->Unit) {
|
||||||
|
1.f()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// !CALL: invoke
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT
|
||||||
|
// !THIS_OBJECT: f
|
||||||
|
// !RECEIVER_ARGUMENT: NO_RECEIVER
|
||||||
|
|
||||||
|
fun bar(f: ()->Unit) {
|
||||||
|
f()
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !CALL: foo
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER
|
||||||
|
// !THIS_OBJECT: Class{A}
|
||||||
|
// !RECEIVER_ARGUMENT: NO_RECEIVER
|
||||||
|
|
||||||
|
trait A {
|
||||||
|
val foo: Int.()->Unit
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
1.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !CALL: invoke
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: BOTH_RECEIVERS
|
||||||
|
// !THIS_OBJECT: foo
|
||||||
|
// !RECEIVER_ARGUMENT: 1
|
||||||
|
|
||||||
|
trait A {
|
||||||
|
val foo: Int.()->Unit
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
1.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !CALL: foo
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT
|
||||||
|
// !THIS_OBJECT: a
|
||||||
|
// !RECEIVER_ARGUMENT: NO_RECEIVER
|
||||||
|
|
||||||
|
trait A {
|
||||||
|
val foo: (Int)->Int
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(a: A) {
|
||||||
|
a.foo(1)
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !CALL: invoke
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT
|
||||||
|
// !THIS_OBJECT: foo
|
||||||
|
// !RECEIVER_ARGUMENT: NO_RECEIVER
|
||||||
|
|
||||||
|
trait A {
|
||||||
|
val foo: (Int)->Int
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(a: A) {
|
||||||
|
a.foo(1)
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// !CALL: foo
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: RECEIVER_ARGUMENT
|
||||||
|
// !THIS_OBJECT: A
|
||||||
|
// !RECEIVER_ARGUMENT: b
|
||||||
|
|
||||||
|
class A {
|
||||||
|
fun B.foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait B
|
||||||
|
|
||||||
|
fun bar(a: A, b: B) {
|
||||||
|
with (a) {
|
||||||
|
b.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T, R> with(receiver: T, f: T.() -> R) : R = receiver.f()
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
// !CALL: foo
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER
|
||||||
|
// !THIS_OBJECT: A
|
||||||
|
// !RECEIVER_ARGUMENT: B
|
||||||
|
|
||||||
|
class A {
|
||||||
|
fun B.foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait B
|
||||||
|
|
||||||
|
fun bar(a: A, b: B) {
|
||||||
|
with (a) {
|
||||||
|
with (b) {
|
||||||
|
foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T, R> with(receiver: T, f: T.() -> R) : R = receiver.f()
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !CALL: foo
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER
|
||||||
|
// !THIS_OBJECT: NO_RECEIVER
|
||||||
|
// !RECEIVER_ARGUMENT: A
|
||||||
|
|
||||||
|
class A {}
|
||||||
|
|
||||||
|
fun A.foo() {}
|
||||||
|
|
||||||
|
fun A.bar() {
|
||||||
|
foo()
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !CALL: foo
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER
|
||||||
|
// !THIS_OBJECT: A
|
||||||
|
// !RECEIVER_ARGUMENT: NO_RECEIVER
|
||||||
|
|
||||||
|
class A {
|
||||||
|
fun foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun A.bar() {
|
||||||
|
foo()
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// !CALL: foo
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER
|
||||||
|
// !THIS_OBJECT: Class{A}
|
||||||
|
// !RECEIVER_ARGUMENT: NO_RECEIVER
|
||||||
|
|
||||||
|
class A {
|
||||||
|
fun foo() {}
|
||||||
|
fun bar() {
|
||||||
|
foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !CALL: invoke
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: BOTH_RECEIVERS
|
||||||
|
// !THIS_OBJECT: f
|
||||||
|
// !RECEIVER_ARGUMENT: 1
|
||||||
|
|
||||||
|
class Foo() {
|
||||||
|
fun Int.invoke() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(f: Foo) {
|
||||||
|
1.f()
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// !CALL: invoke
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT
|
||||||
|
// !THIS_OBJECT: f
|
||||||
|
// !RECEIVER_ARGUMENT: Int
|
||||||
|
|
||||||
|
class Foo() {
|
||||||
|
fun Int.invoke() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(f: Foo, i: Int) {
|
||||||
|
with (i) {
|
||||||
|
f()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T, R> with(receiver: T, f: T.() -> R) : R = throw Exception()
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// !CALL: invoke
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: RECEIVER_ARGUMENT
|
||||||
|
// !THIS_OBJECT: NO_RECEIVER
|
||||||
|
// !RECEIVER_ARGUMENT: f
|
||||||
|
|
||||||
|
class Foo
|
||||||
|
fun Foo.invoke() {}
|
||||||
|
|
||||||
|
fun bar(f: Foo) {
|
||||||
|
f()
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !CALL: invoke
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT
|
||||||
|
// !THIS_OBJECT: f
|
||||||
|
// !RECEIVER_ARGUMENT: NO_RECEIVER
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
fun invoke() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(f: Foo) {
|
||||||
|
f()
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
// !CALL: +
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: RECEIVER_ARGUMENT
|
||||||
|
// !THIS_OBJECT: Title
|
||||||
|
// !RECEIVER_ARGUMENT: "Foo"
|
||||||
|
|
||||||
|
trait Element {
|
||||||
|
fun render(builder: StringBuilder, indent: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
class TextElement(val text: String): Element {
|
||||||
|
override fun render(builder: StringBuilder, indent: String): Unit = fail
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Tag(val name: String): Element {
|
||||||
|
protected fun initTag<T: Element>(tag: T, init: T.() -> Unit): T = fail
|
||||||
|
|
||||||
|
override fun render(builder: StringBuilder, indent: String): Unit = fail
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class TagWithText(name: String): Tag(name) {
|
||||||
|
fun String.plus() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class HTML(): TagWithText("html") {
|
||||||
|
fun head(init: Head.() -> Unit): Head = fail
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Head(): TagWithText("head") {
|
||||||
|
fun title(init: Title.() -> Unit): Title = fail
|
||||||
|
}
|
||||||
|
|
||||||
|
class Title(): TagWithText("title")
|
||||||
|
|
||||||
|
fun html(init: HTML.() -> Unit): HTML = fail
|
||||||
|
|
||||||
|
fun result() =
|
||||||
|
html {
|
||||||
|
head {
|
||||||
|
title {+"Foo"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val fail: Nothing get() = throw Exception()
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// !CALL: foo
|
||||||
|
// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER
|
||||||
|
// !THIS_OBJECT: NO_RECEIVER
|
||||||
|
// !RECEIVER_ARGUMENT: NO_RECEIVER
|
||||||
|
|
||||||
|
fun foo() {}
|
||||||
|
|
||||||
|
fun bar() {
|
||||||
|
foo()
|
||||||
|
}
|
||||||
@@ -229,11 +229,13 @@ public class JetTestUtils {
|
|||||||
return AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(namespace, Collections.<AnalyzerScriptParameter>emptyList());
|
return AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(namespace, Collections.<AnalyzerScriptParameter>emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static JetCoreEnvironment createEnvironmentWithFullJdk(Disposable disposable) {
|
public static JetCoreEnvironment createEnvironmentWithFullJdk(Disposable disposable) {
|
||||||
return createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(disposable,
|
return createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(disposable,
|
||||||
ConfigurationKind.ALL, TestJdkKind.FULL_JDK);
|
ConfigurationKind.ALL, TestJdkKind.FULL_JDK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static JetCoreEnvironment createEnvironmentWithMockJdkAndIdeaAnnotations(Disposable disposable) {
|
public static JetCoreEnvironment createEnvironmentWithMockJdkAndIdeaAnnotations(Disposable disposable) {
|
||||||
return createEnvironmentWithMockJdkAndIdeaAnnotations(disposable, ConfigurationKind.ALL);
|
return createEnvironmentWithMockJdkAndIdeaAnnotations(disposable, ConfigurationKind.ALL);
|
||||||
}
|
}
|
||||||
@@ -243,6 +245,7 @@ public class JetTestUtils {
|
|||||||
return createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(disposable, configurationKind, TestJdkKind.MOCK_JDK);
|
return createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(disposable, configurationKind, TestJdkKind.MOCK_JDK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static JetCoreEnvironment createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(
|
public static JetCoreEnvironment createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(
|
||||||
@NotNull Disposable disposable,
|
@NotNull Disposable disposable,
|
||||||
@NotNull ConfigurationKind configurationKind,
|
@NotNull ConfigurationKind configurationKind,
|
||||||
@@ -445,6 +448,7 @@ public class JetTestUtils {
|
|||||||
return testFiles;
|
return testFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static Map<String, String> parseDirectives(String expectedText) {
|
public static Map<String, String> parseDirectives(String expectedText) {
|
||||||
Map<String, String> directives = Maps.newHashMap();
|
Map<String, String> directives = Maps.newHashMap();
|
||||||
Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText);
|
Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText);
|
||||||
|
|||||||
@@ -25,10 +25,12 @@ public abstract class KotlinTestWithEnvironmentManagement extends UsefulTestCase
|
|||||||
System.setProperty("java.awt.headless", "true");
|
System.setProperty("java.awt.headless", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
protected JetCoreEnvironment createEnvironmentWithMockJdk(@NotNull ConfigurationKind configurationKind) {
|
protected JetCoreEnvironment createEnvironmentWithMockJdk(@NotNull ConfigurationKind configurationKind) {
|
||||||
return createEnvironmentWithJdk(configurationKind, TestJdkKind.MOCK_JDK);
|
return createEnvironmentWithJdk(configurationKind, TestJdkKind.MOCK_JDK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
protected JetCoreEnvironment createEnvironmentWithJdk(@NotNull ConfigurationKind configurationKind, @NotNull TestJdkKind jdkKind) {
|
protected JetCoreEnvironment createEnvironmentWithJdk(@NotNull ConfigurationKind configurationKind, @NotNull TestJdkKind jdkKind) {
|
||||||
return JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(getTestRootDisposable(), configurationKind, jdkKind);
|
return JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(getTestRootDisposable(), configurationKind, jdkKind);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* 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.resolve.calls
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap
|
||||||
|
import org.jetbrains.annotations.NotNull
|
||||||
|
import org.jetbrains.jet.ConfigurationKind
|
||||||
|
import org.jetbrains.jet.JetLiteFixture
|
||||||
|
import org.jetbrains.jet.JetTestUtils
|
||||||
|
import org.jetbrains.jet.analyzer.AnalyzeExhaust
|
||||||
|
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
|
||||||
|
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||||
|
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils
|
||||||
|
import org.jetbrains.jet.lang.psi.JetElement
|
||||||
|
import org.jetbrains.jet.lang.psi.JetFile
|
||||||
|
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
|
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
||||||
|
import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM
|
||||||
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.AbstractReceiverValue
|
||||||
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver
|
||||||
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import java.util.Collections
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
public abstract class AbstractResolvedCallsTest() : JetLiteFixture() {
|
||||||
|
override fun createEnvironment(): JetCoreEnvironment = createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY)
|
||||||
|
|
||||||
|
public fun doTest(filePath: String) {
|
||||||
|
val file = File(filePath)
|
||||||
|
val text = JetTestUtils.doLoadFile(file)
|
||||||
|
val directives = JetTestUtils.parseDirectives(text)
|
||||||
|
|
||||||
|
val (callName, thisObject, receiverArgument) = with (directives) {
|
||||||
|
Triple(get("CALL"), get("THIS_OBJECT"), get("RECEIVER_ARGUMENT"))
|
||||||
|
}
|
||||||
|
val explicitReceiverKind = directives.getExplicitReceiverKind()
|
||||||
|
|
||||||
|
fun analyzeFileAndGetResolvedCallEntries(): Map<JetElement, ResolvedCall<out CallableDescriptor?>> {
|
||||||
|
val psiFile = JetTestUtils.loadJetFile(getProject(), file)
|
||||||
|
val analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, Collections.emptyList())
|
||||||
|
val bindingContext = analyzeExhaust!!.getBindingContext()
|
||||||
|
return bindingContext.getSliceContents(BindingContext.RESOLVED_CALL)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkResolvedCall(resolvedCall: ResolvedCall<out CallableDescriptor?>, element: JetElement) {
|
||||||
|
val lineAndColumn = DiagnosticUtils.getLineAndColumnInPsiFile(element.getContainingFile(), element.getTextRange())
|
||||||
|
|
||||||
|
val (actualThisObject, actualReceiverArgument, actualExplicitReceiverKind) = with(resolvedCall) {
|
||||||
|
Triple(getThisObject().getText(), getReceiverArgument().getText(), getExplicitReceiverKind())
|
||||||
|
}
|
||||||
|
val actualDataMessage = "Actual data:\nThis object: $actualThisObject. Receiver argument: $actualReceiverArgument. " +
|
||||||
|
"Explicit receiver kind: $actualExplicitReceiverKind.\n"
|
||||||
|
|
||||||
|
assertEquals(thisObject, actualThisObject, "${actualDataMessage}This object mismatch: ")
|
||||||
|
assertEquals(receiverArgument, actualReceiverArgument, "${actualDataMessage}Receiver argument mismatch: ")
|
||||||
|
assertEquals(explicitReceiverKind, actualExplicitReceiverKind, "$actualDataMessage" +
|
||||||
|
"Explicit receiver kind for resolved call for '${element.getText()}'$lineAndColumn in not as expected")
|
||||||
|
}
|
||||||
|
|
||||||
|
var callFound = false
|
||||||
|
for ((element, resolvedCall) in analyzeFileAndGetResolvedCallEntries()) {
|
||||||
|
if (callName.equals(element.getText())) {
|
||||||
|
callFound = true
|
||||||
|
checkResolvedCall(resolvedCall, element)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(callFound, "Resolved call for $callName was not found.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ReceiverValue.getText() =
|
||||||
|
if (this is ExpressionReceiver) {
|
||||||
|
this.getExpression().getText()
|
||||||
|
}
|
||||||
|
else if (this is AbstractReceiverValue) {
|
||||||
|
this.getType().toString()
|
||||||
|
}
|
||||||
|
else toString()
|
||||||
|
|
||||||
|
private val EXPLICIT_RECEIVER_KIND_DIRECTIVE: String = "EXPLICIT_RECEIVER_KIND"
|
||||||
|
private fun Map<String, String>.getExplicitReceiverKind(): ExplicitReceiverKind {
|
||||||
|
val explicitReceiverKind = get(EXPLICIT_RECEIVER_KIND_DIRECTIVE)
|
||||||
|
assert(explicitReceiverKind != null) { "$EXPLICIT_RECEIVER_KIND_DIRECTIVE should be present." }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return ExplicitReceiverKind.valueOf(explicitReceiverKind!!)
|
||||||
|
}
|
||||||
|
catch (e: IllegalArgumentException) {
|
||||||
|
val message = StringBuilder()
|
||||||
|
message.append("$EXPLICIT_RECEIVER_KIND_DIRECTIVE must be one of the following: ")
|
||||||
|
for (kind in ExplicitReceiverKind.values()) {
|
||||||
|
message.append("$kind, ")
|
||||||
|
}
|
||||||
|
message.append("\nnot $explicitReceiverKind.")
|
||||||
|
throw AssertionError(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
/*
|
||||||
|
* 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.resolve.calls;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
|
import org.jetbrains.jet.test.InnerTestClasses;
|
||||||
|
import org.jetbrains.jet.test.TestMetadata;
|
||||||
|
|
||||||
|
import org.jetbrains.jet.resolve.calls.AbstractResolvedCallsTest;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("compiler/testData/resolvedCalls")
|
||||||
|
@InnerTestClasses({JetResolvedCallsTestGenerated.FunctionTypes.class, JetResolvedCallsTestGenerated.Invoke.class, JetResolvedCallsTestGenerated.RealExamples.class})
|
||||||
|
public class JetResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
|
||||||
|
public void testAllFilesPresentInResolvedCalls() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/resolvedCalls"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("explicitReceiverIsReceiverArgument.kt")
|
||||||
|
public void testExplicitReceiverIsReceiverArgument() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/explicitReceiverIsReceiverArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("explicitReceiverIsThisObject.kt")
|
||||||
|
public void testExplicitReceiverIsThisObject() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/explicitReceiverIsThisObject.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("hasBothThisObjectAndReceiverArgument.kt")
|
||||||
|
public void testHasBothThisObjectAndReceiverArgument() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("hasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver.kt")
|
||||||
|
public void testHasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("implicitReceiverIsReceiverArgument.kt")
|
||||||
|
public void testImplicitReceiverIsReceiverArgument() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/implicitReceiverIsReceiverArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("implicitReceiverIsThisObject.kt")
|
||||||
|
public void testImplicitReceiverIsThisObject() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/implicitReceiverIsThisObject.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("impliedThisNoExplicitReceiver.kt")
|
||||||
|
public void testImpliedThisNoExplicitReceiver() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/impliedThisNoExplicitReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleCall.kt")
|
||||||
|
public void testSimpleCall() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/simpleCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/resolvedCalls/functionTypes")
|
||||||
|
public static class FunctionTypes extends AbstractResolvedCallsTest {
|
||||||
|
public void testAllFilesPresentInFunctionTypes() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/resolvedCalls/functionTypes"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("invokeForExtensionFunctionType.kt")
|
||||||
|
public void testInvokeForExtensionFunctionType() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/functionTypes/invokeForExtensionFunctionType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("invokeForFunctionType.kt")
|
||||||
|
public void testInvokeForFunctionType() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/functionTypes/invokeForFunctionType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("valOfExtensionFunctionType.kt")
|
||||||
|
public void testValOfExtensionFunctionType() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("valOfExtensionFunctionTypeInvoke.kt")
|
||||||
|
public void testValOfExtensionFunctionTypeInvoke() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionTypeInvoke.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("valOfFunctionType.kt")
|
||||||
|
public void testValOfFunctionType() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/functionTypes/valOfFunctionType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("valOfFunctionTypeInvoke.kt")
|
||||||
|
public void testValOfFunctionTypeInvoke() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/functionTypes/valOfFunctionTypeInvoke.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/resolvedCalls/invoke")
|
||||||
|
public static class Invoke extends AbstractResolvedCallsTest {
|
||||||
|
public void testAllFilesPresentInInvoke() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/resolvedCalls/invoke"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("bothReceivers.kt")
|
||||||
|
public void testBothReceivers() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/invoke/bothReceivers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("implicitReceiverForInvoke.kt")
|
||||||
|
public void testImplicitReceiverForInvoke() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/invoke/implicitReceiverForInvoke.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("receiverArgumentAsReceiverForInvoke.kt")
|
||||||
|
public void testReceiverArgumentAsReceiverForInvoke() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/invoke/receiverArgumentAsReceiverForInvoke.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("thisObjectAsReceiverForInvoke.kt")
|
||||||
|
public void testThisObjectAsReceiverForInvoke() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/invoke/thisObjectAsReceiverForInvoke.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/resolvedCalls/realExamples")
|
||||||
|
public static class RealExamples extends AbstractResolvedCallsTest {
|
||||||
|
public void testAllFilesPresentInRealExamples() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/resolvedCalls/realExamples"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stringPlusInBuilders.kt")
|
||||||
|
public void testStringPlusInBuilders() throws Exception {
|
||||||
|
doTest("compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite = new TestSuite("JetResolvedCallsTestGenerated");
|
||||||
|
suite.addTestSuite(JetResolvedCallsTestGenerated.class);
|
||||||
|
suite.addTestSuite(FunctionTypes.class);
|
||||||
|
suite.addTestSuite(Invoke.class);
|
||||||
|
suite.addTestSuite(RealExamples.class);
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,6 +66,7 @@ import org.jetbrains.jet.resolve.AbstractResolveBaseTest;
|
|||||||
import org.jetbrains.jet.resolve.AbstractResolveTest;
|
import org.jetbrains.jet.resolve.AbstractResolveTest;
|
||||||
import org.jetbrains.jet.resolve.AbstractResolveWithLibTest;
|
import org.jetbrains.jet.resolve.AbstractResolveWithLibTest;
|
||||||
import org.jetbrains.jet.resolve.annotation.AbstractAnnotationParameterTest;
|
import org.jetbrains.jet.resolve.annotation.AbstractAnnotationParameterTest;
|
||||||
|
import org.jetbrains.jet.resolve.calls.AbstractResolvedCallsTest;
|
||||||
import org.jetbrains.jet.safeDelete.AbstractJetSafeDeleteTest;
|
import org.jetbrains.jet.safeDelete.AbstractJetSafeDeleteTest;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -108,6 +109,13 @@ public class GenerateTests {
|
|||||||
testModel("compiler/testData/resolve", true, "resolve", "doTest")
|
testModel("compiler/testData/resolve", true, "resolve", "doTest")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
generateTest(
|
||||||
|
"compiler/tests",
|
||||||
|
"JetResolvedCallsTestGenerated",
|
||||||
|
AbstractResolvedCallsTest.class,
|
||||||
|
testModel("compiler/testData/resolvedCalls")
|
||||||
|
);
|
||||||
|
|
||||||
generateTest(
|
generateTest(
|
||||||
"compiler/tests/",
|
"compiler/tests/",
|
||||||
"JetParsingTestGenerated",
|
"JetParsingTestGenerated",
|
||||||
|
|||||||
Reference in New Issue
Block a user