Fix type parameters indexes of MockClassDescriptor

Exception was thrown during mapping of arguments to parameters in `computeSupertypeProjections`

 #KT-18522 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2018-02-09 19:12:45 +03:00
parent 310ee67c35
commit 9e22761262
6 changed files with 39 additions and 14 deletions
@@ -0,0 +1,3 @@
package a
interface A<T>
@@ -0,0 +1,8 @@
package b
import a.A
interface B {
fun foo(): A<Int>
fun bar(): A<String>
}
@@ -0,0 +1,10 @@
compiler/testData/compileKotlinAgainstCustomBinaries/computeSupertypeWithMissingDependency/source.kt:6:5: error: cannot access class 'a.A'. Check your module classpath for missing or conflicting dependencies
if (true) {
^
compiler/testData/compileKotlinAgainstCustomBinaries/computeSupertypeWithMissingDependency/source.kt:7:11: error: cannot access class 'a.A'. Check your module classpath for missing or conflicting dependencies
b.foo()
^
compiler/testData/compileKotlinAgainstCustomBinaries/computeSupertypeWithMissingDependency/source.kt:9:11: error: cannot access class 'a.A'. Check your module classpath for missing or conflicting dependencies
b.bar()
^
COMPILATION_ERROR
@@ -0,0 +1,11 @@
package c
import b.B
fun bar(b: B) {
if (true) {
b.foo()
} else {
b.bar()
}
}
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.compiler
@@ -214,6 +203,10 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
doTestBrokenLibrary("library", "a/A.class")
}
fun testComputeSupertypeWithMissingDependency() {
doTestBrokenLibrary("library", "a/A.class")
}
fun testMissingDependencyDifferentCases() {
doTestBrokenLibrary("library", "a/A.class")
}
@@ -50,7 +50,7 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
private val isInner: Boolean,
numberOfDeclaredTypeParameters: Int
) : ClassDescriptorBase(storageManager, container, name, SourceElement.NO_SOURCE, /* isExternal = */ false) {
private val typeParameters = (1..numberOfDeclaredTypeParameters).map { index ->
private val typeParameters = (0 until numberOfDeclaredTypeParameters).map { index ->
TypeParameterDescriptorImpl.createWithDefaultBound(
this, Annotations.EMPTY, false, Variance.INVARIANT, Name.identifier("T$index"), index
)