Handle java raw types in IR

Raw type Q is represented as a flexible type
  Q<B1, ... Bn> .. Q<*, ... *>
where Bi is a representative upper bound of the corresponding ith type
parameter of Q.
When mapping generic signature, JVM takes type arguments of lower bound
(which is 'Q<B1, ..., Bn>').

There is still some difference in how JVM and JVM_IR handle raw type in
signature. It requires additional investigation.
This commit is contained in:
Dmitry Petrov
2020-09-03 10:39:05 +03:00
parent 8420c0b7c7
commit 714ab7c37f
11 changed files with 507 additions and 22 deletions
@@ -2040,6 +2040,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.kt");
}
@TestMetadata("rawTypeInSignature.kt")
public void testRawTypeInSignature() throws Exception {
runTest("compiler/testData/ir/irText/types/rawTypeInSignature.kt");
}
@TestMetadata("receiverOfIntersectionType.kt")
public void testReceiverOfIntersectionType() throws Exception {
runTest("compiler/testData/ir/irText/types/receiverOfIntersectionType.kt");
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
@@ -116,27 +117,22 @@ class TypeTranslator(
when (ktTypeDescriptor) {
is TypeParameterDescriptor -> {
classifier = resolveTypeParameter(ktTypeDescriptor)
annotations = translateTypeAnnotations(approximatedType)
annotations = translateTypeAnnotations(approximatedType, flexibleApproximatedType)
}
is ClassDescriptor -> {
classifier = symbolTable.referenceClass(ktTypeDescriptor)
arguments = translateTypeArguments(approximatedType.arguments)
annotations = translateTypeAnnotations(approximatedType)
arguments =
if (flexibleApproximatedType is RawType)
translateTypeArguments(flexibleApproximatedType.arguments)
else
translateTypeArguments(approximatedType.arguments)
annotations = translateTypeAnnotations(approximatedType, flexibleApproximatedType)
}
else ->
throw AssertionError("Unexpected type descriptor $ktTypeDescriptor :: ${ktTypeDescriptor::class}")
}
if (flexibleApproximatedType.isNullabilityFlexible())
extensions.flexibleNullabilityAnnotationConstructor?.let { flexibleTypeAnnotationConstructor ->
annotations += IrConstructorCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
flexibleTypeAnnotationConstructor.constructedClassType,
flexibleTypeAnnotationConstructor.symbol,
0, 0, 0
)
}
}.buildTypeProjection()
}
@@ -194,27 +190,40 @@ class TypeTranslator(
approximateCapturedTypes(ktType).upper
}
private fun translateTypeAnnotations(kotlinType: KotlinType): List<IrConstructorCall> {
private fun translateTypeAnnotations(kotlinType: KotlinType, flexibleType: KotlinType = kotlinType): List<IrConstructorCall> {
val annotations = kotlinType.annotations
val irAnnotations = ArrayList<IrConstructorCall>()
annotations.mapNotNullTo(irAnnotations) {
constantValueGenerator.generateAnnotationConstructorCall(it)
}
// EnhancedNullability annotation is not present in 'annotations', see 'EnhancedTypeAnnotations::iterator()'.
// Also, EnhancedTypeAnnotationDescriptor is not a "real" annotation descriptor, there's no corresponding ClassDescriptor, etc.
if (extensions.enhancedNullability.hasEnhancedNullability(kotlinType)) {
extensions.enhancedNullabilityAnnotationConstructor?.let { irConstructor ->
irAnnotations.add(
IrConstructorCallImpl.fromSymbolOwner(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
irConstructor.constructedClassType,
irConstructor.symbol
)
)
}
irAnnotations.addSpecialAnnotation(extensions.enhancedNullabilityAnnotationConstructor)
}
if (flexibleType.isNullabilityFlexible()) {
irAnnotations.addSpecialAnnotation(extensions.flexibleNullabilityAnnotationConstructor)
}
return irAnnotations
}
private fun MutableList<IrConstructorCall>.addSpecialAnnotation(irConstructor: IrConstructor?) {
if (irConstructor != null) {
add(
IrConstructorCallImpl.fromSymbolOwner(
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
irConstructor.constructedClassType,
irConstructor.symbol
)
)
}
}
private fun translateTypeArguments(arguments: List<TypeProjection>) =
arguments.map {
if (it.isStarProjection)
@@ -0,0 +1,31 @@
// FILE: rawTypeInSignature.kt
// WITH_SIGNATURES
class GenericInv<T : Number>
class GenericIn<in T : Number>
class GenericOut<out T : Number>
fun testReturnsRawGenericInv(j: JRaw) = j.returnsRawGenericInv()
fun testReturnsRawGenericIn(j: JRaw) = j.returnsRawGenericIn()
fun testReturnsRawGenericOut(j: JRaw) = j.returnsRawGenericOut()
class KRaw(j: JRaw) : JRaw by j
// JVM: public <(Ljava/util/List<Ljava/lang/Object;>;)V> method takesRawList(p0: java.util.List): void
// JVM_IR: public <(Ljava/util/List<+Ljava/lang/Object;>;)V> method takesRawList(p0: java.util.List): void
// FILE: JRaw.java
import java.util.*;
public interface JRaw {
void takesRawList(List list);
List returnsRawList();
void takesRawGenericInv(GenericInv g);
GenericInv returnsRawGenericInv();
void takesRawGenericIn(GenericIn g);
GenericIn returnsRawGenericIn();
void takesRawGenericOut(GenericOut g);
GenericOut returnsRawGenericOut();
}
@@ -0,0 +1,40 @@
@kotlin.Metadata
public final class<<T:Ljava/lang/Number;>Ljava/lang/Object;> GenericIn {
// source: 'rawTypeInSignature.kt'
public <null> method <init>(): void
}
@kotlin.Metadata
public final class<<T:Ljava/lang/Number;>Ljava/lang/Object;> GenericInv {
// source: 'rawTypeInSignature.kt'
public <null> method <init>(): void
}
@kotlin.Metadata
public final class<<T:Ljava/lang/Number;>Ljava/lang/Object;> GenericOut {
// source: 'rawTypeInSignature.kt'
public <null> method <init>(): void
}
@kotlin.Metadata
public final class<null> KRaw {
// source: 'rawTypeInSignature.kt'
public <()LGenericIn<Ljava/lang/Number;>;> method returnsRawGenericIn(): GenericIn
public <()LGenericInv<Ljava/lang/Number;>;> method returnsRawGenericInv(): GenericInv
public <()LGenericOut<Ljava/lang/Number;>;> method returnsRawGenericOut(): GenericOut
public <()Ljava/util/List<Ljava/lang/Object;>;> method returnsRawList(): java.util.List
public <(LGenericIn<-Ljava/lang/Number;>;)V> method takesRawGenericIn(p0: GenericIn): void
public <(LGenericInv<Ljava/lang/Number;>;)V> method takesRawGenericInv(p0: GenericInv): void
public <(LGenericOut<+Ljava/lang/Number;>;)V> method takesRawGenericOut(p0: GenericOut): void
public <(Ljava/util/List<Ljava/lang/Object;>;)V> method takesRawList(p0: java.util.List): void
public <null> method <init>(@org.jetbrains.annotations.NotNull p0: JRaw): void
private synthetic final field <null> $$delegate_0: JRaw
}
@kotlin.Metadata
public final class<null> RawTypeInSignatureKt {
// source: 'rawTypeInSignature.kt'
public final static <(LJRaw;)LGenericIn<Ljava/lang/Number;>;> method testReturnsRawGenericIn(@org.jetbrains.annotations.NotNull p0: JRaw): GenericIn
public final static <(LJRaw;)LGenericInv<Ljava/lang/Number;>;> method testReturnsRawGenericInv(@org.jetbrains.annotations.NotNull p0: JRaw): GenericInv
public final static <(LJRaw;)LGenericOut<Ljava/lang/Number;>;> method testReturnsRawGenericOut(@org.jetbrains.annotations.NotNull p0: JRaw): GenericOut
}
@@ -0,0 +1,40 @@
@kotlin.Metadata
public final class<<T:Ljava/lang/Number;>Ljava/lang/Object;> GenericIn {
// source: 'rawTypeInSignature.kt'
public <null> method <init>(): void
}
@kotlin.Metadata
public final class<<T:Ljava/lang/Number;>Ljava/lang/Object;> GenericInv {
// source: 'rawTypeInSignature.kt'
public <null> method <init>(): void
}
@kotlin.Metadata
public final class<<T:Ljava/lang/Number;>Ljava/lang/Object;> GenericOut {
// source: 'rawTypeInSignature.kt'
public <null> method <init>(): void
}
@kotlin.Metadata
public final class<null> KRaw {
// source: 'rawTypeInSignature.kt'
public <()LGenericIn<Ljava/lang/Number;>;> method returnsRawGenericIn(): GenericIn
public <()LGenericInv<Ljava/lang/Number;>;> method returnsRawGenericInv(): GenericInv
public <()LGenericOut<Ljava/lang/Number;>;> method returnsRawGenericOut(): GenericOut
public <()Ljava/util/List<Ljava/lang/Object;>;> method returnsRawList(): java.util.List
public <(LGenericIn<-Ljava/lang/Number;>;)V> method takesRawGenericIn(p0: GenericIn): void
public <(LGenericInv<Ljava/lang/Number;>;)V> method takesRawGenericInv(p0: GenericInv): void
public <(LGenericOut<+Ljava/lang/Number;>;)V> method takesRawGenericOut(p0: GenericOut): void
public <(Ljava/util/List<+Ljava/lang/Object;>;)V> method takesRawList(p0: java.util.List): void
public <null> method <init>(@org.jetbrains.annotations.NotNull p0: JRaw): void
private synthetic final field <null> $$delegate_0: JRaw
}
@kotlin.Metadata
public final class<null> RawTypeInSignatureKt {
// source: 'rawTypeInSignature.kt'
public final static <(LJRaw;)LGenericIn<Ljava/lang/Number;>;> method testReturnsRawGenericIn(@org.jetbrains.annotations.NotNull p0: JRaw): GenericIn
public final static <(LJRaw;)LGenericInv<Ljava/lang/Number;>;> method testReturnsRawGenericInv(@org.jetbrains.annotations.NotNull p0: JRaw): GenericInv
public final static <(LJRaw;)LGenericOut<Ljava/lang/Number;>;> method testReturnsRawGenericOut(@org.jetbrains.annotations.NotNull p0: JRaw): GenericOut
}
@@ -0,0 +1,139 @@
FILE fqName:<root> fileName:/rawTypeInSignature.kt
CLASS CLASS name:GenericInv modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.GenericInv<T of <root>.GenericInv>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Number]
CONSTRUCTOR visibility:public <> () returnType:<root>.GenericInv<T of <root>.GenericInv> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:GenericInv modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:GenericIn modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.GenericIn<T of <root>.GenericIn>
TYPE_PARAMETER name:T index:0 variance:in superTypes:[kotlin.Number]
CONSTRUCTOR visibility:public <> () returnType:<root>.GenericIn<T of <root>.GenericIn> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:GenericIn modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:GenericOut modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.GenericOut<T of <root>.GenericOut>
TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Number]
CONSTRUCTOR visibility:public <> () returnType:<root>.GenericOut<T of <root>.GenericOut> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:GenericOut modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:testReturnsRawGenericInv visibility:public modality:FINAL <> (j:<root>.JRaw) returnType:<root>.GenericInv<*>?
VALUE_PARAMETER name:j index:0 type:<root>.JRaw
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testReturnsRawGenericInv (j: <root>.JRaw): <root>.GenericInv<*>? declared in <root>'
CALL 'public abstract fun returnsRawGenericInv (): <root>.GenericInv<*>? declared in <root>.JRaw' type=<root>.GenericInv<*>? origin=null
$this: GET_VAR 'j: <root>.JRaw declared in <root>.testReturnsRawGenericInv' type=<root>.JRaw origin=null
FUN name:testReturnsRawGenericIn visibility:public modality:FINAL <> (j:<root>.JRaw) returnType:<root>.GenericIn<kotlin.Nothing>?
VALUE_PARAMETER name:j index:0 type:<root>.JRaw
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testReturnsRawGenericIn (j: <root>.JRaw): <root>.GenericIn<kotlin.Nothing>? declared in <root>'
CALL 'public abstract fun returnsRawGenericIn (): <root>.GenericIn<kotlin.Nothing>? declared in <root>.JRaw' type=<root>.GenericIn<kotlin.Nothing>? origin=null
$this: GET_VAR 'j: <root>.JRaw declared in <root>.testReturnsRawGenericIn' type=<root>.JRaw origin=null
FUN name:testReturnsRawGenericOut visibility:public modality:FINAL <> (j:<root>.JRaw) returnType:<root>.GenericOut<*>?
VALUE_PARAMETER name:j index:0 type:<root>.JRaw
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testReturnsRawGenericOut (j: <root>.JRaw): <root>.GenericOut<*>? declared in <root>'
CALL 'public abstract fun returnsRawGenericOut (): <root>.GenericOut<*>? declared in <root>.JRaw' type=<root>.GenericOut<*>? origin=null
$this: GET_VAR 'j: <root>.JRaw declared in <root>.testReturnsRawGenericOut' type=<root>.JRaw origin=null
CLASS CLASS name:KRaw modality:FINAL visibility:public superTypes:[<root>.JRaw]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.KRaw
CONSTRUCTOR visibility:public <> (j:<root>.JRaw) returnType:<root>.KRaw [primary]
VALUE_PARAMETER name:j index:0 type:<root>.JRaw
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:KRaw modality:FINAL visibility:public superTypes:[<root>.JRaw]'
SET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.JRaw visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.KRaw declared in <root>.KRaw' type=<root>.KRaw origin=null
value: GET_VAR 'j: <root>.JRaw declared in <root>.KRaw.<init>' type=<root>.JRaw origin=null
FIELD DELEGATE name:<$$delegate_0> type:<root>.JRaw visibility:local [final]
FUN FAKE_OVERRIDE name:takesRawList visibility:public modality:OPEN <> ($this:<root>.JRaw, list:kotlin.collections.List<*>?) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun takesRawList (list: kotlin.collections.List<*>?): kotlin.Unit declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.JRaw
VALUE_PARAMETER name:list index:0 type:kotlin.collections.List<*>?
FUN FAKE_OVERRIDE name:returnsRawList visibility:public modality:OPEN <> ($this:<root>.JRaw) returnType:kotlin.collections.List<*>? [fake_override]
overridden:
public abstract fun returnsRawList (): kotlin.collections.List<*>? declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.JRaw
FUN FAKE_OVERRIDE name:takesRawGenericInv visibility:public modality:OPEN <> ($this:<root>.JRaw, g:<root>.GenericInv<*>?) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun takesRawGenericInv (g: <root>.GenericInv<*>?): kotlin.Unit declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.JRaw
VALUE_PARAMETER name:g index:0 type:<root>.GenericInv<*>?
FUN FAKE_OVERRIDE name:returnsRawGenericInv visibility:public modality:OPEN <> ($this:<root>.JRaw) returnType:<root>.GenericInv<*>? [fake_override]
overridden:
public abstract fun returnsRawGenericInv (): <root>.GenericInv<*>? declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.JRaw
FUN FAKE_OVERRIDE name:takesRawGenericIn visibility:public modality:OPEN <> ($this:<root>.JRaw, g:<root>.GenericIn<kotlin.Nothing>?) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun takesRawGenericIn (g: <root>.GenericIn<kotlin.Nothing>?): kotlin.Unit declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.JRaw
VALUE_PARAMETER name:g index:0 type:<root>.GenericIn<kotlin.Nothing>?
FUN FAKE_OVERRIDE name:returnsRawGenericIn visibility:public modality:OPEN <> ($this:<root>.JRaw) returnType:<root>.GenericIn<kotlin.Nothing>? [fake_override]
overridden:
public abstract fun returnsRawGenericIn (): <root>.GenericIn<kotlin.Nothing>? declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.JRaw
FUN FAKE_OVERRIDE name:takesRawGenericOut visibility:public modality:OPEN <> ($this:<root>.JRaw, g:<root>.GenericOut<*>?) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun takesRawGenericOut (g: <root>.GenericOut<*>?): kotlin.Unit declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.JRaw
VALUE_PARAMETER name:g index:0 type:<root>.GenericOut<*>?
FUN FAKE_OVERRIDE name:returnsRawGenericOut visibility:public modality:OPEN <> ($this:<root>.JRaw) returnType:<root>.GenericOut<*>? [fake_override]
overridden:
public abstract fun returnsRawGenericOut (): <root>.GenericOut<*>? declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.JRaw
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
+28
View File
@@ -0,0 +1,28 @@
// FILE: rawTypeInSignature.kt
class GenericInv<T : Number>
class GenericIn<in T : Number>
class GenericOut<out T : Number>
fun testReturnsRawGenericInv(j: JRaw) = j.returnsRawGenericInv()
fun testReturnsRawGenericIn(j: JRaw) = j.returnsRawGenericIn()
fun testReturnsRawGenericOut(j: JRaw) = j.returnsRawGenericOut()
class KRaw(j: JRaw) : JRaw by j
// FILE: JRaw.java
import java.util.*;
public interface JRaw {
void takesRawList(List list);
List returnsRawList();
void takesRawGenericInv(GenericInv g);
GenericInv returnsRawGenericInv();
void takesRawGenericIn(GenericIn g);
GenericIn returnsRawGenericIn();
void takesRawGenericOut(GenericOut g);
GenericOut returnsRawGenericOut();
}
+178
View File
@@ -0,0 +1,178 @@
FILE fqName:<root> fileName:/rawTypeInSignature.kt
CLASS CLASS name:GenericInv modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.GenericInv<T of <root>.GenericInv>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Number]
CONSTRUCTOR visibility:public <> () returnType:<root>.GenericInv<T of <root>.GenericInv> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:GenericInv modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:GenericIn modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.GenericIn<T of <root>.GenericIn>
TYPE_PARAMETER name:T index:0 variance:in superTypes:[kotlin.Number]
CONSTRUCTOR visibility:public <> () returnType:<root>.GenericIn<T of <root>.GenericIn> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:GenericIn modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:GenericOut modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.GenericOut<T of <root>.GenericOut>
TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Number]
CONSTRUCTOR visibility:public <> () returnType:<root>.GenericOut<T of <root>.GenericOut> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:GenericOut modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:testReturnsRawGenericInv visibility:public modality:FINAL <> (j:<root>.JRaw) returnType:@[FlexibleNullability] <root>.GenericInv<kotlin.Number>?
VALUE_PARAMETER name:j index:0 type:<root>.JRaw
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testReturnsRawGenericInv (j: <root>.JRaw): @[FlexibleNullability] <root>.GenericInv<kotlin.Number>? declared in <root>'
CALL 'public abstract fun returnsRawGenericInv (): @[FlexibleNullability] <root>.GenericInv<kotlin.Number>? declared in <root>.JRaw' type=@[FlexibleNullability] <root>.GenericInv<kotlin.Number>? origin=null
$this: GET_VAR 'j: <root>.JRaw declared in <root>.testReturnsRawGenericInv' type=<root>.JRaw origin=null
FUN name:testReturnsRawGenericIn visibility:public modality:FINAL <> (j:<root>.JRaw) returnType:@[FlexibleNullability] <root>.GenericIn<kotlin.Number>?
VALUE_PARAMETER name:j index:0 type:<root>.JRaw
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testReturnsRawGenericIn (j: <root>.JRaw): @[FlexibleNullability] <root>.GenericIn<kotlin.Number>? declared in <root>'
CALL 'public abstract fun returnsRawGenericIn (): @[FlexibleNullability] <root>.GenericIn<kotlin.Number>? declared in <root>.JRaw' type=@[FlexibleNullability] <root>.GenericIn<kotlin.Number>? origin=null
$this: GET_VAR 'j: <root>.JRaw declared in <root>.testReturnsRawGenericIn' type=<root>.JRaw origin=null
FUN name:testReturnsRawGenericOut visibility:public modality:FINAL <> (j:<root>.JRaw) returnType:@[FlexibleNullability] <root>.GenericOut<kotlin.Number>?
VALUE_PARAMETER name:j index:0 type:<root>.JRaw
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testReturnsRawGenericOut (j: <root>.JRaw): @[FlexibleNullability] <root>.GenericOut<kotlin.Number>? declared in <root>'
CALL 'public abstract fun returnsRawGenericOut (): @[FlexibleNullability] <root>.GenericOut<kotlin.Number>? declared in <root>.JRaw' type=@[FlexibleNullability] <root>.GenericOut<kotlin.Number>? origin=null
$this: GET_VAR 'j: <root>.JRaw declared in <root>.testReturnsRawGenericOut' type=<root>.JRaw origin=null
CLASS CLASS name:KRaw modality:FINAL visibility:public superTypes:[<root>.JRaw]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.KRaw
CONSTRUCTOR visibility:public <> (j:<root>.JRaw) returnType:<root>.KRaw [primary]
VALUE_PARAMETER name:j index:0 type:<root>.JRaw
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:KRaw modality:FINAL visibility:public superTypes:[<root>.JRaw]'
FIELD DELEGATE name:$$delegate_0 type:<root>.JRaw visibility:private [final]
EXPRESSION_BODY
GET_VAR 'j: <root>.JRaw declared in <root>.KRaw.<init>' type=<root>.JRaw origin=null
FUN DELEGATED_MEMBER name:returnsRawGenericIn visibility:public modality:OPEN <> ($this:<root>.KRaw) returnType:@[FlexibleNullability] <root>.GenericIn<kotlin.Number>?
overridden:
public abstract fun returnsRawGenericIn (): @[FlexibleNullability] <root>.GenericIn<kotlin.Number>? declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.KRaw
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun returnsRawGenericIn (): @[FlexibleNullability] <root>.GenericIn<kotlin.Number>? declared in <root>.KRaw'
CALL 'public abstract fun returnsRawGenericIn (): @[FlexibleNullability] <root>.GenericIn<kotlin.Number>? declared in <root>.JRaw' type=@[FlexibleNullability] <root>.GenericIn<kotlin.Number>? origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.JRaw visibility:private [final]' type=<root>.JRaw origin=null
receiver: GET_VAR '<this>: <root>.KRaw declared in <root>.KRaw.returnsRawGenericIn' type=<root>.KRaw origin=null
FUN DELEGATED_MEMBER name:returnsRawGenericInv visibility:public modality:OPEN <> ($this:<root>.KRaw) returnType:@[FlexibleNullability] <root>.GenericInv<kotlin.Number>?
overridden:
public abstract fun returnsRawGenericInv (): @[FlexibleNullability] <root>.GenericInv<kotlin.Number>? declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.KRaw
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun returnsRawGenericInv (): @[FlexibleNullability] <root>.GenericInv<kotlin.Number>? declared in <root>.KRaw'
CALL 'public abstract fun returnsRawGenericInv (): @[FlexibleNullability] <root>.GenericInv<kotlin.Number>? declared in <root>.JRaw' type=@[FlexibleNullability] <root>.GenericInv<kotlin.Number>? origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.JRaw visibility:private [final]' type=<root>.JRaw origin=null
receiver: GET_VAR '<this>: <root>.KRaw declared in <root>.KRaw.returnsRawGenericInv' type=<root>.KRaw origin=null
FUN DELEGATED_MEMBER name:returnsRawGenericOut visibility:public modality:OPEN <> ($this:<root>.KRaw) returnType:@[FlexibleNullability] <root>.GenericOut<kotlin.Number>?
overridden:
public abstract fun returnsRawGenericOut (): @[FlexibleNullability] <root>.GenericOut<kotlin.Number>? declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.KRaw
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun returnsRawGenericOut (): @[FlexibleNullability] <root>.GenericOut<kotlin.Number>? declared in <root>.KRaw'
CALL 'public abstract fun returnsRawGenericOut (): @[FlexibleNullability] <root>.GenericOut<kotlin.Number>? declared in <root>.JRaw' type=@[FlexibleNullability] <root>.GenericOut<kotlin.Number>? origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.JRaw visibility:private [final]' type=<root>.JRaw origin=null
receiver: GET_VAR '<this>: <root>.KRaw declared in <root>.KRaw.returnsRawGenericOut' type=<root>.KRaw origin=null
FUN DELEGATED_MEMBER name:returnsRawList visibility:public modality:OPEN <> ($this:<root>.KRaw) returnType:@[FlexibleNullability] kotlin.collections.List<kotlin.Any?>?
overridden:
public abstract fun returnsRawList (): @[FlexibleNullability] kotlin.collections.List<kotlin.Any?>? declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.KRaw
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun returnsRawList (): @[FlexibleNullability] kotlin.collections.List<kotlin.Any?>? declared in <root>.KRaw'
CALL 'public abstract fun returnsRawList (): @[FlexibleNullability] kotlin.collections.List<kotlin.Any?>? declared in <root>.JRaw' type=@[FlexibleNullability] kotlin.collections.List<kotlin.Any?>? origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.JRaw visibility:private [final]' type=<root>.JRaw origin=null
receiver: GET_VAR '<this>: <root>.KRaw declared in <root>.KRaw.returnsRawList' type=<root>.KRaw origin=null
FUN DELEGATED_MEMBER name:takesRawGenericIn visibility:public modality:OPEN <> ($this:<root>.KRaw, g:@[FlexibleNullability] <root>.GenericIn<kotlin.Number>?) returnType:kotlin.Unit
overridden:
public abstract fun takesRawGenericIn (g: @[FlexibleNullability] <root>.GenericIn<kotlin.Number>?): kotlin.Unit declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.KRaw
VALUE_PARAMETER name:g index:0 type:@[FlexibleNullability] <root>.GenericIn<kotlin.Number>?
BLOCK_BODY
CALL 'public abstract fun takesRawGenericIn (g: @[FlexibleNullability] <root>.GenericIn<kotlin.Number>?): kotlin.Unit declared in <root>.JRaw' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.JRaw visibility:private [final]' type=<root>.JRaw origin=null
receiver: GET_VAR '<this>: <root>.KRaw declared in <root>.KRaw.takesRawGenericIn' type=<root>.KRaw origin=null
g: GET_VAR 'g: @[FlexibleNullability] <root>.GenericIn<kotlin.Number>? declared in <root>.KRaw.takesRawGenericIn' type=@[FlexibleNullability] <root>.GenericIn<kotlin.Number>? origin=null
FUN DELEGATED_MEMBER name:takesRawGenericInv visibility:public modality:OPEN <> ($this:<root>.KRaw, g:@[FlexibleNullability] <root>.GenericInv<kotlin.Number>?) returnType:kotlin.Unit
overridden:
public abstract fun takesRawGenericInv (g: @[FlexibleNullability] <root>.GenericInv<kotlin.Number>?): kotlin.Unit declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.KRaw
VALUE_PARAMETER name:g index:0 type:@[FlexibleNullability] <root>.GenericInv<kotlin.Number>?
BLOCK_BODY
CALL 'public abstract fun takesRawGenericInv (g: @[FlexibleNullability] <root>.GenericInv<kotlin.Number>?): kotlin.Unit declared in <root>.JRaw' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.JRaw visibility:private [final]' type=<root>.JRaw origin=null
receiver: GET_VAR '<this>: <root>.KRaw declared in <root>.KRaw.takesRawGenericInv' type=<root>.KRaw origin=null
g: GET_VAR 'g: @[FlexibleNullability] <root>.GenericInv<kotlin.Number>? declared in <root>.KRaw.takesRawGenericInv' type=@[FlexibleNullability] <root>.GenericInv<kotlin.Number>? origin=null
FUN DELEGATED_MEMBER name:takesRawGenericOut visibility:public modality:OPEN <> ($this:<root>.KRaw, g:@[FlexibleNullability] <root>.GenericOut<kotlin.Number>?) returnType:kotlin.Unit
overridden:
public abstract fun takesRawGenericOut (g: @[FlexibleNullability] <root>.GenericOut<kotlin.Number>?): kotlin.Unit declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.KRaw
VALUE_PARAMETER name:g index:0 type:@[FlexibleNullability] <root>.GenericOut<kotlin.Number>?
BLOCK_BODY
CALL 'public abstract fun takesRawGenericOut (g: @[FlexibleNullability] <root>.GenericOut<kotlin.Number>?): kotlin.Unit declared in <root>.JRaw' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.JRaw visibility:private [final]' type=<root>.JRaw origin=null
receiver: GET_VAR '<this>: <root>.KRaw declared in <root>.KRaw.takesRawGenericOut' type=<root>.KRaw origin=null
g: GET_VAR 'g: @[FlexibleNullability] <root>.GenericOut<kotlin.Number>? declared in <root>.KRaw.takesRawGenericOut' type=@[FlexibleNullability] <root>.GenericOut<kotlin.Number>? origin=null
FUN DELEGATED_MEMBER name:takesRawList visibility:public modality:OPEN <> ($this:<root>.KRaw, list:@[FlexibleNullability] kotlin.collections.List<kotlin.Any?>?) returnType:kotlin.Unit
overridden:
public abstract fun takesRawList (list: @[FlexibleNullability] kotlin.collections.List<kotlin.Any?>?): kotlin.Unit declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:<root>.KRaw
VALUE_PARAMETER name:list index:0 type:@[FlexibleNullability] kotlin.collections.List<kotlin.Any?>?
BLOCK_BODY
CALL 'public abstract fun takesRawList (list: @[FlexibleNullability] kotlin.collections.List<kotlin.Any?>?): kotlin.Unit declared in <root>.JRaw' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.JRaw visibility:private [final]' type=<root>.JRaw origin=null
receiver: GET_VAR '<this>: <root>.KRaw declared in <root>.KRaw.takesRawList' type=<root>.KRaw origin=null
list: GET_VAR 'list: @[FlexibleNullability] kotlin.collections.List<kotlin.Any?>? declared in <root>.KRaw.takesRawList' type=@[FlexibleNullability] kotlin.collections.List<kotlin.Any?>? origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.JRaw
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
@@ -149,6 +149,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
runTest("compiler/testData/codegen/bytecodeListing/privateNestedClassInInterface.kt");
}
@TestMetadata("rawTypeInSignature.kt")
public void testRawTypeInSignature() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/rawTypeInSignature.kt");
}
@TestMetadata("samAdapterAndInlinedOne.kt")
public void testSamAdapterAndInlinedOne() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne.kt");
@@ -149,6 +149,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
runTest("compiler/testData/codegen/bytecodeListing/privateNestedClassInInterface.kt");
}
@TestMetadata("rawTypeInSignature.kt")
public void testRawTypeInSignature() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/rawTypeInSignature.kt");
}
@TestMetadata("samAdapterAndInlinedOne.kt")
public void testSamAdapterAndInlinedOne() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne.kt");
@@ -2039,6 +2039,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
runTest("compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.kt");
}
@TestMetadata("rawTypeInSignature.kt")
public void testRawTypeInSignature() throws Exception {
runTest("compiler/testData/ir/irText/types/rawTypeInSignature.kt");
}
@TestMetadata("receiverOfIntersectionType.kt")
public void testReceiverOfIntersectionType() throws Exception {
runTest("compiler/testData/ir/irText/types/receiverOfIntersectionType.kt");