Skip to content

Commit

Permalink
Skip over synthetic type parameters from outer class
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Sep 10, 2023
1 parent ba19d83 commit 8b210b7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3965,7 +3965,7 @@ class KotlinParserVisitor(
val before = sourceBefore("<")
val typeParameters: MutableList<JRightPadded<J.TypeParameter?>> =
ArrayList(regularClass.typeParameters.size)
val parameters = regularClass.typeParameters
val parameters = regularClass.typeParameters.filter { it.source != null }
for (i in parameters.indices) {
val j: J = visitElement(parameters[i], data)!!
typeParameters.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,12 @@ void explicitInlineConstructor() {
@Test
void implicitConstructorWithSuperType() {
rewriteRun(
kotlin("class Other"),
kotlin("class Test ( val answer : Int ) : Other ( ) { }")
kotlin(
"""
open class Other
class Test constructor ( val answer : Int ) : Other ( ) { }
"""
)
);
}

Expand Down Expand Up @@ -416,7 +420,7 @@ abstract class BaseSubProjectionNode < T , R > (
val root : R
) {
constructor ( parent : T , root : R ) : this ( parent , root )
constructor ( parent : T , root : R , id : Int ) : this ( parent , root )
fun parent ( ) : T {
return parent
Expand Down Expand Up @@ -454,10 +458,7 @@ void mixedAnnotationsAndModifiers() {
"""
@Repeatable
annotation class A ( val s : String )
"""
),
kotlin(
"""
open @A ( "1" ) public @A ( "2" ) class TestA
@A ( "1" ) open @A ( "2" ) public class TestB
"""
Expand Down Expand Up @@ -564,4 +565,19 @@ void coneProjection() {
)
);
}

@Test
void outerClassTypeParameters() {
rewriteRun(
kotlin(
"""
class Test<K, V> {
abstract inner class LinkedTreeMapIterator<T> : MutableIterator<T> {
var lastReturned: Map.Entry<K, V>? = null
}
}
"""
)
);
}
}

0 comments on commit 8b210b7

Please sign in to comment.