Commit Graph

428 Commits

Author SHA1 Message Date
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
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
e627f08614 Make wrong phase name an error 2019-03-21 23:32:25 +03:00
Georgy Bronnikov
fae003866b Use CLI compiler arguments directly in PhaseConfig creation 2019-03-21 23:32:25 +03:00
Georgy Bronnikov
469fd20902 Warn about mistyped phase names in CLI 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
Ilya Chernikov
57ac149f5b Extract script cli evaluation to the plugin 2019-03-02 08:10:17 +01:00
Georgy Bronnikov
c618ef9304 Correct phase argument names and cli test outputs 2019-02-28 11:53:02 +03: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
Nikita Katkov
4db9174b4d Error on calling suspend functions inside Lock.withLock body
See SuspensionPointInsideCriticalSectionChecker
2018-12-28 19:56:26 +03:00
Marcin Moskala
686cfa6fd2 Fix common misspellings 2018-12-21 16:13:42 +03:00
Georgy Bronnikov
ffa3d7c57a Update test data 2018-11-29 12:48:52 +03:00
Alexander Udalov
5bc2178040 Report warning instead of error on incorrect -Xuse-experimental/-Xexperimental
#KT-27430 Fixed
 #KT-27709 Fixed
2018-10-30 19:58:03 +01:00
Mikhail Glukhikh
cb92009862 Fix maven build + ~50 compiler tests broken by UNUSED_PARAMETER in main 2018-10-26 19:51:20 +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
Ilmir Usmanov
9af7316845 Add call checker to report error more granulary if possible
This, however, works only for calls of 'synchronized' only. Thus, it
does not support inline functions of any kind.
2018-10-09 22:55:51 +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
Yan Zhulanow
2219f0956e Minor: Change the output for KT-19628 tests to the temporary directory path 2018-09-11 16:41:20 +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
Ilmir Usmanov
2d04acba42 Update test data of compiler tests, except IR tests 2018-08-30 16:24:41 +03:00
Dmitry Savvinov
b064c48f83 Fix testdata after advancing LATEST_STABLE to 1.3
This commit contains minor changes in testdata, where test and behavior
change are not related
2018-08-30 16:24:31 +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
Ilya Gorbunov
0f5f90cf52 Advance project version to 1.3-SNAPSHOT
Set LATEST_STABLE language version and current version of stdlib to 1.3, set IS_PRE_RELEASE
Remove "EXPERIMENTAL" from 1.3 version description in tests and gradle options
2018-08-30 14:49:27 +03:00
Yan Zhulanow
bda14fcbb2 Unresolved reference not reported on data class constructor @get annotation (KT-19628) 2018-08-24 04:28:16 +05:00
Alexander Udalov
852760b3b0 Report error on incompatible .kotlin_module files in classpath
Also remove obsolete test wrongAbiVersionNoErrors

 #KT-25973 Fixed
 #KT-26266 Open
2018-08-21 17:12:02 +02: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
Alexander Udalov
fe829add44 Minor, use TEMP_DIR/TESTDATA_DIR in CLI tests on xml build files
Otherwise the "outputDir" in these tests was treated as relative to the
project root, and starting from 63b4302cea, running these tests resulted
in the "whatever" directory being created in the project root
2018-08-07 13:38:30 +02:00
Alexander Udalov
19feacb96b Minor, expand TESTDATA_DIR with absolute path in CLI tests
To be able to use it correctly inside an xml build file where, if the
path is not absolute, it's treated as relative to the build file path
(which is TMP_DIR in several tests of the subsequent commit)
2018-08-07 13:38:30 +02:00
Alexander Udalov
4bd66d5aa8 Add compiler argument -Xfriend-paths for kotlinc-jvm
#KT-21910 Fixed
2018-07-27 18:51:42 +02:00
Alexander Udalov
3323fd5a11 Check "kotlin" package usage when compiling common code
#KT-25369 Fixed
2018-07-26 17:10:33 +02:00
Dmitry Petrov
6fb913a463 KT-22274 report error/warning on incorrect return target label 2018-07-25 12:08:20 +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
Alexander Udalov
871b896a21 Add internal compiler argument to change metadata version
Will be used in tests to check how we behave on binaries produced by a
"future" compiler
2018-07-18 17:59:37 +02:00
Dmitry Savvinov
70144f8003 Make warning about usage of -XX-flags less scary 2018-07-16 18:49:21 +03:00
Denis Zharkov
89d99e3989 Refine diagnostics for nullability migration warnings
#KT-24911 Fixed
2018-07-13 17:51:21 +03:00
Ilmir Usmanov
6ba2baa9da Deserialize constructors and properties with version requirement 1.3
if they have suspend function type in their descriptors.
Also, review fixes.

 #KT-25256: Fixed
2018-07-11 14:20:46 +03:00
Georgy Bronnikov
8ce658ab54 Introduce -Xuse-ir flag for cli compiler 2018-07-10 10:05:06 +02:00
Ilya Chernikov
b979f3dc52 Fix testdata 2018-07-10 08:43:52 +02:00
Ilya Chernikov
ec58929e39 Allow multiple same jsr305 options in the command-line
do not report duplicate jsr305 entries if options are the same
2018-07-10 08:43:51 +02:00
Dmitry Savvinov
8eb7eab535 Make tests on -XXLanguage more tolerant to 1.2 -> 1.3 transition 2018-07-05 10:42:50 +03:00
Alexander Udalov
0c45f20515 Minor, fix several CLI argument descriptions 2018-06-27 13:25:30 +02:00