Commit Graph

409 Commits

Author SHA1 Message Date
LepilkinaElena
21fe5ac415 Fix parser for linkerOpts/compilerOpts (KT-29970) (#2219) 2019-03-29 20:13:23 +03:00
Alexander Udalov
4cb5a4fb6d Fix misc typos in IR backends 2019-03-28 14:26:09 +01:00
Alexey Tsvetkov
0687b8eac3 Add argument to allow running compiler without sources
`-Xbuild-file` argument allows the compiler to run without
passing any Kotlin source file in arguments.
We have been using this property in
Kotlin Gradle plugin for a few important cases:
1. incremental compilation (to update caches when there are only removed files);
2. for KAPT (Kotlin sources don't make sense in context
of running APs).

We want to stop using `-Xbuild-file` in Kotlin Gradle plugin,
and avoid breaking the Gradle plugin or IC in other build-systems.

This change adds an argument to explicitly run
the compiler without specifying any Kotlin source file.
2019-03-25 16:39:47 +03:00
Alexey Tsvetkov
4154e97aa3 Fixes after code review 2019-03-25 16:39:47 +03:00
Alexey Tsvetkov
5f54f67f70 Stop using -Xbuild-file in Gradle Plugin
#KT-27640 fixed
    #KT-27778 fixed
    #KT-27638 fixed
2019-03-25 16:39:47 +03:00
Alexander Udalov
ed86757817 Rework how built-in types are loaded in compiler for JVM
In TopDownAnalyzerFacadeForJVM, we now always use the "load built-ins
from module dependencies" behavior that was previously only enabled with
the dedicated CLI argument -Xload-builtins-from-dependencies. However,
sometimes we compile code without kotlin-stdlib in the classpath, and we
don't want everything to crash because some standard type like
kotlin.Unit hasn't been found.

To mitigate this, we add another module at the end of the dependencies
list, namely a "fallback built-ins" module. This module loads all
built-in declarations from the compiler's class loader, as was done by
default previously. This prevents the compiler from crashing if any
built-in declaration is not found, but compiling the code against
built-ins found in the compiler is still discouraged, so we report an
error if anything is resolved to a declaration from this module, via a
new checker MissingBuiltInDeclarationChecker.

Also introduce a new CLI argument -Xsuppress-missing-builtins-error
specifically to suppress this error and to allow compiling code against
compiler's own built-ins.

 #KT-19227 Fixed
 #KT-28198 Fixed
2019-03-22 14:59:03 +01:00
Georgy Bronnikov
fae003866b Use CLI compiler arguments directly in PhaseConfig creation 2019-03-21 23:32:25 +03:00
Alexander Udalov
518b03125c Support JVM target versions up to 12
#KT-26240 Fixed
2019-03-07 11:42:31 +01:00
Georgy Bronnikov
c618ef9304 Correct phase argument names and cli test outputs 2019-02-28 11:53:02 +03:00
Georgy Bronnikov
da13d3288e Check pre- and postconditions on phases 2019-02-28 11:53:02 +03:00
Ilya Chernikov
3943bd1b15 Make toString for repl return function types nicer, drop obsolete isFunctionType 2019-02-05 16:13:06 +01:00
Alexander Udalov
db487a622a Add -Xsanitize-parentheses to workaround ASM 6.1 issue in frame computation
#KT-29475 Fixed
2019-01-31 15:47:43 +01:00
Mikhael Bogdanov
a122cba862 Switch Kotlin project to jvm-target 1.8
#KT-29405
2019-01-31 07:43:05 +01:00
Ilya Chernikov
f125600af1 Restore returning of functional types from repl eval
add tests for the broken case as well for the return value representation
#KT-29490 fixed
2019-01-29 15:05:37 +01:00
Ilya Chernikov
04b04ea0ee Refactor compiler arguments to configuration conversion:
extract into independent functions, rearrange logic
2019-01-28 13:15:36 +01:00
Alexander Udalov
6b5a16884c Refactor inheritMultifileParts to be a JVM analysis flag
Instead of a JVMConfigurationKeys key. This will allow to use it in a
checker in 'frontend.java'
2019-01-25 15:57:13 +01:00
Alexander Udalov
05c25342ad Make CommonToolArguments.nullable
#KT-28974 Fixed
2019-01-15 17:21:43 +01:00
vitaly.khudobakhshov
396ba6cdd5 Display function value properly 2018-12-05 16:02:29 +01:00
vitaly.khudobakhshov
c901d6cebc Implement support for "resX" result fields in REPL 2018-12-05 16:01:32 +01:00
Georgy Bronnikov
f4aad70b36 Fix KotlinFrameworkSupportProviderTest 2018-11-30 18:00:27 +03:00
Georgy Bronnikov
32640750ee Add CompilerPhase and corresponding compiler keys 2018-11-29 12:48:52 +03:00
Yan Zhulanow
69ec958aab Kapt: Add tests for the command-line 'kapt' tool 2018-11-27 22:21:23 +09:00
Yan Zhulanow
6e5eb0fdd4 Kapt: Implement 'kapt' command-line tool (KT-24998, KT-24997) 2018-11-27 22:21:23 +09:00
Alexander Udalov
9b07bbdf56 Do not use backslash for escaping outside of string literals in argfiles
This fixes CLI tests testArgfileWithEscaping and
testApiVersionLessThanLanguageUsingArgfile on Windows

 #KT-28180 Fixed
2018-11-14 12:53:24 +01:00
Natalia Selezneva
e48fbe4aa3 Do not insert additional new lines in REPL 2018-11-01 15:00:41 +03:00
Natalia Selezneva
468404c6c3 Repl: refactoring, move common parts to utils 2018-11-01 15:00:41 +03:00
Alexander Udalov
9df02b2366 Support Groovy $Trait$FieldHelper classes in new class file reader
Preface: for Groovy traits with fields, the Groovy compiler generates
synthetic "$Trait$FieldHelper" classes which posed several problems to
our class file reader, caused by the fact that the contents of the
InnerClasses attribute broke some assumptions about how names on the JVM
are formed and used.

For a trait named `A`, the Groovy compiler will additionally generate a
synthetic class file `A$Trait$FieldHelper` with the following in the
InnerClasses attribute:

InnerClasses:
     public static #15= #2 of #14; //FieldHelper=class A$Trait$FieldHelper of class A

i.e. the simple name of the class is `FieldHelper`, the name of its
outer class is `A`, but the full internal name is `A$Trait$FieldHelper`,
which is surprising considering that the names are usually obtained by
separating the outer and inner names via the dollar sign.

Another detail is that in some usages of this synthetic class, the
InnerClasses attribute was missing at all. For example, if an empty
class `B` extends `A`, then there's no InnerClasses attribute in `B`'s
class file, which is surprising because we might decode the same name
differently depending on the class file we encounter it in.

In this change, we attempt to treat these synthetic classes as top-level
by refusing to read "invalid" InnerClasses attribute values (they are
not technically invalid because they still conform to JVMS), fixing the
problem of "unresolved supertypes" error which occurred when these
classes were used as supertypes in a class file in a dependency.

1) In ClassifierResolutionContext.mapInternalNameToClassId, do not use
   the ad-hoc logic (copy-pasted from intellij-core) to determine class
   id heuristically from the internal name. For $Trait$FieldHelper
   classes this logic attempted to replace all dollar signs with dots,
   which was semantically incorrect: dollars there were used as
   synthetic characters, not as a separator between outer and inner
   classes.
