Fix incremental compilation problems related to type alias constructors
1. Determine source element for descriptors with NO_SOURCE recursively. 2. Always provide type abbreviation for type alias constructor return type. #KT-15495 Fixed
This commit is contained in:
+7
-8
@@ -79,14 +79,13 @@ fun isContainedByCompiledPartOfOurModule(descriptor: DeclarationDescriptor, outD
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getSourceElement(descriptor: DeclarationDescriptor): SourceElement =
|
fun getSourceElement(descriptor: DeclarationDescriptor): SourceElement =
|
||||||
if (descriptor is CallableMemberDescriptor && descriptor.source === SourceElement.NO_SOURCE) {
|
when {
|
||||||
descriptor.containingDeclaration.toSourceElement
|
descriptor is CallableMemberDescriptor && descriptor.source === SourceElement.NO_SOURCE ->
|
||||||
}
|
getSourceElement(descriptor.containingDeclaration)
|
||||||
else if (descriptor is DeserializedTypeAliasDescriptor) {
|
descriptor is DeserializedTypeAliasDescriptor ->
|
||||||
descriptor.containingDeclaration.toSourceElement
|
getSourceElement(descriptor.containingDeclaration)
|
||||||
}
|
else ->
|
||||||
else {
|
descriptor.toSourceElement
|
||||||
descriptor.toSourceElement
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val DeclarationDescriptor.toSourceElement: SourceElement
|
private val DeclarationDescriptor.toSourceElement: SourceElement
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
public val test2: Base
|
public val test2: Obsolete /* = Base */
|
||||||
public val test3: Base.Companion
|
public val test3: Base.Companion
|
||||||
public fun test1(/*0*/ x: Obsolete /* = Base */): Obsolete /* = Base */
|
public fun test1(/*0*/ x: Obsolete /* = Base */): Obsolete /* = Base */
|
||||||
public fun test1a(/*0*/ x: kotlin.collections.List<Obsolete /* = Base */>): kotlin.collections.List<Obsolete /* = Base */>
|
public fun test1a(/*0*/ x: kotlin.collections.List<Obsolete /* = Base */>): kotlin.collections.List<Obsolete /* = Base */>
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
public val test1: [ERROR : Type for C1_Alias()]
|
public val test1: [ERROR : Type for C1_Alias()]
|
||||||
public val test2: C2
|
public val test2: C2_Alias /* = C2 */
|
||||||
|
|
||||||
@kotlin.SinceKotlin(version = "1.1") public open class C1 {
|
@kotlin.SinceKotlin(version = "1.1") public open class C1 {
|
||||||
public constructor C1()
|
public constructor C1()
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
public fun test1(/*0*/ x: Outer): Outer.Inner
|
public fun test1(/*0*/ x: Outer): OI /* = Outer.Inner */
|
||||||
public fun test2(/*0*/ x: Generic<kotlin.Int>): GI<kotlin.Int> /* = Generic<kotlin.Int>.Inner */
|
public fun test2(/*0*/ x: Generic<kotlin.Int>): GI<kotlin.Int> /* = Generic<kotlin.Int>.Inner */
|
||||||
public fun </*0*/ T> test3(/*0*/ x: Generic<T>): GI<T> /* = Generic<T>.Inner */
|
public fun </*0*/ T> test3(/*0*/ x: Generic<T>): GI<T> /* = Generic<T>.Inner */
|
||||||
public fun </*0*/ T> test4(/*0*/ x: Generic<kotlin.collections.List<T>>): GI<kotlin.collections.List<T>> /* = Generic<kotlin.collections.List<T>>.Inner */
|
public fun </*0*/ T> test4(/*0*/ x: Generic<kotlin.collections.List<T>>): GI<kotlin.collections.List<T>> /* = Generic<kotlin.collections.List<T>>.Inner */
|
||||||
|
|||||||
+5
-5
@@ -1,19 +1,19 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
public val test1: AbstractClass
|
public val test1: Test1 /* = AbstractClass */
|
||||||
public val test1a: AbstractClass
|
public val test1a: AbstractClass
|
||||||
public val test2: AnnotationClass
|
public val test2: Test2 /* = AnnotationClass */
|
||||||
public val test2a: AnnotationClass
|
public val test2a: AnnotationClass
|
||||||
public val test3: EnumClass
|
public val test3: Test3 /* = EnumClass */
|
||||||
public val test3a: EnumClass
|
public val test3a: EnumClass
|
||||||
public val test4: SealedClass
|
public val test4: Test4 /* = SealedClass */
|
||||||
public val test4a: SealedClass
|
public val test4a: SealedClass
|
||||||
public val test5: [ERROR : Type for Test5()]
|
public val test5: [ERROR : Type for Test5()]
|
||||||
public val test5a: [ERROR : Type for Outer.Inner()]
|
public val test5a: [ERROR : Type for Outer.Inner()]
|
||||||
public val test5b: [ERROR : Type for Outer.TestInner()]
|
public val test5b: [ERROR : Type for Outer.TestInner()]
|
||||||
public val test5c: [ERROR : Type for Outer().TestInner()]
|
public val test5c: [ERROR : Type for Outer().TestInner()]
|
||||||
public val test5d: Outer.Inner
|
public val test5d: Outer.Inner
|
||||||
public val test5e: Outer.Inner
|
public val test5e: Test5 /* = Outer.Inner */
|
||||||
|
|
||||||
public abstract class AbstractClass {
|
public abstract class AbstractClass {
|
||||||
public constructor AbstractClass()
|
public constructor AbstractClass()
|
||||||
|
|||||||
+3
-3
@@ -4,7 +4,7 @@ public val test1: [ERROR : Type for MyAlias(1)]
|
|||||||
public val test1a: [ERROR : Type for MyClass(1)]
|
public val test1a: [ERROR : Type for MyClass(1)]
|
||||||
public val test2: [ERROR : Type for MyAlias("")]
|
public val test2: [ERROR : Type for MyAlias("")]
|
||||||
public val test2a: [ERROR : Type for MyClass("")]
|
public val test2a: [ERROR : Type for MyClass("")]
|
||||||
public val test3: MyClass
|
public val test3: MyAlias /* = MyClass */
|
||||||
public val test3a: MyClass
|
public val test3a: MyClass
|
||||||
|
|
||||||
public open class MyClass {
|
public open class MyClass {
|
||||||
@@ -21,9 +21,9 @@ public final class MyDerived : MyClass {
|
|||||||
public constructor MyDerived()
|
public constructor MyDerived()
|
||||||
public final val test4: [ERROR : Type for MyAlias(1)]
|
public final val test4: [ERROR : Type for MyAlias(1)]
|
||||||
public final val test4a: [ERROR : Type for MyClass(1)]
|
public final val test4a: [ERROR : Type for MyClass(1)]
|
||||||
public final val test5: MyClass
|
public final val test5: MyAlias /* = MyClass */
|
||||||
public final val test5a: MyClass
|
public final val test5a: MyClass
|
||||||
public final val test6: MyClass
|
public final val test6: MyAlias /* = MyClass */
|
||||||
public final val test6a: MyClass
|
public final val test6a: MyClass
|
||||||
public final override /*1*/ /*fake_override*/ val x: kotlin.Int
|
public final override /*1*/ /*fake_override*/ val x: kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
|||||||
+2
-2
@@ -2,9 +2,9 @@ package
|
|||||||
|
|
||||||
public val test1: ObjectWithInvoke
|
public val test1: ObjectWithInvoke
|
||||||
public val test2: ObjectWithInvoke
|
public val test2: ObjectWithInvoke
|
||||||
public val test3: ClassWithCompanionObjectWithInvoke
|
public val test3: CWI /* = ClassWithCompanionObjectWithInvoke */
|
||||||
public val test4: kotlin.Any
|
public val test4: kotlin.Any
|
||||||
public val test5: ClassWithCompanionObjectWithInvoke
|
public val test5: CWI /* = ClassWithCompanionObjectWithInvoke */
|
||||||
public val test5a: ClassWithCompanionObjectWithInvoke
|
public val test5a: ClassWithCompanionObjectWithInvoke
|
||||||
|
|
||||||
public final class ClassWithCompanionObjectWithInvoke {
|
public final class ClassWithCompanionObjectWithInvoke {
|
||||||
|
|||||||
+2
-3
@@ -57,9 +57,8 @@ FILE /kt16905.kt
|
|||||||
FUN FAKE_OVERRIDE public open override fun toString(): kotlin.String
|
FUN FAKE_OVERRIDE public open override fun toString(): kotlin.String
|
||||||
$this: VALUE_PARAMETER this@Any: Any
|
$this: VALUE_PARAMETER this@Any: Any
|
||||||
TYPEALIAS typealias OI = Outer.Inner type=Outer.Inner
|
TYPEALIAS typealias OI = Outer.Inner type=Outer.Inner
|
||||||
FUN public fun test(): Outer.Inner
|
FUN public fun test(): OI /* = Outer.Inner */
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='test(): Outer.Inner'
|
RETURN type=kotlin.Nothing from='test(): OI /* = Outer.Inner */'
|
||||||
CALL 'constructor Inner()' type=Outer.Inner origin=null
|
CALL 'constructor Inner()' type=Outer.Inner origin=null
|
||||||
$this: CALL 'constructor Outer()' type=Outer origin=null
|
$this: CALL 'constructor Outer()' type=Outer origin=null
|
||||||
|
|
||||||
|
|||||||
+1
-5
@@ -185,11 +185,7 @@ class TypeAliasConstructorDescriptorImpl private constructor(
|
|||||||
val returnType = run {
|
val returnType = run {
|
||||||
val returnTypeNoAbbreviation = substitutorForUnderlyingClass.substitute(constructor.returnType, Variance.INVARIANT)
|
val returnTypeNoAbbreviation = substitutorForUnderlyingClass.substitute(constructor.returnType, Variance.INVARIANT)
|
||||||
?: return null
|
?: return null
|
||||||
val abbreviation = typeAliasDescriptor.defaultType
|
returnTypeNoAbbreviation.unwrap().lowerIfFlexible().withAbbreviation(typeAliasDescriptor.defaultType)
|
||||||
if (returnTypeNoAbbreviation is SimpleType && abbreviation is SimpleType)
|
|
||||||
returnTypeNoAbbreviation.withAbbreviation(abbreviation)
|
|
||||||
else
|
|
||||||
returnTypeNoAbbreviation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val receiverParameterType = constructor.dispatchReceiverParameter?.let { substitutorForUnderlyingClass.safeSubstitute(it.type, Variance.INVARIANT) }
|
val receiverParameterType = constructor.dispatchReceiverParameter?.let { substitutorForUnderlyingClass.safeSubstitute(it.type, Variance.INVARIANT) }
|
||||||
|
|||||||
+12
@@ -557,6 +557,18 @@ public class ExperimentalIncrementalJpsTestGenerated extends AbstractExperimenta
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalTypealiasConstructor")
|
||||||
|
public void testInternalTypealiasConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/internalTypealiasConstructor/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalTypealiasObject")
|
||||||
|
public void testInternalTypealiasObject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/internalTypealiasObject/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("localClassChanged")
|
@TestMetadata("localClassChanged")
|
||||||
public void testLocalClassChanged() throws Exception {
|
public void testLocalClassChanged() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/localClassChanged/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/localClassChanged/");
|
||||||
|
|||||||
+12
@@ -557,6 +557,18 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalTypealiasConstructor")
|
||||||
|
public void testInternalTypealiasConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/internalTypealiasConstructor/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalTypealiasObject")
|
||||||
|
public void testInternalTypealiasObject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/internalTypealiasObject/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("localClassChanged")
|
@TestMetadata("localClassChanged")
|
||||||
public void testLocalClassChanged() throws Exception {
|
public void testLocalClassChanged() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/localClassChanged/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/localClassChanged/");
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
package foo
|
package foo
|
||||||
|
|
||||||
internal typealias TypeAlias = Int
|
internal typealias TypeAlias = Int
|
||||||
|
internal typealias TypeAlias2 = TypeAlias
|
||||||
@@ -2,4 +2,8 @@ package foo
|
|||||||
|
|
||||||
internal fun useTypeAlias(x: TypeAlias) {
|
internal fun useTypeAlias(x: TypeAlias) {
|
||||||
x.toString()
|
x.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun useTypeAlias2(x: TypeAlias2) {
|
||||||
|
x.toString()
|
||||||
}
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class C
|
||||||
|
|
||||||
|
internal typealias CAlias = C
|
||||||
|
internal typealias CAlias2 = CAlias
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
================ Step #1 =================
|
||||||
|
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/META-INF/module.kotlin_module
|
||||||
|
out/production/module/test/UseTypeAliasConstructorKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/useTypeAliasConstructor.kt
|
||||||
|
End of files
|
||||||
|
Exit code: OK
|
||||||
|
------------------------------------------
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
val c = CAlias()
|
||||||
|
val c2 = CAlias2()
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class C {
|
||||||
|
companion object
|
||||||
|
}
|
||||||
|
|
||||||
|
internal typealias CAlias = C
|
||||||
|
internal typealias CAlias2 = CAlias
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
================ Step #1 =================
|
||||||
|
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/META-INF/module.kotlin_module
|
||||||
|
out/production/module/test/UseTypeAliasObjectKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/useTypeAliasObject.kt
|
||||||
|
End of files
|
||||||
|
Exit code: OK
|
||||||
|
------------------------------------------
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
val cc = CAlias
|
||||||
|
val cc2 = CAlias2
|
||||||
Reference in New Issue
Block a user