Fix variance problems.

This commit is contained in:
Stanislav Erokhin
2014-08-27 17:13:00 +04:00
parent c10c1ad7f6
commit 65c9ea2465
15 changed files with 25 additions and 25 deletions
@@ -35,7 +35,7 @@ public trait ResolverForModule {
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 descriptorForModule(moduleInfo: M): ModuleDescriptor
val allModules: Collection<M>
@@ -113,7 +113,7 @@ public trait ModuleInfo {
}
//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(
globalContext: GlobalContext,
project: Project,
@@ -1,4 +1,4 @@
trait R<in T: Comparable<T>> {
trait R<T: Comparable<T>> {
var value: T
}
@@ -3,7 +3,7 @@ class Holder(var value: Int) {
fun set(that: Any?, desc: PropertyMetadata, newValue: Int) { value = newValue }
}
trait R<in T: Comparable<T>> {
trait R<T: Comparable<T>> {
var value: T
}
@@ -1,4 +1,4 @@
open class A<out T> () {
open class A<T> () {
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 Test<T, out X, in Y>() {
class Test<T, X, in Y>() {
fun test1(p: T): T? = null
@@ -2,7 +2,7 @@ trait A
trait B: A
trait D
trait BaseSuper<T>
trait BaseSuper<out T>
trait BaseImpl: BaseSuper<D>
trait DerivedSuper<out S>: <!INCONSISTENT_TYPE_PARAMETER_VALUES!>BaseSuper<S>, BaseImpl<!>
@@ -20,7 +20,7 @@ internal trait BaseImpl : BaseSuper<D> {
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 hashCode(): kotlin.Int
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_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
private val origin: KClassOrigin =
if (isKnownToBeKotlin ||
@@ -52,7 +52,7 @@ open class KForeignMemberProperty<T : Any, out R>(
"val ${owner.jClass.getName()}.$name"
}
class KMutableForeignMemberProperty<T : Any, out R>(
class KMutableForeignMemberProperty<T : Any, R>(
name: String,
owner: KClassImpl<T>
) : 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 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>
@@ -38,7 +38,7 @@ import org.jetbrains.jet.context.GlobalContextImpl
fun createModuleResolverProvider(
project: Project,
globalContext: GlobalContextImpl,
analyzerFacade: AnalyzerFacade<ResolverForModule, JvmPlatformParameters>,
analyzerFacade: AnalyzerFacade<out ResolverForModule, JvmPlatformParameters>,
syntheticFiles: Collection<JetFile>,
delegateProvider: ModuleResolverProvider,
moduleFilter: (IdeaModuleInfo) -> Boolean
@@ -25,7 +25,7 @@ import org.jetbrains.jet.plugin.caches.resolve.JsAnalyzerFacade
public object AnalyzerFacadeProvider {
//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
public fun getAnalyzerFacade(targetPlatform: TargetPlatform): AnalyzerFacade<ResolverForModule, JvmPlatformParameters> {
public fun getAnalyzerFacade(targetPlatform: TargetPlatform): AnalyzerFacade<out ResolverForModule, JvmPlatformParameters> {
return when (targetPlatform) {
TargetPlatform.JVM -> JvmAnalyzerFacade
TargetPlatform.JS -> JsAnalyzerFacade
@@ -1,11 +1,11 @@
// "Cast expression 'x' to 'Foo<Number>'" "true"
trait Foo<out T: Number> {
fun foo(x: T)
// "Cast expression 'x' to 'Foo<out Number>'" "true"
trait Foo<T: Number> {
fun foo()
}
fun bar(_x: Any) {
var x = _x
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"
trait Foo<out T: Number> {
fun foo(x: T)
// "Cast expression 'x' to 'Foo<out Number>'" "true"
trait Foo<T: Number> {
fun foo()
}
fun bar(_x: Any) {
var x = _x
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 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 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?>
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 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 default: (ref: T, key: K) -> V = defaultValueProvider) : MapVal<T, K, V>() {
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 default: (ref: T, key: K) -> V = defaultValueProvider) : MapVar<T, K, V>() {
protected override fun map(ref: T): MutableMap<in K, Any?> {