Skip to content

Commit 0668b71

Browse files
authored
Merge pull request github#14831 from igfoo/igfoo/kot2
Kotlin: Add 2.0.0-Beta1
2 parents d8e7c9c + 95de749 commit 0668b71

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

java/kotlin-extractor/build.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,14 @@ def write_arg_file(arg_file, args):
9090
def compile_to_dir(build_dir, srcs, version, classpath, java_classpath, output):
9191
# Use kotlinc to compile .kt files:
9292
kotlin_arg_file = build_dir + '/kotlin.args'
93-
kotlin_args = ['-Werror',
94-
'-opt-in=kotlin.RequiresOptIn',
95-
'-opt-in=org.jetbrains.kotlin.ir.symbols.IrSymbolInternals',
96-
'-d', output,
93+
opt_in_args = ['-opt-in=kotlin.RequiresOptIn']
94+
if version.lessThan(kotlin_plugin_versions.Version(2, 0, 0, "")):
95+
opt_in_args.append('-opt-in=org.jetbrains.kotlin.ir.symbols.IrSymbolInternals')
96+
else:
97+
opt_in_args.append('-opt-in=org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI')
98+
kotlin_args = ['-Werror'] \
99+
+ opt_in_args \
100+
+ ['-d', output,
97101
'-module-name', 'codeql-kotlin-extractor',
98102
'-Xsuppress-version-warnings',
99103
'-language-version', version.toLanguageVersionString(),

java/kotlin-extractor/kotlin_plugin_versions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def toTupleWithTag(self):
2727
def toTupleNoTag(self):
2828
return [self.major, self.minor, self.patch]
2929

30+
def lessThan(self, other):
31+
return self.toTupleNoTag() < other.toTupleNoTag()
32+
3033
def lessThanOrEqual(self, other):
3134
return self.toTupleNoTag() <= other.toTupleNoTag()
3235

@@ -43,7 +46,7 @@ def version_string_to_version(version):
4346
# Version number used by CI.
4447
ci_version = '1.9.0'
4548

46-
many_versions = [ '1.5.0', '1.5.10', '1.5.20', '1.5.30', '1.6.0', '1.6.20', '1.7.0', '1.7.20', '1.8.0', '1.9.0-Beta', '1.9.20-Beta' ]
49+
many_versions = [ '1.5.0', '1.5.10', '1.5.20', '1.5.30', '1.6.0', '1.6.20', '1.7.0', '1.7.20', '1.8.0', '1.9.0-Beta', '1.9.20-Beta', '2.0.0-Beta1' ]
4750

4851
many_versions_versions = [version_string_to_version(v) for v in many_versions]
4952
many_versions_versions_asc = sorted(many_versions_versions, key = lambda v: v.toTupleWithTag())
@@ -58,7 +61,7 @@ def get_single_version(fakeVersionOutput = None):
5861
if kotlinc is None:
5962
raise KotlincNotFoundException()
6063
versionOutput = subprocess.run([kotlinc, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stderr if fakeVersionOutput is None else fakeVersionOutput
61-
m = re.match(r'.* kotlinc-jvm ([0-9]+\.[0-9]+\.[0-9]+-?[a-zA-Z]*) .*', versionOutput)
64+
m = re.match(r'.* kotlinc-jvm ([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z][a-zA-Z0-9]*)?) .*', versionOutput)
6265
if m is None:
6366
raise Exception('Cannot detect version of kotlinc (got ' + str(versionOutput) + ')')
6467
current_version = version_string_to_version(m.group(1))

0 commit comments

Comments
 (0)