Add method replaceType for ReceiverValue.

This method will used for capturing from expressions before call resolution.
This commit is contained in:
Stanislav Erokhin
2017-04-06 12:32:46 +03:00
parent 1dcdb72a49
commit e8501c7d54
8 changed files with 49 additions and 2 deletions
@@ -396,6 +396,12 @@ public class Visibilities {
public KotlinType getType() {
throw new IllegalStateException("This method should not be called");
}
@NotNull
@Override
public ReceiverValue replaceType(@NotNull KotlinType newType) {
throw new IllegalStateException("This method should not be called");
}
};
/**
@@ -408,6 +414,12 @@ public class Visibilities {
public KotlinType getType() {
throw new IllegalStateException("This method should not be called");
}
@NotNull
@Override
public ReceiverValue replaceType(@NotNull KotlinType newType) {
throw new IllegalStateException("This method should not be called");
}
};
// This constant is not intended to use somewhere else from
@@ -418,6 +430,12 @@ public class Visibilities {
public KotlinType getType() {
throw new IllegalStateException("This method should not be called");
}
@NotNull
@Override
public ReceiverValue replaceType(@NotNull KotlinType newType) {
throw new IllegalStateException("This method should not be called");
}
};
public static boolean isPrivate(@NotNull Visibility visibility) {
@@ -35,6 +35,12 @@ public class ExtensionReceiver extends AbstractReceiverValue implements Implicit
return descriptor;
}
@NotNull
@Override
public ReceiverValue replaceType(@NotNull KotlinType newType) {
return new ExtensionReceiver(descriptor, newType);
}
@Override
public String toString() {
return getType() + ": Ext {" + descriptor + "}";
@@ -17,6 +17,8 @@
package org.jetbrains.kotlin.resolve.scopes.receivers
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.types.KotlinType
import java.lang.UnsupportedOperationException
/**
* Describes any "this" receiver inside a class
@@ -39,4 +41,7 @@ open class ImplicitClassReceiver(final override val classDescriptor: ClassDescri
override fun hashCode() = classDescriptor.hashCode()
override fun toString() = "Class{$type}"
override fun replaceType(newType: KotlinType) =
throw UnsupportedOperationException("Replace type should not be called for this receiver")
}
@@ -23,4 +23,7 @@ public interface ReceiverValue extends Receiver {
@NotNull
KotlinType getType();
@NotNull
ReceiverValue replaceType(@NotNull KotlinType newType);
}
@@ -32,4 +32,10 @@ public class TransientReceiver extends AbstractReceiverValue {
public String toString() {
return "{Transient} : " + getType();
}
@NotNull
@Override
public ReceiverValue replaceType(@NotNull KotlinType newType) {
return new TransientReceiver(newType);
}
}