Skip to content

Commit 2e1db7d

Browse files
authored
Merge pull request github#9290 from igfoo/igfoo/kotlin1.7
Kotlin: Add support for the 1.7 RC
2 parents dd52a70 + 81e876a commit 2e1db7d

File tree

17 files changed

+127
-6
lines changed

17 files changed

+127
-6
lines changed

java/kotlin-extractor/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ sourceSets {
3535
"utils/versions/v_1_5_21/*.kt",
3636
"utils/versions/v_1_5_31/*.kt",
3737
"utils/versions/v_1_6_10/*.kt",
38+
"utils/versions/v_1_7_0-RC/*.kt",
3839
// "utils/versions/v_1_6_20/*.kt",
3940
]
4041
}

java/kotlin-extractor/build.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def parse_args():
2121
help='Build for all versions/kinds')
2222
parser.add_argument('--single', action='store_false',
2323
dest='many', help='Build for a single version/kind')
24+
parser.add_argument('--single-version',
25+
help='Build for a specific version/kind')
2426
return parser.parse_args()
2527

2628

@@ -174,8 +176,8 @@ def compile(jars, java_jars, dependency_folder, transform_to_embeddable, output,
174176

175177
for v in kotlin_plugin_versions.many_versions:
176178
if v != version:
177-
shutil.rmtree(
178-
tmp_dir + '/main/kotlin/utils/versions/v_' + v.replace('.', '_'))
179+
d = tmp_dir + '/main/kotlin/utils/versions/v_' + v.replace('.', '_')
180+
shutil.rmtree(d)
179181

180182
srcs = find_sources(tmp_dir)
181183

@@ -205,7 +207,9 @@ def compile_standalone(version):
205207
'build/temp_src',
206208
version)
207209

208-
if args.many:
210+
if args.single_version:
211+
compile_standalone(args.single_version)
212+
elif args.many:
209213
for version in kotlin_plugin_versions.many_versions:
210214
compile_standalone(version)
211215
compile_embeddable(version)

java/kotlin-extractor/kotlin_plugin_versions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/python
2+
13
import platform
24
import re
35
import shutil
@@ -19,7 +21,7 @@ def version_string_to_tuple(version):
1921
m = re.match(r'([0-9]+)\.([0-9]+)\.([0-9]+)', version)
2022
return tuple([int(m.group(i)) for i in range(1, 4)])
2123

22-
many_versions = [ '1.4.32', '1.5.0', '1.5.10', '1.5.21', '1.5.31', '1.6.10', '1.6.20' ]
24+
many_versions = [ '1.4.32', '1.5.0', '1.5.10', '1.5.21', '1.5.31', '1.6.10', '1.7.0-RC', '1.6.20' ]
2325

2426
many_versions_tuples = [version_string_to_tuple(v) for v in many_versions]
2527

java/kotlin-extractor/src/main/kotlin/utils/TypeSubstitution.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.github.codeql.utils
22

33
import com.github.codeql.KotlinUsesExtractor
44
import com.github.codeql.getJavaEquivalentClassId
5+
import com.github.codeql.utils.versions.codeQlWithHasQuestionMark
56
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
67
import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor
78
import org.jetbrains.kotlin.backend.common.lower.parents
@@ -66,7 +67,7 @@ private fun subProjectedType(substitutionMap: Map<IrTypeParameterSymbol, IrTypeA
6667
if (conflictingVariance(outerVariance, substitutedTypeArg.variance))
6768
IrStarProjectionImpl
6869
else {
69-
val newProjectedType = substitutedTypeArg.type.let { if (t.hasQuestionMark) it.withHasQuestionMark(true) else it }
70+
val newProjectedType = substitutedTypeArg.type.let { if (t.hasQuestionMark) it.codeQlWithHasQuestionMark(true) else it }
7071
val newVariance = combineVariance(outerVariance, substitutedTypeArg.variance)
7172
makeTypeProjection(newProjectedType, newVariance)
7273
}
@@ -191,7 +192,7 @@ fun IrTypeArgument.withQuestionMark(b: Boolean): IrTypeArgument =
191192
is IrStarProjection -> this
192193
is IrTypeProjection ->
193194
this.type.let { when(it) {
194-
is IrSimpleType -> if (it.hasQuestionMark == b) this else makeTypeProjection(it.withHasQuestionMark(b), this.variance)
195+
is IrSimpleType -> if (it.hasQuestionMark == b) this else makeTypeProjection(it.codeQlWithHasQuestionMark(b), this.variance)
195196
else -> this
196197
}}
197198
else -> this
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.types.IrType
4+
import org.jetbrains.kotlin.ir.types.withHasQuestionMark
5+
6+
fun IrType.codeQlWithHasQuestionMark(b : Boolean): IrType {
7+
return this.withHasQuestionMark(b)
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.types.IrType
4+
import org.jetbrains.kotlin.ir.types.withHasQuestionMark
5+
6+
fun IrType.codeQlWithHasQuestionMark(b : Boolean): IrType {
7+
return this.withHasQuestionMark(b)
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.types.IrType
4+
import org.jetbrains.kotlin.ir.types.withHasQuestionMark
5+
6+
fun IrType.codeQlWithHasQuestionMark(b : Boolean): IrType {
7+
return this.withHasQuestionMark(b)
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.types.IrType
4+
import org.jetbrains.kotlin.ir.types.withHasQuestionMark
5+
6+
fun IrType.codeQlWithHasQuestionMark(b : Boolean): IrType {
7+
return this.withHasQuestionMark(b)
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.types.IrType
4+
import org.jetbrains.kotlin.ir.types.withHasQuestionMark
5+
6+
fun IrType.codeQlWithHasQuestionMark(b : Boolean): IrType {
7+
return this.withHasQuestionMark(b)
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.types.IrType
4+
import org.jetbrains.kotlin.ir.types.withHasQuestionMark
5+
6+
fun IrType.codeQlWithHasQuestionMark(b : Boolean): IrType {
7+
return this.withHasQuestionMark(b)
8+
}

0 commit comments

Comments
 (0)