2) In isNotTopLevelClass (Other.kt), only consider "valid" InnerClasses
   attribute values, where the full name of the class is obtained by
   separating the outer name and the inner name with a dollar character.
   This way, we'll be able to treat class files with invalid attribute
   values as top-level and avoid breaking any other assumptions in the
   class file loader.
3) In BinaryJavaClass.visitInnerClass, record all valid InnerClasses
   attribute values present in the class file, not just those related to
   the class in question itself. This is needed now because previously,
   the removed heuristics (see p.1) transformed mentioned inner class
   names to class ids correctly >99% of the time. Now that the
   heuristics are gone, we'll use the information present in the class
   file to map names correctly and predictably. According to JVMS, this
   attribute should contain information about all inner classes
   mentioned in the class file, and this is true at least for class
   files produced by javac.

 #KT-18592 Fixed
2018-10-25 22:15:22 +02:00
Alexander Udalov
009f18f1f4 Split AnalysisFlag values to AnalysisFlags and JvmAnalysisFlags
Declare AnalysisFlags in module 'frontend', and JvmAnalysisFlags in
module 'frontend.java', to avoid leaking Java-related logic to common
compiler code
2018-10-01 13:31:00 +02:00
Alexey Sedunov
c59779f5b9 MPP: Retain KotlinSourceSetInfo for Android in data nodes
User data is not serialized which leads to broken import on reopening

 #KT-27213 Fixed
2018-10-01 13:55:35 +03:00
Dmitry Petrov
729da29e49 Update command-line options help for '-Xnormalize-constructor-calls'
Default value depends on language version.
2018-10-01 09:42:13 +03:00
Alexander Udalov
088cd4b5e3 Stop parsing argument in argfile when quote ends
There are two visible effects of this change:
1) If an empty argument is passed in quotes, it will be parsed as an
   empty string and handled by the compiler, which will report an error
   later. The specific error is not very important because it's an edge
   case anyway; at the moment, "source file or directory not found:" is
   reported which is no better than the "invalid flag:" error reported
   by javac in the similar case
