Fix psi2ir when type parameter bound goes after the type parameter
This commit is contained in:
+8
-4
@@ -108,7 +108,7 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator {
|
|||||||
from: List<TypeParameterDescriptor>,
|
from: List<TypeParameterDescriptor>,
|
||||||
declareTypeParameter: (Int, Int, TypeParameterDescriptor) -> IrTypeParameter
|
declareTypeParameter: (Int, Int, TypeParameterDescriptor) -> IrTypeParameter
|
||||||
) {
|
) {
|
||||||
from.mapTo(irTypeParametersOwner.typeParameters) { typeParameterDescriptor ->
|
val irTypeParameters = from.map { typeParameterDescriptor ->
|
||||||
val ktTypeParameterDeclaration = DescriptorToSourceUtils.getSourceFromDescriptor(typeParameterDescriptor)
|
val ktTypeParameterDeclaration = DescriptorToSourceUtils.getSourceFromDescriptor(typeParameterDescriptor)
|
||||||
val startOffset = ktTypeParameterDeclaration.startOffsetOrUndefined
|
val startOffset = ktTypeParameterDeclaration.startOffsetOrUndefined
|
||||||
val endOffset = ktTypeParameterDeclaration.endOffsetOrUndefined
|
val endOffset = ktTypeParameterDeclaration.endOffsetOrUndefined
|
||||||
@@ -116,10 +116,14 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator {
|
|||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
typeParameterDescriptor
|
typeParameterDescriptor
|
||||||
).also { irTypeParameter ->
|
)
|
||||||
mapSuperClassifiers(typeParameterDescriptor, irTypeParameter)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
irTypeParameters.forEach {
|
||||||
|
mapSuperClassifiers(it.descriptor, it)
|
||||||
|
}
|
||||||
|
|
||||||
|
irTypeParametersOwner.typeParameters.addAll(irTypeParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mapSuperClassifiers(
|
private fun mapSuperClassifiers(
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
class Test1<T : U, U>
|
||||||
|
|
||||||
|
fun <T : U, U> test2() {}
|
||||||
|
|
||||||
|
var <T : U, U> Test1<T, U>.test3: Unit
|
||||||
|
get() {}
|
||||||
|
set(value) {}
|
||||||
+56
@@ -0,0 +1,56 @@
|
|||||||
|
FILE fqName:<root> fileName:/typeParameterBeforeBound.kt
|
||||||
|
CLASS CLASS name:Test1 modality:FINAL visibility:public flags:
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:Test1<T, U> flags:
|
||||||
|
superClasses:
|
||||||
|
CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags:
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: upperBounds:[U]
|
||||||
|
superClassifiers:
|
||||||
|
TYPE_PARAMETER name:U index:1 variance: upperBounds:[kotlin.Any?]
|
||||||
|
TYPE_PARAMETER name:U index:1 variance: upperBounds:[kotlin.Any?]
|
||||||
|
superClassifiers:
|
||||||
|
CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags:
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:Test1<T, U> flags:
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'constructor Any()'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='Test1'
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags:
|
||||||
|
overridden:
|
||||||
|
FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags:
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags:
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags:
|
||||||
|
overridden:
|
||||||
|
FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags:
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags:
|
||||||
|
overridden:
|
||||||
|
FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags:
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||||
|
FUN name:test2 visibility:public modality:FINAL <T, U> () returnType:Unit flags:
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: upperBounds:[U]
|
||||||
|
superClassifiers:
|
||||||
|
TYPE_PARAMETER name:U index:1 variance: upperBounds:[kotlin.Any?]
|
||||||
|
TYPE_PARAMETER name:U index:1 variance: upperBounds:[kotlin.Any?]
|
||||||
|
superClassifiers:
|
||||||
|
CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags:
|
||||||
|
BLOCK_BODY
|
||||||
|
PROPERTY name:test3 type:kotlin.Unit visibility:public modality:FINAL flags:var
|
||||||
|
FUN name:<get-test3> visibility:public modality:FINAL <T, U> ($receiver:Test1<T, U>) returnType:Unit flags:
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: upperBounds:[U]
|
||||||
|
superClassifiers:
|
||||||
|
TYPE_PARAMETER name:U index:1 variance: upperBounds:[kotlin.Any?]
|
||||||
|
TYPE_PARAMETER name:U index:1 variance: upperBounds:[kotlin.Any?]
|
||||||
|
superClassifiers:
|
||||||
|
CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags:
|
||||||
|
$receiver: VALUE_PARAMETER name:<this> type:Test1<T, U> flags:
|
||||||
|
BLOCK_BODY
|
||||||
|
FUN name:<set-test3> visibility:public modality:FINAL <T, U> ($receiver:Test1<T, U>, value:kotlin.Unit) returnType:Unit flags:
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: upperBounds:[U]
|
||||||
|
superClassifiers:
|
||||||
|
TYPE_PARAMETER name:U index:1 variance: upperBounds:[kotlin.Any?]
|
||||||
|
TYPE_PARAMETER name:U index:1 variance: upperBounds:[kotlin.Any?]
|
||||||
|
superClassifiers:
|
||||||
|
CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags:
|
||||||
|
$receiver: VALUE_PARAMETER name:<this> type:Test1<T, U> flags:
|
||||||
|
VALUE_PARAMETER name:value index:0 type:kotlin.Unit flags:
|
||||||
|
BLOCK_BODY
|
||||||
@@ -418,6 +418,12 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/parameters/propertyAccessors.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/parameters/propertyAccessors.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeParameterBeforeBound.kt")
|
||||||
|
public void testTypeParameterBeforeBound() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/ir/irText/declarations/provideDelegate")
|
@TestMetadata("compiler/testData/ir/irText/declarations/provideDelegate")
|
||||||
|
|||||||
Reference in New Issue
Block a user