Skip to content

Commit 88628ff

Browse files
committed
Kotlin: Accept test changes
Accept test changes from Kotlin 2.3.0 update Updates expected test outputs for kotlin2 library tests to match actual compiler output. Changes include: - Location adjustments for properties/methods (now point to identifiers) - CastExpr -> ImplicitCastExpr for implicit type casts - Removed duplicate BlockStmt entries in loop ASTs - Super constructor call location changes Note that in Kotlin 2.3.0 super constructor calls now have locations spanning entire class declarations instead of the actual super call site.
1 parent d0878a2 commit 88628ff

File tree

48 files changed

+1046
-901
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1046
-901
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
if (( $# != 2 )); then
4+
echo Exactly two arguments expected. Got $#
5+
exit 1
6+
fi
7+
8+
SOURCE=$1
9+
DEST=$2
10+
11+
cd $SOURCE
12+
for f in *; do
13+
if [ -f ../$DEST/$f ]; then
14+
echo -n "Skip"
15+
else
16+
echo -n "Copy"
17+
cp $f ../$DEST
18+
fi
19+
echo ": $f"
20+
done
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.github.codeql
2+
3+
// The compiler provides the annotation class, so we don't need to do
4+
// anything
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
4+
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
5+
6+
fun isUnderscoreParameter(vp: IrValueParameter) =
7+
vp.origin == IrDeclarationOrigin.UNDERSCORE_PARAMETER
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.github.codeql.utils
2+
3+
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
4+
import org.jetbrains.kotlin.ir.symbols.*
5+
import org.jetbrains.kotlin.name.CallableId
6+
import org.jetbrains.kotlin.name.ClassId
7+
import org.jetbrains.kotlin.name.FqName
8+
import org.jetbrains.kotlin.name.Name
9+
10+
fun getClassByFqName(pluginContext: IrPluginContext, fqName: FqName): IrClassSymbol? {
11+
val id = ClassId.topLevel(fqName)
12+
return getClassByClassId(pluginContext, id)
13+
}
14+
15+
fun getClassByClassId(pluginContext: IrPluginContext, id: ClassId): IrClassSymbol? {
16+
return pluginContext.referenceClass(id)
17+
}
18+
19+
fun getFunctionsByFqName(
20+
pluginContext: IrPluginContext,
21+
pkgName: FqName,
22+
name: Name
23+
): Collection<IrSimpleFunctionSymbol> {
24+
val id = CallableId(pkgName, name)
25+
return pluginContext.referenceFunctions(id)
26+
}
27+
28+
fun getPropertiesByFqName(
29+
pluginContext: IrPluginContext,
30+
pkgName: FqName,
31+
name: Name
32+
): Collection<IrPropertySymbol> {
33+
val id = CallableId(pkgName, name)
34+
return pluginContext.referenceProperties(id)
35+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
4+
5+
val kind_ENUM_ENTRIES: IrSyntheticBodyKind? = IrSyntheticBodyKind.ENUM_ENTRIES
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.backend.jvm.ir.isRawType
4+
import org.jetbrains.kotlin.ir.types.IrSimpleType
5+
6+
fun IrSimpleType.codeQlIsRawType() = this.isRawType()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
4+
import org.jetbrains.kotlin.ir.util.allOverridden
5+
6+
fun IrSimpleFunction.allOverriddenIncludingSelf() = this.allOverridden(includeSelf = true)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.declarations.IrFunction
4+
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
5+
import org.jetbrains.kotlin.ir.util.copyTo
6+
7+
fun copyParameterToFunction(p: IrValueParameter, f: IrFunction) = p.copyTo(f)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
4+
import org.jetbrains.kotlin.ir.declarations.IrField
5+
import org.jetbrains.kotlin.ir.declarations.IrMemberWithContainerSource
6+
import org.jetbrains.kotlin.load.kotlin.FacadeClassSource
7+
import org.jetbrains.kotlin.name.FqName
8+
9+
fun getFileClassFqName(d: IrDeclaration): FqName? {
10+
// d is in a file class.
11+
// Get the name in a similar way to the compiler's ExternalPackageParentPatcherLowering
12+
// visitMemberAccess/generateOrGetFacadeClass.
13+
14+
// But first, fields aren't IrMemberWithContainerSource, so we need
15+
// to get back to the property (if there is one)
16+
if (d is IrField) {
17+
val propSym = d.correspondingPropertySymbol
18+
if (propSym != null) {
19+
return getFileClassFqName(propSym.owner)
20+
}
21+
}
22+
23+
// Now the main code
24+
if (d is IrMemberWithContainerSource) {
25+
val containerSource = d.containerSource
26+
if (containerSource is FacadeClassSource) {
27+
val facadeClassName = containerSource.facadeClassName
28+
if (facadeClassName != null) {
29+
// TODO: This is really a multifile-class rather than a file-class,
30+
// but for now we treat them the same.
31+
return facadeClassName.fqNameForTopLevelClassMaybeWithDollars
32+
} else {
33+
return containerSource.className.fqNameForTopLevelClassMaybeWithDollars
34+
}
35+
} else {
36+
return null
37+
}
38+
} else {
39+
return null
40+
}
41+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.types.IrType
4+
import org.jetbrains.kotlin.ir.types.makeNotNull
5+
import org.jetbrains.kotlin.ir.types.makeNullable
6+
7+
fun IrType.codeQlWithHasQuestionMark(b: Boolean): IrType {
8+
if (b) {
9+
return this.makeNullable()
10+
} else {
11+
return this.makeNotNull()
12+
}
13+
}

0 commit comments

Comments
 (0)