Add TypeBinding.
This commit is contained in:
@@ -32,6 +32,7 @@ public interface JetTypeElement extends JetElement {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// may contain null
|
||||||
@NotNull
|
@NotNull
|
||||||
List<JetTypeReference> getTypeArgumentsAsTypes();
|
List<JetTypeReference> getTypeArgumentsAsTypes();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 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.lang.resolve.typeBinding
|
||||||
|
|
||||||
|
import org.jetbrains.jet.lang.types.JetType
|
||||||
|
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.jet.lang.psi.JetTypeElement
|
||||||
|
import org.jetbrains.jet.lang.psi.JetCallableDeclaration
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingTrace
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
|
import org.jetbrains.jet.lang.psi.JetTypeReference
|
||||||
|
import java.util.AbstractList
|
||||||
|
import org.jetbrains.jet.lang.types.TypeProjection
|
||||||
|
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||||
|
import org.jetbrains.jet.lang.types.TypeProjectionImpl
|
||||||
|
|
||||||
|
|
||||||
|
trait TypeBinding<out P : PsiElement> {
|
||||||
|
val psiElement: P
|
||||||
|
val jetType: JetType
|
||||||
|
fun getArgumentBindings(): List<TypeArgumentBinding<P>?>
|
||||||
|
}
|
||||||
|
|
||||||
|
trait TypeArgumentBinding<out P: PsiElement> {
|
||||||
|
val typeProjection: TypeProjection
|
||||||
|
val typeParameterDescriptor: TypeParameterDescriptor?
|
||||||
|
val typeBinding: TypeBinding<P>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun JetTypeReference.createTypeBinding(trace: BindingContext): TypeBinding<JetTypeElement>? {
|
||||||
|
val jetType = trace[BindingContext.TYPE, this]
|
||||||
|
val psiElement = getTypeElement()
|
||||||
|
if (jetType == null || psiElement == null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ExplicitTypeBinding(trace, psiElement, jetType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun JetCallableDeclaration.createTypeBindingForReturnType(trace: BindingContext): TypeBinding<PsiElement>? {
|
||||||
|
val jetTypeReference = getTypeReference()
|
||||||
|
if (jetTypeReference != null) return jetTypeReference.createTypeBinding(trace)
|
||||||
|
|
||||||
|
val descriptor = trace[BindingContext.DECLARATION_TO_DESCRIPTOR, this]
|
||||||
|
if (descriptor !is CallableDescriptor) return null
|
||||||
|
|
||||||
|
return descriptor.getReturnType()?.let { NoTypeElementBinding(trace, this, it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TypeArgumentBindingImpl<out P: PsiElement>(
|
||||||
|
override val typeProjection: TypeProjection,
|
||||||
|
override val typeParameterDescriptor: TypeParameterDescriptor?,
|
||||||
|
override val typeBinding: TypeBinding<P>
|
||||||
|
) : TypeArgumentBinding<P>
|
||||||
|
|
||||||
|
private class ExplicitTypeBinding(
|
||||||
|
private val trace: BindingContext,
|
||||||
|
override val psiElement: JetTypeElement,
|
||||||
|
override val jetType: JetType
|
||||||
|
) : TypeBinding<JetTypeElement> {
|
||||||
|
|
||||||
|
override fun getArgumentBindings(): List<TypeArgumentBinding<JetTypeElement>?> {
|
||||||
|
val psiTypeArguments = psiElement.getTypeArgumentsAsTypes()
|
||||||
|
val isErrorBinding = run {
|
||||||
|
val sizeIsEqual = psiTypeArguments.size == jetType.getArguments().size
|
||||||
|
&& psiTypeArguments.size == jetType.getConstructor().getParameters().size
|
||||||
|
jetType.isError() || !sizeIsEqual
|
||||||
|
}
|
||||||
|
|
||||||
|
return psiTypeArguments.indices.map { (index: Int): TypeArgumentBinding<JetTypeElement>? ->
|
||||||
|
// todo fix for List<*>
|
||||||
|
val jetTypeReference = psiTypeArguments[index]
|
||||||
|
val jetTypeElement = jetTypeReference?.getTypeElement()
|
||||||
|
if (jetTypeElement == null) return@map null;
|
||||||
|
|
||||||
|
if (isErrorBinding) {
|
||||||
|
val nextJetType = trace[BindingContext.TYPE, jetTypeReference]
|
||||||
|
if (nextJetType == null) return@map null;
|
||||||
|
|
||||||
|
return@map TypeArgumentBindingImpl(
|
||||||
|
TypeProjectionImpl(nextJetType),
|
||||||
|
null,
|
||||||
|
ExplicitTypeBinding(trace, jetTypeElement, nextJetType)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val typeProjection = jetType.getArguments()[index]
|
||||||
|
return@map TypeArgumentBindingImpl(
|
||||||
|
typeProjection,
|
||||||
|
jetType.getConstructor().getParameters()[index],
|
||||||
|
ExplicitTypeBinding(trace, jetTypeElement, typeProjection.getType())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NoTypeElementBinding<out P : PsiElement>(
|
||||||
|
private val trace: BindingContext,
|
||||||
|
override val psiElement: P,
|
||||||
|
override val jetType: JetType
|
||||||
|
): TypeBinding<P> {
|
||||||
|
|
||||||
|
override fun getArgumentBindings(): List<TypeArgumentBinding<P>?> {
|
||||||
|
val isErrorBinding = jetType.isError() || jetType.getConstructor().getParameters().size != jetType.getArguments().size
|
||||||
|
return jetType.getArguments().indices.map {
|
||||||
|
val typeProjection = jetType.getArguments()[it]
|
||||||
|
TypeArgumentBindingImpl(
|
||||||
|
typeProjection,
|
||||||
|
if (isErrorBinding) null else jetType.getConstructor().getParameters()[it],
|
||||||
|
NoTypeElementBinding(trace, psiElement, typeProjection.getType())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
val foo: List<in Int> = null!!
|
||||||
|
/*
|
||||||
|
psi: List<in Int>
|
||||||
|
type: List<in Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: in Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
val foo: List<in List<Int>> = null!!
|
||||||
|
/*
|
||||||
|
psi: List<in List<Int>>
|
||||||
|
type: List<in List<Int>>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: in List<Int>
|
||||||
|
psi: List<Int>
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
val foo: Pair<Pair<List<Int>>, String> = null!!
|
||||||
|
/*
|
||||||
|
psi: Pair<Pair<List<Int>>, String>
|
||||||
|
type: Pair<[ERROR : Pair<List<Int>>], String>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: [ERROR : Pair<List<Int>>]
|
||||||
|
psi: Pair<List<Int>>
|
||||||
|
type: [ERROR : Pair<List<Int>>]
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: List<Int>
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: String
|
||||||
|
psi: String
|
||||||
|
type: String
|
||||||
|
*/
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
val foo: List<in Int, out Int> = null!!
|
||||||
|
/*
|
||||||
|
psi: List<in Int, out Int>
|
||||||
|
type: [ERROR : List<in Int, out Int>]
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
val foo: List<(Pair<Int, Float>) -> List<Int>> = null!!
|
||||||
|
/*
|
||||||
|
psi: List<(Pair<Int, Float>) -> List<Int>>
|
||||||
|
type: List<(Pair<Int, Float>) -> List<Int>>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: (Pair<Int, Float>) -> List<Int>
|
||||||
|
psi: (Pair<Int, Float>) -> List<Int>
|
||||||
|
type: (Pair<Int, Float>) -> List<Int>
|
||||||
|
typeParameter: <in P1> defined in kotlin.Function1
|
||||||
|
typeProjection: Pair<Int, Float>
|
||||||
|
psi: Pair<Int, Float>
|
||||||
|
type: Pair<Int, Float>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: Float
|
||||||
|
psi: Float
|
||||||
|
type: Float
|
||||||
|
|
||||||
|
typeParameter: <out R> defined in kotlin.Function1
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: List<Int>
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
val foo: (Pair<Int, Float>) -> List<Int> = null!!
|
||||||
|
/*
|
||||||
|
psi: (Pair<Int, Float>) -> List<Int>
|
||||||
|
type: (Pair<Int, Float>) -> List<Int>
|
||||||
|
typeParameter: <in P1> defined in kotlin.Function1
|
||||||
|
typeProjection: Pair<Int, Float>
|
||||||
|
psi: Pair<Int, Float>
|
||||||
|
type: Pair<Int, Float>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: Float
|
||||||
|
psi: Float
|
||||||
|
type: Float
|
||||||
|
|
||||||
|
typeParameter: <out R> defined in kotlin.Function1
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: List<Int>
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
val foo: () -> List<Int> = null!!
|
||||||
|
/*
|
||||||
|
psi: () -> List<Int>
|
||||||
|
type: () -> List<Int>
|
||||||
|
typeParameter: <out R> defined in kotlin.Function0
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: List<Int>
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
trait Inv<T>
|
||||||
|
trait In<in I>
|
||||||
|
trait Out<out O>
|
||||||
|
|
||||||
|
|
||||||
|
val foo: Inv<in In<in Out<in Int>>> = null!!
|
||||||
|
/*
|
||||||
|
psi: Inv<in In<in Out<in Int>>>
|
||||||
|
type: Inv<in In<in Out<in Int>>>
|
||||||
|
typeParameter: <T> defined in Inv
|
||||||
|
typeProjection: in In<in Out<in Int>>
|
||||||
|
psi: In<in Out<in Int>>
|
||||||
|
type: In<in Out<in Int>>
|
||||||
|
typeParameter: <in I> defined in In
|
||||||
|
typeProjection: in Out<in Int>
|
||||||
|
psi: Out<in Int>
|
||||||
|
type: Out<in Int>
|
||||||
|
typeParameter: <out O> defined in Out
|
||||||
|
typeProjection: in Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
val fml: Int = 239
|
||||||
|
/*
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
val foo: List = null!!
|
||||||
|
/*
|
||||||
|
psi: List
|
||||||
|
type: [ERROR : List]
|
||||||
|
*/
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
val foo: List<String, List<Int>> = null!!
|
||||||
|
/*
|
||||||
|
psi: List<String, List<Int>>
|
||||||
|
type: [ERROR : List<String, List<Int>>]
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: String
|
||||||
|
psi: String
|
||||||
|
type: String
|
||||||
|
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: List<Int>
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
val foo: Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>> = null!!
|
||||||
|
/*
|
||||||
|
psi: Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>
|
||||||
|
type: Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: List<Int?>
|
||||||
|
psi: List<Int?>
|
||||||
|
type: List<Int?>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int?
|
||||||
|
psi: Int?
|
||||||
|
type: Int?
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: Pair<List<Int?>?, List<Int>?>
|
||||||
|
psi: Pair<List<Int?>?, List<Int>?>
|
||||||
|
type: Pair<List<Int?>?, List<Int>?>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: List<Int?>?
|
||||||
|
psi: List<Int?>?
|
||||||
|
type: List<Int?>?
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int?
|
||||||
|
psi: Int?
|
||||||
|
type: Int?
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: List<Int>?
|
||||||
|
psi: List<Int>?
|
||||||
|
type: List<Int>?
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
trait Inv<T>
|
||||||
|
trait In<in I>
|
||||||
|
trait Out<out O>
|
||||||
|
|
||||||
|
|
||||||
|
val foo: Inv<out In<out Out<out Int>>> = null!!
|
||||||
|
/*
|
||||||
|
psi: Inv<out In<out Out<out Int>>>
|
||||||
|
type: Inv<out In<out Out<out Int>>>
|
||||||
|
typeParameter: <T> defined in Inv
|
||||||
|
typeProjection: out In<out Out<out Int>>
|
||||||
|
psi: In<out Out<out Int>>
|
||||||
|
type: In<out Out<out Int>>
|
||||||
|
typeParameter: <in I> defined in In
|
||||||
|
typeProjection: out Out<out Int>
|
||||||
|
psi: Out<out Int>
|
||||||
|
type: Out<out Int>
|
||||||
|
typeParameter: <out O> defined in Out
|
||||||
|
typeProjection: out Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
|
||||||
|
val foo: Pair<List<Int>, String> = null!!
|
||||||
|
/*
|
||||||
|
psi: Pair<List<Int>, String>
|
||||||
|
type: Pair<List<Int>, String>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: List<Int>
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: String
|
||||||
|
psi: String
|
||||||
|
type: String
|
||||||
|
*/
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
val foo: List<Int> = null!!
|
||||||
|
/*
|
||||||
|
psi: List<Int>
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
val foo: List<*> = null!!
|
||||||
|
/*
|
||||||
|
psi: List<*>
|
||||||
|
type: List<Any?>
|
||||||
|
null
|
||||||
|
*/
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
trait Inv<I>
|
||||||
|
|
||||||
|
val foo: Inv<out ((Inv<Int>)?)> = null!!
|
||||||
|
/*
|
||||||
|
psi: Inv<out ((Inv<Int>)?)>
|
||||||
|
type: Inv<out Inv<Int>?>
|
||||||
|
typeParameter: <I> defined in Inv
|
||||||
|
typeProjection: out Inv<Int>?
|
||||||
|
psi: (Inv<Int>)?
|
||||||
|
type: Inv<Int>?
|
||||||
|
typeParameter: <I> defined in Inv
|
||||||
|
typeProjection: Int
|
||||||
|
psi: Int
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
val foo: List<adad<List<dd>>> = null!!
|
||||||
|
/*
|
||||||
|
psi: List<adad<List<dd>>>
|
||||||
|
type: List<[ERROR : adad<List<dd>>]>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: [ERROR : adad<List<dd>>]
|
||||||
|
psi: adad<List<dd>>
|
||||||
|
type: [ERROR : adad<List<dd>>]
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: List<[ERROR : dd]>
|
||||||
|
psi: List<dd>
|
||||||
|
type: List<[ERROR : dd]>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: [ERROR : dd]
|
||||||
|
psi: dd
|
||||||
|
type: [ERROR : dd]
|
||||||
|
*/
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<List<in Int>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<List<in Int>>()
|
||||||
|
type: List<in Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: in Int
|
||||||
|
psi: val foo = getT<List<in Int>>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<List<in List<Int>>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<List<in List<Int>>>()
|
||||||
|
type: List<in List<Int>>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: in List<Int>
|
||||||
|
psi: val foo = getT<List<in List<Int>>>()
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<List<in List<Int>>>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<Pair<Pair<List<Int>>, String>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<Pair<Pair<List<Int>>, String>>()
|
||||||
|
type: Pair<[ERROR : Pair<List<Int>>], String>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: [ERROR : Pair<List<Int>>]
|
||||||
|
psi: val foo = getT<Pair<Pair<List<Int>>, String>>()
|
||||||
|
type: [ERROR : Pair<List<Int>>]
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: String
|
||||||
|
psi: val foo = getT<Pair<Pair<List<Int>>, String>>()
|
||||||
|
type: String
|
||||||
|
*/
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<List<in Int, out Int>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<List<in Int, out Int>>()
|
||||||
|
type: [ERROR : List<in Int, out Int>]
|
||||||
|
*/
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<List<(Pair<Int, Float>) -> List<Int>>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<List<(Pair<Int, Float>) -> List<Int>>>()
|
||||||
|
type: List<(Pair<Int, Float>) -> List<Int>>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: (Pair<Int, Float>) -> List<Int>
|
||||||
|
psi: val foo = getT<List<(Pair<Int, Float>) -> List<Int>>>()
|
||||||
|
type: (Pair<Int, Float>) -> List<Int>
|
||||||
|
typeParameter: <in P1> defined in kotlin.Function1
|
||||||
|
typeProjection: Pair<Int, Float>
|
||||||
|
psi: val foo = getT<List<(Pair<Int, Float>) -> List<Int>>>()
|
||||||
|
type: Pair<Int, Float>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<List<(Pair<Int, Float>) -> List<Int>>>()
|
||||||
|
type: Int
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: Float
|
||||||
|
psi: val foo = getT<List<(Pair<Int, Float>) -> List<Int>>>()
|
||||||
|
type: Float
|
||||||
|
|
||||||
|
typeParameter: <out R> defined in kotlin.Function1
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: val foo = getT<List<(Pair<Int, Float>) -> List<Int>>>()
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<List<(Pair<Int, Float>) -> List<Int>>>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<(Pair<Int, Float>) -> List<Int>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<(Pair<Int, Float>) -> List<Int>>()
|
||||||
|
type: (Pair<Int, Float>) -> List<Int>
|
||||||
|
typeParameter: <in P1> defined in kotlin.Function1
|
||||||
|
typeProjection: Pair<Int, Float>
|
||||||
|
psi: val foo = getT<(Pair<Int, Float>) -> List<Int>>()
|
||||||
|
type: Pair<Int, Float>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<(Pair<Int, Float>) -> List<Int>>()
|
||||||
|
type: Int
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: Float
|
||||||
|
psi: val foo = getT<(Pair<Int, Float>) -> List<Int>>()
|
||||||
|
type: Float
|
||||||
|
|
||||||
|
typeParameter: <out R> defined in kotlin.Function1
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: val foo = getT<(Pair<Int, Float>) -> List<Int>>()
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<(Pair<Int, Float>) -> List<Int>>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<() -> List<Int>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<() -> List<Int>>()
|
||||||
|
type: () -> List<Int>
|
||||||
|
typeParameter: <out R> defined in kotlin.Function0
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: val foo = getT<() -> List<Int>>()
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<() -> List<Int>>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
trait Inv<T>
|
||||||
|
trait In<in I>
|
||||||
|
trait Out<out O>
|
||||||
|
|
||||||
|
|
||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<Inv<in In<in Out<in Int>>>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<Inv<in In<in Out<in Int>>>>()
|
||||||
|
type: Inv<in In<in Out<in Int>>>
|
||||||
|
typeParameter: <T> defined in Inv
|
||||||
|
typeProjection: in In<in Out<in Int>>
|
||||||
|
psi: val foo = getT<Inv<in In<in Out<in Int>>>>()
|
||||||
|
type: In<in Out<in Int>>
|
||||||
|
typeParameter: <in I> defined in In
|
||||||
|
typeProjection: in Out<in Int>
|
||||||
|
psi: val foo = getT<Inv<in In<in Out<in Int>>>>()
|
||||||
|
type: Out<in Int>
|
||||||
|
typeParameter: <out O> defined in Out
|
||||||
|
typeProjection: in Int
|
||||||
|
psi: val foo = getT<Inv<in In<in Out<in Int>>>>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val fml = getT<Int>()
|
||||||
|
/*
|
||||||
|
psi: val fml = getT<Int>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<List>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<List>()
|
||||||
|
type: [ERROR : List]
|
||||||
|
*/
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<List<String, List<Int>>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<List<String, List<Int>>>()
|
||||||
|
type: [ERROR : List<String, List<Int>>]
|
||||||
|
*/
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>>()
|
||||||
|
type: Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: List<Int?>
|
||||||
|
psi: val foo = getT<Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>>()
|
||||||
|
type: List<Int?>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int?
|
||||||
|
psi: val foo = getT<Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>>()
|
||||||
|
type: Int?
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: Pair<List<Int?>?, List<Int>?>
|
||||||
|
psi: val foo = getT<Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>>()
|
||||||
|
type: Pair<List<Int?>?, List<Int>?>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: List<Int?>?
|
||||||
|
psi: val foo = getT<Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>>()
|
||||||
|
type: List<Int?>?
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int?
|
||||||
|
psi: val foo = getT<Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>>()
|
||||||
|
type: Int?
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: List<Int>?
|
||||||
|
psi: val foo = getT<Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>>()
|
||||||
|
type: List<Int>?
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<Pair<List<Int?>, Pair<List<Int?>?, List<Int>?>>>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
trait Inv<T>
|
||||||
|
trait In<in I>
|
||||||
|
trait Out<out O>
|
||||||
|
|
||||||
|
|
||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<Inv<out In<out Out<out Int>>>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<Inv<out In<out Out<out Int>>>>()
|
||||||
|
type: Inv<out In<out Out<out Int>>>
|
||||||
|
typeParameter: <T> defined in Inv
|
||||||
|
typeProjection: out In<out Out<out Int>>
|
||||||
|
psi: val foo = getT<Inv<out In<out Out<out Int>>>>()
|
||||||
|
type: In<out Out<out Int>>
|
||||||
|
typeParameter: <in I> defined in In
|
||||||
|
typeProjection: out Out<out Int>
|
||||||
|
psi: val foo = getT<Inv<out In<out Out<out Int>>>>()
|
||||||
|
type: Out<out Int>
|
||||||
|
typeParameter: <out O> defined in Out
|
||||||
|
typeProjection: out Int
|
||||||
|
psi: val foo = getT<Inv<out In<out Out<out Int>>>>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<Pair<List<Int>, String>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<Pair<List<Int>, String>>()
|
||||||
|
type: Pair<List<Int>, String>
|
||||||
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: val foo = getT<Pair<List<Int>, String>>()
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<Pair<List<Int>, String>>()
|
||||||
|
type: Int
|
||||||
|
|
||||||
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
|
typeProjection: String
|
||||||
|
psi: val foo = getT<Pair<List<Int>, String>>()
|
||||||
|
type: String
|
||||||
|
*/
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<List<Int>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<List<Int>>()
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<List<Int>>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<List<*>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<List<*>>()
|
||||||
|
type: List<Any?>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Any?
|
||||||
|
psi: val foo = getT<List<*>>()
|
||||||
|
type: Any?
|
||||||
|
*/
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
trait Inv<I>
|
||||||
|
|
||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<Inv<out ((Inv<Int>)?)>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<Inv<out ((Inv<Int>)?)>>()
|
||||||
|
type: Inv<out Inv<Int>?>
|
||||||
|
typeParameter: <I> defined in Inv
|
||||||
|
typeProjection: out Inv<Int>?
|
||||||
|
psi: val foo = getT<Inv<out ((Inv<Int>)?)>>()
|
||||||
|
type: Inv<Int>?
|
||||||
|
typeParameter: <I> defined in Inv
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<Inv<out ((Inv<Int>)?)>>()
|
||||||
|
type: Int
|
||||||
|
*/
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
val foo = getT<List<adad<List<dd>>>()
|
||||||
|
/*
|
||||||
|
psi: val foo = getT<List<adad<List<dd>>>()
|
||||||
|
type: [ERROR : Type for getT<List<adad<List<dd>>>()]
|
||||||
|
*/
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 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.types
|
||||||
|
|
||||||
|
import org.jetbrains.jet.JetLiteFixture
|
||||||
|
import org.jetbrains.jet.ConfigurationKind
|
||||||
|
import org.jetbrains.jet.JetTestUtils
|
||||||
|
import java.io.File
|
||||||
|
import org.junit.Assert.*
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingTraceContext
|
||||||
|
import org.jetbrains.jet.lang.resolve.typeBinding.*
|
||||||
|
import org.jetbrains.jet.lang.types.JetType
|
||||||
|
import org.jetbrains.jet.renderer.DescriptorRenderer
|
||||||
|
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor
|
||||||
|
import org.jetbrains.jet.lang.resolve.lazy.JvmResolveUtil
|
||||||
|
import org.jetbrains.jet.lang.psi.JetCallableDeclaration
|
||||||
|
import org.jetbrains.jet.utils.Printer
|
||||||
|
import org.jetbrains.jet.test.util.trimIndent
|
||||||
|
import org.jetbrains.jet.lang.psi.JetFile
|
||||||
|
import org.jetbrains.jet.JetTestUtils.*
|
||||||
|
import org.jetbrains.jet.lang.psi.JetVariableDeclaration
|
||||||
|
|
||||||
|
abstract class AbstractJetTypeBindingTest : JetLiteFixture() {
|
||||||
|
override fun createEnvironment() = createEnvironmentWithMockJdk(ConfigurationKind.ALL)
|
||||||
|
|
||||||
|
protected fun doTest(path: String) {
|
||||||
|
val testFile = File(path)
|
||||||
|
val testKtFile = JetTestUtils.loadJetFile(getProject(), testFile)
|
||||||
|
|
||||||
|
val analyzeResult = JvmResolveUtil.analyzeFilesWithJavaIntegration(getProject(), listOf(testKtFile), { true })
|
||||||
|
|
||||||
|
val testDeclaration = testKtFile.getDeclarations().last!! as JetCallableDeclaration
|
||||||
|
|
||||||
|
val typeBinding = testDeclaration.createTypeBindingForReturnType(analyzeResult.bindingContext)
|
||||||
|
|
||||||
|
JetTestUtils.assertEqualsToFile(
|
||||||
|
testFile,
|
||||||
|
StringBuilder {
|
||||||
|
append(removeLastComment(testKtFile))
|
||||||
|
append("/*\n")
|
||||||
|
|
||||||
|
MyPrinter(this).print(typeBinding)
|
||||||
|
|
||||||
|
append("*/")
|
||||||
|
}.toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun removeLastComment(file: JetFile): String {
|
||||||
|
val fileText = file.getText()
|
||||||
|
val lastIndex = fileText.indexOf("/*")
|
||||||
|
return if (lastIndex > 0) {
|
||||||
|
fileText.substring(0, lastIndex)
|
||||||
|
}
|
||||||
|
else fileText
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MyPrinter(out: StringBuilder) : Printer(out) {
|
||||||
|
private fun JetType.render() = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this)
|
||||||
|
private fun TypeParameterDescriptor?.render() = if (this == null) "null" else DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(this)
|
||||||
|
|
||||||
|
fun print(argument: TypeArgumentBinding<*>?): MyPrinter {
|
||||||
|
if (argument == null) {
|
||||||
|
println("null")
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
println("typeParameter: ${argument.typeParameterDescriptor.render()}")
|
||||||
|
|
||||||
|
val projection = argument.typeProjection.getProjectionKind().toString().let {
|
||||||
|
if (it.isNotEmpty())
|
||||||
|
"$it "
|
||||||
|
else
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
println("typeProjection: ${projection}${argument.typeProjection.getType().render()}")
|
||||||
|
print(argument.typeBinding)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun print(binding: TypeBinding<*>?): MyPrinter {
|
||||||
|
if (binding == null) {
|
||||||
|
println("null")
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
println("psi: ${binding.psiElement.getText()}")
|
||||||
|
println("type: ${binding.jetType.render()}")
|
||||||
|
|
||||||
|
printCollection(binding.getArgumentBindings()) {
|
||||||
|
print(it)
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun <T> printCollection(list: Iterable<T>, f: MyPrinter.(T) -> Unit) {
|
||||||
|
pushIndent()
|
||||||
|
var first = true
|
||||||
|
for (element in list) {
|
||||||
|
if (first) first = false
|
||||||
|
else println()
|
||||||
|
|
||||||
|
f(element)
|
||||||
|
}
|
||||||
|
popIndent()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = out.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,273 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 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.types;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||||
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
|
import org.jetbrains.jet.test.InnerTestClasses;
|
||||||
|
import org.jetbrains.jet.test.TestMetadata;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("compiler/testData/type/binding")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@InnerTestClasses({JetTypeBindingTestGenerated.Explicit.class, JetTypeBindingTestGenerated.Implicit.class})
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class JetTypeBindingTestGenerated extends AbstractJetTypeBindingTest {
|
||||||
|
public void testAllFilesPresentInBinding() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/type/binding"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/type/binding/explicit")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Explicit extends AbstractJetTypeBindingTest {
|
||||||
|
public void testAllFilesPresentInExplicit() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/type/binding/explicit"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("conflictingProjection.kt")
|
||||||
|
public void testConflictingProjection() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/conflictingProjection.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("conflictingProjection2.kt")
|
||||||
|
public void testConflictingProjection2() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/conflictingProjection2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("errorPair.kt")
|
||||||
|
public void testErrorPair() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/errorPair.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("errorWithProjection.kt")
|
||||||
|
public void testErrorWithProjection() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/errorWithProjection.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionType.kt")
|
||||||
|
public void testFunctionType() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/functionType.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionType2.kt")
|
||||||
|
public void testFunctionType2() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/functionType2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionType3.kt")
|
||||||
|
public void testFunctionType3() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/functionType3.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inProjection.kt")
|
||||||
|
public void testInProjection() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/inProjection.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("int.kt")
|
||||||
|
public void testInt() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/int.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("list0.kt")
|
||||||
|
public void testList0() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/list0.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("list2.kt")
|
||||||
|
public void testList2() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/list2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nullableType.kt")
|
||||||
|
public void testNullableType() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/nullableType.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outProjection.kt")
|
||||||
|
public void testOutProjection() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/outProjection.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("pair.kt")
|
||||||
|
public void testPair() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/pair.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simple.kt")
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/simple.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("star.kt")
|
||||||
|
public void testStar() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/star.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeWithBracket.kt")
|
||||||
|
public void testTypeWithBracket() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/typeWithBracket.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unresolvedType.kt")
|
||||||
|
public void testUnresolvedType() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/explicit/unresolvedType.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/type/binding/implicit")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Implicit extends AbstractJetTypeBindingTest {
|
||||||
|
public void testAllFilesPresentInImplicit() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/type/binding/implicit"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("conflictingProjection.kt")
|
||||||
|
public void testConflictingProjection() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/conflictingProjection.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("conflictingProjection2.kt")
|
||||||
|
public void testConflictingProjection2() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/conflictingProjection2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("errorPair.kt")
|
||||||
|
public void testErrorPair() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/errorPair.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("errorWithProjection.kt")
|
||||||
|
public void testErrorWithProjection() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/errorWithProjection.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionType.kt")
|
||||||
|
public void testFunctionType() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/functionType.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionType2.kt")
|
||||||
|
public void testFunctionType2() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/functionType2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionType3.kt")
|
||||||
|
public void testFunctionType3() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/functionType3.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inProjection.kt")
|
||||||
|
public void testInProjection() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/inProjection.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("int.kt")
|
||||||
|
public void testInt() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/int.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("list0.kt")
|
||||||
|
public void testList0() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/list0.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("list2.kt")
|
||||||
|
public void testList2() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/list2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nullableType.kt")
|
||||||
|
public void testNullableType() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/nullableType.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outProjection.kt")
|
||||||
|
public void testOutProjection() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/outProjection.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("pair.kt")
|
||||||
|
public void testPair() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/pair.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simple.kt")
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/simple.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("star.kt")
|
||||||
|
public void testStar() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/star.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeWithBracket.kt")
|
||||||
|
public void testTypeWithBracket() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/typeWithBracket.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unresolvedType.kt")
|
||||||
|
public void testUnresolvedType() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/type/binding/implicit/unresolvedType.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ public class Printer {
|
|||||||
private static final String INDENTATION_UNIT = " ";
|
private static final String INDENTATION_UNIT = " ";
|
||||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||||
|
|
||||||
private final Appendable out;
|
protected final Appendable out;
|
||||||
private final int maxBlankLines;
|
private final int maxBlankLines;
|
||||||
|
|
||||||
private String indent = "";
|
private String indent = "";
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ import org.jetbrains.jet.completion.AbstractMultiFileSmartCompletionTest
|
|||||||
import org.jetbrains.jet.completion.handlers.AbstractCompletionCharFilterTest
|
import org.jetbrains.jet.completion.handlers.AbstractCompletionCharFilterTest
|
||||||
import org.jetbrains.jet.resolve.AbstractPartialBodyResolveTest
|
import org.jetbrains.jet.resolve.AbstractPartialBodyResolveTest
|
||||||
import org.jetbrains.jet.checkers.AbstractJetDiagnosticsTestWithJsStdLib
|
import org.jetbrains.jet.checkers.AbstractJetDiagnosticsTestWithJsStdLib
|
||||||
|
import org.jetbrains.jet.types.AbstractJetTypeBindingTest
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
System.setProperty("java.awt.headless", "true")
|
System.setProperty("java.awt.headless", "true")
|
||||||
@@ -300,6 +301,10 @@ fun main(args: Array<String>) {
|
|||||||
testClass(javaClass<AbstractKotlinLightClassTest>()) {
|
testClass(javaClass<AbstractKotlinLightClassTest>()) {
|
||||||
model("asJava/lightClasses")
|
model("asJava/lightClasses")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testClass(javaClass<AbstractJetTypeBindingTest>()) {
|
||||||
|
model("type/binding")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testGroup("idea/tests", "idea/testData") {
|
testGroup("idea/tests", "idea/testData") {
|
||||||
|
|||||||
Reference in New Issue
Block a user