2) It's no longer possible to split an argument into several parts and
   quote them separately, such as:

       "-langu"ag"e-"ver'sio'n 1.2

   No test added for this change in behavior since it's an even edgier
   case. Note that javac also prohibits this.

 #KT-27226 Fixed
2018-09-28 16:02:40 +02:00
Alexander Udalov
16dd6ebe61 Handle whitespaces in argfiles correctly
#KT-27218 Fixed
2018-09-28 16:02:40 +02:00
Mikhail Glukhikh
64b23812c0 Move CliArgumentStringBuilder: cli -> idea-jvm 2018-09-25 19:14:12 +03:00
Mikhail Glukhikh
f6b805a973 Add enable / disable feature in JPS
#KT-26775 Fixed
#KT-26774 Fixed
2018-09-20 15:56:37 +03:00
Mikhail Glukhikh
8a7ff4cd24 Add enable / disable feature in Maven project
Part of KT-26775
2018-09-20 15:56:32 +03:00
Mikhail Zarechenskiy
169599abcc Add flag to allow using kotlin.Result as a return type
#KT-26659 Fixed
2018-09-11 10:39:11 +03:00
Alexander Udalov
c4be039cd1 Support argfiles in CLI with "@argfile"
#KT-24613 Fixed
2018-09-10 14:12:32 +03:00
Alexander Udalov
e996513044 Support single quotation marks in argfiles
#KT-26122 Fixed
2018-09-10 14:12:31 +03:00
Alexander Udalov
9311ea5d25 Support progressive mode via "-progressive"
#KT-25862 Fixed
2018-09-10 14:12:31 +03:00
Alexander Udalov
1d5d6b5b72 Support strict metadata version semantics
Preface: Kotlin 1.3 will be able to read metadata of .class files
produced by Kotlin 1.4 (see KT-25972). Also, to simplify implementation
and to improve diagnostic messages, we're going to advance JVM metadata
version to 1.4.0 in Kotlin 1.4, and would like to keep it in sync with
the compiler version thereafter. This presents a problem: in an unlikely
event that before releasing 1.4, we find out that the metadata-reading
implementation in 1.3 was incorrect, we'd like to be able to fix the bug
in that implementation and _forbid_ 1.3 from reading metadata of 1.4.
But prior to this commit the only way to do this was to advance the
metadata version, in this case to 1.5, and that breaks the
metadata/compiler version equivalence we'd like to keep.

The solution is to add another boolean flag to the class file, called
"strict metadata version semantics", which signifies that if this class
file has metadata version 1.X, then it can only be read by the compilers
of versions 1.X and greater. This flag effectively disables the smooth
migration scenario proposed in KT-25972 (as does increasing metadata
version by 2), and will be used only in hopeless situations as in the
case described above.
2018-09-10 14:12:18 +03:00
Alexander Udalov
02a9b03007 Report a warning or error if an old language version or API version is used
#KT-25823 Fixed
2018-08-30 14:57:31 +03:00
Ilmir Usmanov
cf1f194f8b Add warning on -Xcoroutines flag use
The only case when warning is not reported is -Xcoroutines=default.
But this is OK until the flag is removed completely.
2018-08-30 14:55:50 +03:00
Alexander Udalov
0f003802fe Introduce -Xcommon-sources and pass it correctly from build tool plugins
#KT-25196 In Progress
2018-08-21 12:49:10 +02:00
Mikhail Zarechenskiy
b1985ee422 Enable SAM conversion for Kotlin functions by default in new inference
KT-25686
2018-08-10 17:24:18 +03:00
Sergey Rostov
59c41e111d K2JSCompilerArguments: sourceMapEmbedSources should be null by default.
When sourceMapEmbedSources are not null and source maps is disabled warning is reported, since it has effect only when source maps are enabled. Also this fixes some JPS JS with warnings count assertions.
2018-08-10 12:23:40 +03:00
Alexey Sedunov
abbac067b8 Configuration: Collapse empty nullable strings to null 2018-08-09 10:06:30 +03:00
Alexey Sedunov
ecf607d4fa Gradle: Implement new MPP model import 2018-08-07 15:59:41 +03:00
Alexander Udalov
4bd66d5aa8 Add compiler argument -Xfriend-paths for kotlinc-jvm
#KT-21910 Fixed
2018-07-27 18:51:42 +02:00
Dmitry Petrov
566b5856ec Constructor call normalization mode depends on language version 2018-07-27 09:52:29 +03:00
Dmitry Savvinov
6dacd1011f Do not report warning if -XXLanguage turns on bugfix
KT-25554 Fixed
2018-07-20 14:24:42 +03:00