Fix variance problems.
This commit is contained in:
@@ -35,7 +35,7 @@ public trait ResolverForModule {
|
|||||||
public val lazyResolveSession: ResolveSession
|
public val lazyResolveSession: ResolveSession
|
||||||
}
|
}
|
||||||
|
|
||||||
public trait ResolverForProject<M : ModuleInfo, R : ResolverForModule> {
|
public trait ResolverForProject<M : ModuleInfo,out R : ResolverForModule> {
|
||||||
public fun resolverForModule(moduleInfo: M): R
|
public fun resolverForModule(moduleInfo: M): R
|
||||||
public fun descriptorForModule(moduleInfo: M): ModuleDescriptor
|
public fun descriptorForModule(moduleInfo: M): ModuleDescriptor
|
||||||
val allModules: Collection<M>
|
val allModules: Collection<M>
|
||||||
@@ -113,7 +113,7 @@ public trait ModuleInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: (module refactoring) extract project context
|
//TODO: (module refactoring) extract project context
|
||||||
public trait AnalyzerFacade<out A : ResolverForModule, in P : PlatformAnalysisParameters> {
|
public trait AnalyzerFacade<A : ResolverForModule, in P : PlatformAnalysisParameters> {
|
||||||
public fun <M : ModuleInfo> setupResolverForProject(
|
public fun <M : ModuleInfo> setupResolverForProject(
|
||||||
globalContext: GlobalContext,
|
globalContext: GlobalContext,
|
||||||
project: Project,
|
project: Project,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
trait R<in T: Comparable<T>> {
|
trait R<T: Comparable<T>> {
|
||||||
var value: T
|
var value: T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class Holder(var value: Int) {
|
|||||||
fun set(that: Any?, desc: PropertyMetadata, newValue: Int) { value = newValue }
|
fun set(that: Any?, desc: PropertyMetadata, newValue: Int) { value = newValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
trait R<in T: Comparable<T>> {
|
trait R<T: Comparable<T>> {
|
||||||
var value: T
|
var value: T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
open class A<out T> () {
|
open class A<T> () {
|
||||||
fun plus(e: T) = B<T> (e)
|
fun plus(e: T) = B<T> (e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class Zin<in T> {}
|
|||||||
|
|
||||||
class Params(val methodIndex: Int, val paramClass: Class<*>, val expectedReturnType: String, val expecedParamType: String)
|
class Params(val methodIndex: Int, val paramClass: Class<*>, val expectedReturnType: String, val expecedParamType: String)
|
||||||
|
|
||||||
class Test<T, out X, in Y>() {
|
class Test<T, X, in Y>() {
|
||||||
|
|
||||||
fun test1(p: T): T? = null
|
fun test1(p: T): T? = null
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ trait A
|
|||||||
trait B: A
|
trait B: A
|
||||||
trait D
|
trait D
|
||||||
|
|
||||||
trait BaseSuper<T>
|
trait BaseSuper<out T>
|
||||||
trait BaseImpl: BaseSuper<D>
|
trait BaseImpl: BaseSuper<D>
|
||||||
trait DerivedSuper<out S>: <!INCONSISTENT_TYPE_PARAMETER_VALUES!>BaseSuper<S>, BaseImpl<!>
|
trait DerivedSuper<out S>: <!INCONSISTENT_TYPE_PARAMETER_VALUES!>BaseSuper<S>, BaseImpl<!>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ internal trait BaseImpl : BaseSuper<D> {
|
|||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
internal trait BaseSuper</*0*/ T> {
|
internal trait BaseSuper</*0*/ out T> {
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ enum class KClassOrigin {
|
|||||||
private val KOTLIN_CLASS_ANNOTATION_CLASS = javaClassOf<KotlinClass>()
|
private val KOTLIN_CLASS_ANNOTATION_CLASS = javaClassOf<KotlinClass>()
|
||||||
private val KOTLIN_SYNTHETIC_CLASS_ANNOTATION_CLASS = javaClassOf<KotlinSyntheticClass>()
|
private val KOTLIN_SYNTHETIC_CLASS_ANNOTATION_CLASS = javaClassOf<KotlinSyntheticClass>()
|
||||||
|
|
||||||
class KClassImpl<out T>(val jClass: Class<T>, isKnownToBeKotlin: Boolean) : KClass<T> {
|
class KClassImpl<T>(val jClass: Class<T>, isKnownToBeKotlin: Boolean) : KClass<T> {
|
||||||
// TODO: write metadata to local classes
|
// TODO: write metadata to local classes
|
||||||
private val origin: KClassOrigin =
|
private val origin: KClassOrigin =
|
||||||
if (isKnownToBeKotlin ||
|
if (isKnownToBeKotlin ||
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ open class KForeignMemberProperty<T : Any, out R>(
|
|||||||
"val ${owner.jClass.getName()}.$name"
|
"val ${owner.jClass.getName()}.$name"
|
||||||
}
|
}
|
||||||
|
|
||||||
class KMutableForeignMemberProperty<T : Any, out R>(
|
class KMutableForeignMemberProperty<T : Any, R>(
|
||||||
name: String,
|
name: String,
|
||||||
owner: KClassImpl<T>
|
owner: KClassImpl<T>
|
||||||
) : KMutableMemberProperty<T, R>, KMutablePropertyImpl<R>, KForeignMemberProperty<T, R>(name, owner) {
|
) : KMutableMemberProperty<T, R>, KMutablePropertyImpl<R>, KForeignMemberProperty<T, R>(name, owner) {
|
||||||
|
|||||||
@@ -18,4 +18,4 @@ package kotlin.reflect
|
|||||||
|
|
||||||
public trait KTopLevelExtensionProperty<T, out R> : KExtensionProperty<T, R>, KTopLevelProperty<R>
|
public trait KTopLevelExtensionProperty<T, out R> : KExtensionProperty<T, R>, KTopLevelProperty<R>
|
||||||
|
|
||||||
public trait KMutableTopLevelExtensionProperty<T, out R> : KTopLevelExtensionProperty<T, R>, KMutableExtensionProperty<T, R>, KMutableTopLevelProperty<R>
|
public trait KMutableTopLevelExtensionProperty<T, R> : KTopLevelExtensionProperty<T, R>, KMutableExtensionProperty<T, R>, KMutableTopLevelProperty<R>
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ import org.jetbrains.jet.context.GlobalContextImpl
|
|||||||
fun createModuleResolverProvider(
|
fun createModuleResolverProvider(
|
||||||
project: Project,
|
project: Project,
|
||||||
globalContext: GlobalContextImpl,
|
globalContext: GlobalContextImpl,
|
||||||
analyzerFacade: AnalyzerFacade<ResolverForModule, JvmPlatformParameters>,
|
analyzerFacade: AnalyzerFacade<out ResolverForModule, JvmPlatformParameters>,
|
||||||
syntheticFiles: Collection<JetFile>,
|
syntheticFiles: Collection<JetFile>,
|
||||||
delegateProvider: ModuleResolverProvider,
|
delegateProvider: ModuleResolverProvider,
|
||||||
moduleFilter: (IdeaModuleInfo) -> Boolean
|
moduleFilter: (IdeaModuleInfo) -> Boolean
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.plugin.caches.resolve.JsAnalyzerFacade
|
|||||||
public object AnalyzerFacadeProvider {
|
public object AnalyzerFacadeProvider {
|
||||||
//NOTE: it's convenient that JS backend doesn't have platform parameters (for now)
|
//NOTE: it's convenient that JS backend doesn't have platform parameters (for now)
|
||||||
// otherwise we would be forced to add casts on the call site of setupResolverForProject
|
// otherwise we would be forced to add casts on the call site of setupResolverForProject
|
||||||
public fun getAnalyzerFacade(targetPlatform: TargetPlatform): AnalyzerFacade<ResolverForModule, JvmPlatformParameters> {
|
public fun getAnalyzerFacade(targetPlatform: TargetPlatform): AnalyzerFacade<out ResolverForModule, JvmPlatformParameters> {
|
||||||
return when (targetPlatform) {
|
return when (targetPlatform) {
|
||||||
TargetPlatform.JVM -> JvmAnalyzerFacade
|
TargetPlatform.JVM -> JvmAnalyzerFacade
|
||||||
TargetPlatform.JS -> JsAnalyzerFacade
|
TargetPlatform.JS -> JsAnalyzerFacade
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// "Cast expression 'x' to 'Foo<Number>'" "true"
|
// "Cast expression 'x' to 'Foo<out Number>'" "true"
|
||||||
trait Foo<out T: Number> {
|
trait Foo<T: Number> {
|
||||||
fun foo(x: T)
|
fun foo()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(_x: Any) {
|
fun bar(_x: Any) {
|
||||||
var x = _x
|
var x = _x
|
||||||
if (x is Foo<*>) {
|
if (x is Foo<*>) {
|
||||||
(x as Foo<Number>)<caret>.foo(42)
|
(x as Foo<out Number>)<caret>.foo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
// "Cast expression 'x' to 'Foo<Number>'" "true"
|
// "Cast expression 'x' to 'Foo<out Number>'" "true"
|
||||||
trait Foo<out T: Number> {
|
trait Foo<T: Number> {
|
||||||
fun foo(x: T)
|
fun foo()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(_x: Any) {
|
fun bar(_x: Any) {
|
||||||
var x = _x
|
var x = _x
|
||||||
if (x is Foo<*>) {
|
if (x is Foo<*>) {
|
||||||
x<caret>.foo(42)
|
x<caret>.foo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ private class BlockingLazyVal<T>(lock: Any?, private val initializer: () -> T) :
|
|||||||
|
|
||||||
public class KeyMissingException(message: String): RuntimeException(message)
|
public class KeyMissingException(message: String): RuntimeException(message)
|
||||||
|
|
||||||
public abstract class MapVal<T, in K, out V>() : ReadOnlyProperty<T, V> {
|
public abstract class MapVal<T, K, out V>() : ReadOnlyProperty<T, V> {
|
||||||
protected abstract fun map(ref: T): Map<in K, Any?>
|
protected abstract fun map(ref: T): Map<in K, Any?>
|
||||||
protected abstract fun key(desc: PropertyMetadata): K
|
protected abstract fun key(desc: PropertyMetadata): K
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ public abstract class MapVal<T, in K, out V>() : ReadOnlyProperty<T, V> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class MapVar<T, in K, V>() : MapVal<T, K, V>(), ReadWriteProperty<T, V> {
|
public abstract class MapVar<T, K, V>() : MapVal<T, K, V>(), ReadWriteProperty<T, V> {
|
||||||
protected abstract override fun map(ref: T): MutableMap<in K, Any?>
|
protected abstract override fun map(ref: T): MutableMap<in K, Any?>
|
||||||
|
|
||||||
public override fun set(thisRef: T, desc: PropertyMetadata, value: V) {
|
public override fun set(thisRef: T, desc: PropertyMetadata, value: V) {
|
||||||
@@ -144,7 +144,7 @@ public abstract class MapVar<T, in K, V>() : MapVal<T, K, V>(), ReadWritePropert
|
|||||||
private val defaultKeyProvider:(PropertyMetadata) -> String = {it.name}
|
private val defaultKeyProvider:(PropertyMetadata) -> String = {it.name}
|
||||||
private val defaultValueProvider:(Any?, Any?) -> Nothing = {(thisRef, key) -> throw KeyMissingException("$key is missing from $thisRef")}
|
private val defaultValueProvider:(Any?, Any?) -> Nothing = {(thisRef, key) -> throw KeyMissingException("$key is missing from $thisRef")}
|
||||||
|
|
||||||
public open class FixedMapVal<T, in K, out V>(private val map: Map<in K, Any?>,
|
public open class FixedMapVal<T, K, out V>(private val map: Map<in K, Any?>,
|
||||||
private val key: (PropertyMetadata) -> K,
|
private val key: (PropertyMetadata) -> K,
|
||||||
private val default: (ref: T, key: K) -> V = defaultValueProvider) : MapVal<T, K, V>() {
|
private val default: (ref: T, key: K) -> V = defaultValueProvider) : MapVal<T, K, V>() {
|
||||||
protected override fun map(ref: T): Map<in K, Any?> {
|
protected override fun map(ref: T): Map<in K, Any?> {
|
||||||
@@ -160,7 +160,7 @@ public open class FixedMapVal<T, in K, out V>(private val map: Map<in K, Any?>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public open class FixedMapVar<T, in K, V>(private val map: MutableMap<in K, Any?>,
|
public open class FixedMapVar<T, K, V>(private val map: MutableMap<in K, Any?>,
|
||||||
private val key: (PropertyMetadata) -> K,
|
private val key: (PropertyMetadata) -> K,
|
||||||
private val default: (ref: T, key: K) -> V = defaultValueProvider) : MapVar<T, K, V>() {
|
private val default: (ref: T, key: K) -> V = defaultValueProvider) : MapVar<T, K, V>() {
|
||||||
protected override fun map(ref: T): MutableMap<in K, Any?> {
|
protected override fun map(ref: T): MutableMap<in K, Any?> {
|
||||||
|
|||||||
Reference in New Issue
Block a user