From db11c14fee84abd5d92234f16f909fc95f2f8a2e Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 11 Nov 2019 14:05:58 +0300 Subject: [PATCH] FIR Java: don't add type parameter bounds multiple times --- .../src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt | 4 +++- .../testData/loadJava/compiledJava/ClassWithTypePP.fir.txt | 4 ++-- .../loadJava/compiledJava/ClassWithTypePRefNext.fir.txt | 4 ++-- .../loadJava/compiledJava/ClassWithTypePRefSelf.fir.txt | 4 ++-- .../compiledJava/ClassWithTypePRefSelfAndClass.fir.txt | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt index 012242ef464..3e6a7d9b28c 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt @@ -146,7 +146,9 @@ class JavaSymbolProvider( .map { it.toFirTypeParameter(stack) } .also { it.forEachIndexed { index, typeParameter -> - typeParameter.addBounds(this[index], stack) + if (typeParameter.bounds.isEmpty()) { + typeParameter.addBounds(this[index], stack) + } } } } diff --git a/compiler/testData/loadJava/compiledJava/ClassWithTypePP.fir.txt b/compiler/testData/loadJava/compiledJava/ClassWithTypePP.fir.txt index 53be87bc02c..ae67ea3b7ef 100644 --- a/compiler/testData/loadJava/compiledJava/ClassWithTypePP.fir.txt +++ b/compiler/testData/loadJava/compiledJava/ClassWithTypePP.fir.txt @@ -1,4 +1,4 @@ -public final class ClassWithTypePP : R|kotlin/Any| { - public constructor(): R|test/ClassWithTypePP| +public final class ClassWithTypePP : R|kotlin/Any| { + public constructor(): R|test/ClassWithTypePP| } diff --git a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefNext.fir.txt b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefNext.fir.txt index 95e6d10b368..e36bdb46e5a 100644 --- a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefNext.fir.txt +++ b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefNext.fir.txt @@ -1,4 +1,4 @@ -public open class ClassWithTypePRefNext|, R|kotlin/collections/MutableIterable

|, P> : R|kotlin/Any| { - public constructor|, R|kotlin/collections/MutableIterable

|, P>(): R|test/ClassWithTypePRefNext| +public open class ClassWithTypePRefNext|, P> : R|kotlin/Any| { + public constructor|, P>(): R|test/ClassWithTypePRefNext| } diff --git a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelf.fir.txt b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelf.fir.txt index 989ed3dfb57..af1f1138354 100644 --- a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelf.fir.txt +++ b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelf.fir.txt @@ -1,4 +1,4 @@ -public final class ClassWithTypePRefSelf

|, R|kotlin/Enum

|> : R|kotlin/Any| { - public constructor

|, R|kotlin/Enum

|>(): R|test/ClassWithTypePRefSelf

| +public final class ClassWithTypePRefSelf

|> : R|kotlin/Any| { + public constructor

|>(): R|test/ClassWithTypePRefSelf

| } diff --git a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelfAndClass.fir.txt b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelfAndClass.fir.txt index 1d762fca539..46cb7f3a7d5 100644 --- a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelfAndClass.fir.txt +++ b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelfAndClass.fir.txt @@ -1,4 +1,4 @@ -public final class ClassWithTypePRefSelfAndClass

|, R|test/ClassWithTypePRefSelfAndClass

|> : R|kotlin/Any| { - public constructor

|, R|test/ClassWithTypePRefSelfAndClass

|>(): R|test/ClassWithTypePRefSelfAndClass

| +public final class ClassWithTypePRefSelfAndClass

|> : R|kotlin/Any| { + public constructor

|>(): R|test/ClassWithTypePRefSelfAndClass

| }