Use upper bound checker for typealias expansion

This commit is contained in:
Victor Petukhov
2021-02-03 12:59:49 +03:00
parent edb8007d52
commit d783d99443
20 changed files with 306 additions and 140 deletions
@@ -1,11 +1,36 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// FULL_JDK
// FILE: MapLike.java
import java.util.Map;
public interface MapLike<@org.jetbrains.annotations.NotNull K, V> {
public class MapLike<@org.jetbrains.annotations.NotNull K, V> {
void putAll(Map<K, V> map);
}
// FILE: ListLike.java
import java.util.Collection;
public class ListLike<K extends Collection<@org.jetbrains.annotations.NotNull Object>> {}
// FILE: main.kt
fun test(map : MapLike<Int?, Int>) {}
fun test0(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>, Int>) {}
fun <K> test11(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>K<!>, K>) {}
fun <K> test12(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>K?<!>, K>) {}
fun <K : Any> test13(map : MapLike<K, K>) {}
fun <K : Any> test14(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>K?<!>, K>) {}
class Foo<K>
typealias A<A> = MapLike<A, Int>
typealias A2<B> = Foo<MapLike<B, Int>>
typealias A3<C> = ListLike<List<C>>
fun main1(x: A<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>>) {}
fun main2(x: A2<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>>) {}
fun main3(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?><!>) {}
fun main3() {
val x = A3<Int?>() // TODO: support reporting errors on typealias constructor calls
val x2 = A<Int?>() // TODO: support reporting errors on typealias constructor calls
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?><!> = A3<Int?>()
}
@@ -1,16 +1,36 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// FULL_JDK
// FILE: MapLike.java
import java.util.Map;
public interface MapLike<@org.jetbrains.annotations.NotNull K, V> {
public class MapLike<@org.jetbrains.annotations.NotNull K, V> {
void putAll(Map<K, V> map);
}
// FILE: ListLike.java
import java.util.Collection;
public class ListLike<K extends Collection<@org.jetbrains.annotations.NotNull Object>> {}
// FILE: main.kt
fun test0(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>, Int>) {}
fun <K> test11(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>K<!>, K>) {}
fun <K> test12(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>K?<!>, K>) {}
fun <K : Any> test13(map : MapLike<K, K>) {}
fun <K : Any> test14(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>K?<!>, K>) {}
class Foo<K>
typealias A<A> = MapLike<A, Int>
typealias A2<B> = Foo<MapLike<B, Int>>
typealias A3<C> = ListLike<List<C>>
fun main1(x: A<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>>) {}
fun main2(x: A2<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>>) {}
fun main3(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?><!>) {}
fun main3() {
val x = A3<Int?>() // TODO: support reporting errors on typealias constructor calls
val x2 = A<Int?>() // TODO: support reporting errors on typealias constructor calls
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?><!> = A3<Int?>()
}
@@ -1,15 +1,37 @@
package
public fun main1(/*0*/ x: A<kotlin.Int?> /* = MapLike<kotlin.Int?, kotlin.Int> */): kotlin.Unit
public fun main2(/*0*/ x: A2<kotlin.Int?> /* = Foo<MapLike<kotlin.Int?, kotlin.Int>> */): kotlin.Unit
public fun main3(): kotlin.Unit
public fun main3(/*0*/ x: A3<kotlin.Int?> /* = ListLike<kotlin.collections.List<kotlin.Int?>> */): kotlin.Unit
public fun test0(/*0*/ map: MapLike<kotlin.Int?, kotlin.Int>): kotlin.Unit
public fun </*0*/ K> test11(/*0*/ map: MapLike<K, K>): kotlin.Unit
public fun </*0*/ K> test12(/*0*/ map: MapLike<K?, K>): kotlin.Unit
public fun </*0*/ K : kotlin.Any> test13(/*0*/ map: MapLike<K, K>): kotlin.Unit
public fun </*0*/ K : kotlin.Any> test14(/*0*/ map: MapLike<K?, K>): kotlin.Unit
public fun test2(/*0*/ map: MapLike<kotlin.Int, kotlin.Int>): kotlin.Unit
public interface MapLike</*0*/ @org.jetbrains.annotations.NotNull K : kotlin.Any!, /*1*/ V : kotlin.Any!> {
public final class Foo</*0*/ K> {
public constructor Foo</*0*/ K>()
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 abstract fun putAll(/*0*/ map: kotlin.collections.(Mutable)Map<K!, V!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class ListLike</*0*/ K : kotlin.collections.(Mutable)Collection<@org.jetbrains.annotations.NotNull kotlin.Any!>!> {
public constructor ListLike</*0*/ K : kotlin.collections.(Mutable)Collection<@org.jetbrains.annotations.NotNull kotlin.Any!>!>()
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
}
public open class MapLike</*0*/ @org.jetbrains.annotations.NotNull K : kotlin.Any!, /*1*/ V : kotlin.Any!> {
public constructor MapLike</*0*/ @org.jetbrains.annotations.NotNull K : kotlin.Any!, /*1*/ V : kotlin.Any!>()
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/*package*/ open fun putAll(/*0*/ map: kotlin.collections.(Mutable)Map<K!, V!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public typealias A</*0*/ A> = MapLike<A, kotlin.Int>
public typealias A2</*0*/ B> = Foo<MapLike<B, kotlin.Int>>
public typealias A3</*0*/ C> = ListLike<kotlin.collections.List<C>>
@@ -1,17 +1,37 @@
// !LANGUAGE: +ImprovementsAroundTypeEnhancement
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// FULL_JDK
// FILE: MapLike.java
import java.util.Map;
public interface MapLike<@org.jetbrains.annotations.NotNull K, V> {
public class MapLike<@org.jetbrains.annotations.NotNull K, V> {
void putAll(Map<K, V> map);
}
// FILE: ListLike.java
import java.util.Collection;
public class ListLike<K extends Collection<@org.jetbrains.annotations.NotNull Object>> {}
// FILE: main.kt
fun test0(map : MapLike<Int?, Int>) {}
fun <K> test11(map : MapLike<K, K>) {}
fun <K> test12(map : MapLike<K?, K>) {}
fun test0(map : MapLike<<!UPPER_BOUND_VIOLATED!>Int?<!>, Int>) {}
fun <K> test11(map : MapLike<<!UPPER_BOUND_VIOLATED!>K<!>, K>) {}
fun <K> test12(map : MapLike<<!UPPER_BOUND_VIOLATED!>K?<!>, K>) {}
fun <K : Any> test13(map : MapLike<K, K>) {}
fun <K : Any> test14(map : MapLike<K?, K>) {}
fun <K : Any> test14(map : MapLike<<!UPPER_BOUND_VIOLATED!>K?<!>, K>) {}
class Foo<K>
typealias A<A> = MapLike<A, Int>
typealias A2<B> = Foo<MapLike<B, Int>>
typealias A3<C> = ListLike<List<C>>
fun main1(x: A<<!UPPER_BOUND_VIOLATED!>Int?<!>>) {}
fun main2(x: A2<<!UPPER_BOUND_VIOLATED!>Int?<!>>) {}
fun main3(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A3<Int?><!>) {}
fun main3() {
val x = A3<Int?>() // TODO: support reporting errors on typealias constructor calls
val x2 = A<Int?>()
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A3<Int?><!> = A3<Int?>()
}
@@ -1,17 +1,37 @@
// !LANGUAGE: +ImprovementsAroundTypeEnhancement
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// FULL_JDK
// FILE: MapLike.java
import java.util.Map;
public interface MapLike<@org.jetbrains.annotations.NotNull K, V> {
public class MapLike<@org.jetbrains.annotations.NotNull K, V> {
void putAll(Map<K, V> map);
}
// FILE: ListLike.java
import java.util.Collection;
public class ListLike<K extends Collection<@org.jetbrains.annotations.NotNull Object>> {}
// FILE: main.kt
fun test0(map : MapLike<<!UPPER_BOUND_VIOLATED!>Int?<!>, Int>) {}
fun <K> test11(map : MapLike<<!UPPER_BOUND_VIOLATED!>K<!>, K>) {}
fun <K> test12(map : MapLike<<!UPPER_BOUND_VIOLATED!>K?<!>, K>) {}
fun <K : Any> test13(map : MapLike<K, K>) {}
fun <K : Any> test14(map : MapLike<<!UPPER_BOUND_VIOLATED!>K?<!>, K>) {}
class Foo<K>
typealias A<A> = MapLike<A, Int>
typealias A2<B> = Foo<MapLike<B, Int>>
typealias A3<C> = ListLike<List<C>>
fun main1(x: A<<!UPPER_BOUND_VIOLATED!>Int?<!>>) {}
fun main2(x: A2<<!UPPER_BOUND_VIOLATED!>Int?<!>>) {}
fun main3(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A3<Int?><!>) {}
fun main3() {
val x = A3<Int?>() // TODO: support reporting errors on typealias constructor calls
val x2 = A<<!UPPER_BOUND_VIOLATED!>Int?<!>>()
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A3<Int?><!> = A3<Int?>()
}
@@ -1,14 +1,37 @@
package
public fun main1(/*0*/ x: A<kotlin.Int?> /* = MapLike<kotlin.Int?, kotlin.Int> */): kotlin.Unit
public fun main2(/*0*/ x: A2<kotlin.Int?> /* = Foo<MapLike<kotlin.Int?, kotlin.Int>> */): kotlin.Unit
public fun main3(): kotlin.Unit
public fun main3(/*0*/ x: A3<kotlin.Int?> /* = ListLike<kotlin.collections.List<kotlin.Int?>> */): kotlin.Unit
public fun test0(/*0*/ map: MapLike<kotlin.Int?, kotlin.Int>): kotlin.Unit
public fun </*0*/ K> test11(/*0*/ map: MapLike<K, K>): kotlin.Unit
public fun </*0*/ K> test12(/*0*/ map: MapLike<K?, K>): kotlin.Unit
public fun </*0*/ K : kotlin.Any> test13(/*0*/ map: MapLike<K, K>): kotlin.Unit
public fun </*0*/ K : kotlin.Any> test14(/*0*/ map: MapLike<K?, K>): kotlin.Unit
public interface MapLike</*0*/ @org.jetbrains.annotations.NotNull K : kotlin.Any, /*1*/ V : kotlin.Any!> {
public final class Foo</*0*/ K> {
public constructor Foo</*0*/ K>()
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 abstract fun putAll(/*0*/ map: kotlin.collections.(Mutable)Map<K, V!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class ListLike</*0*/ K : kotlin.collections.(Mutable)Collection<@org.jetbrains.annotations.NotNull kotlin.Any>!> {
public constructor ListLike</*0*/ K : kotlin.collections.(Mutable)Collection<@org.jetbrains.annotations.NotNull kotlin.Any>!>()
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
}
public open class MapLike</*0*/ @org.jetbrains.annotations.NotNull K : kotlin.Any, /*1*/ V : kotlin.Any!> {
public constructor MapLike</*0*/ @org.jetbrains.annotations.NotNull K : kotlin.Any, /*1*/ V : kotlin.Any!>()
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/*package*/ open fun putAll(/*0*/ map: kotlin.collections.(Mutable)Map<K, V!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public typealias A</*0*/ A> = MapLike<A, kotlin.Int>
public typealias A2</*0*/ B> = Foo<MapLike<B, kotlin.Int>>
public typealias A3</*0*/ C> = ListLike<kotlin.collections.List<C>>