Star projection information preserved in substitutions
#KT-6700 Fixed
This commit is contained in:
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.CollectionClassMapping
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import java.util.LinkedHashSet
|
||||
import org.jetbrains.kotlin.types.typeUtil.substitute
|
||||
|
||||
fun JetType.makeNullable() = TypeUtils.makeNullable(this)
|
||||
fun JetType.makeNotNullable() = TypeUtils.makeNotNullable(this)
|
||||
@@ -53,7 +54,7 @@ public fun approximateFlexibleTypes(jetType: JetType, outermost: Boolean = true)
|
||||
jetType.getAnnotations(),
|
||||
jetType.getConstructor(),
|
||||
jetType.isMarkedNullable(),
|
||||
jetType.getArguments().map { TypeProjectionImpl(it.getProjectionKind(), approximateFlexibleTypes(it.getType(), false)) },
|
||||
jetType.getArguments().map { it.substitute { type -> approximateFlexibleTypes(type, false)} },
|
||||
ErrorUtils.createErrorScope("This type is not supposed to be used in member resolution", true)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class C<T : C<T>>
|
||||
|
||||
trait Base {
|
||||
fun foo(c: C<*>)
|
||||
}
|
||||
|
||||
class Derived : Base {
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class C<T : C<T>>
|
||||
|
||||
trait Base {
|
||||
fun foo(c: C<*>)
|
||||
}
|
||||
|
||||
class Derived : Base {
|
||||
override fun foo(c: C<*>) {
|
||||
<selection><caret>throw UnsupportedOperationException()</selection>
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Cast expression 'x' to 'Foo<out Number>'" "true"
|
||||
// "Cast expression 'x' to 'Foo<*>'" "true"
|
||||
trait Foo<T: Number> {
|
||||
fun foo()
|
||||
}
|
||||
@@ -6,6 +6,6 @@ trait Foo<T: Number> {
|
||||
fun bar(_x: Any) {
|
||||
var x = _x
|
||||
if (x is Foo<*>) {
|
||||
(x as Foo<out Number>)<caret>.foo()
|
||||
(x as Foo<*>).foo()
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Cast expression 'x' to 'Foo<out Number>'" "true"
|
||||
// "Cast expression 'x' to 'Foo<*>'" "true"
|
||||
trait Foo<T: Number> {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
@@ -197,4 +197,8 @@ public final class OverrideImplementTest extends AbstractOverrideImplementTest {
|
||||
public void testLocalClass() {
|
||||
doImplementFileTest();
|
||||
}
|
||||
|
||||
public void testStarProjections() {
|
||||
doImplementFileTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user