Commit Graph

418 Commits

Author SHA1 Message Date
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
Dmitry Savvinov 8964b2c7a4 Minor: escape colon properly in interalArgWrongPrefix.args 2018-06-21 13:36:11 +03:00
Mikhail Zarechenskiy 605cdcd8d8 Allow to use inline classes in 1.3 with warning 2018-06-18 11:52:31 +03:00
Mikhael Bogdanov 419218b9cf Rename 'jvm-default-mode' to 'jvm-default'. Add description 2018-05-29 11:26:36 +02:00
Dmitry Savvinov da7b59984f Move importsDumper to compiler plugin 2018-05-28 13:02:48 +03:00
Dmitry Savvinov 16ee2df585 Fix tests for imports dumper
Remove local absolute paths from testdata, introduce new testrunner to
support relativization of imports dump.
2018-05-28 13:02:47 +03:00
Alexander Udalov 06d97cce51 Fix multiple issues when expanding argfiles
- treat a contiguous whitespace sequence as a single argument separator,
  not as several empty-string arguments separated by whitespaces
- fix infinite loop when reading unfinished quoted argument
- do not attempt to perform escape if the backslash is the last
  character in the file
2018-05-28 11:23:32 +03:00
Dmitry Savvinov 43467516ef Support argfiles in kotlin compiler
Using '-Xargfile=path/to/argfile' will substitute
that argument with the content of argfile.

See KT-24472
2018-05-28 11:23:32 +03:00
Ilmir Usmanov f568149863 Implement new assert semantics in back-end
Previously, assert was just a regular function and its argument used to
be computed on each call (even if assertions are disabled on JVM).
This change adds support for 3 new behaviours of assert:
* always-enable (independently from -ea on JVM)
* always-disable (independently from -ea JVM)
* runtime/jvm (compile the calls like javac generates assert-operator)
* legacy (leave current eager semantics) - this already existed

Default behaviour is legacy for now.

The behavior is changed based on -Xassertions flag.
 #KT-7540: Fixed
2018-05-21 20:43:37 +03:00
Dmitry Savvinov c33b7377da Add support of internal arguments for language feature settings
Arguments are passed in form '-XXLanguage:+LanguageFeatureName' for enabling
LanguageFeature.LanguageFeatureName, and '-XXLanguage:-LanguageFeatureName'
for disabling.

Note that they do override other settings, including 'language-version'
or extra ('-X') args.
2018-05-18 16:16:23 +03:00
Dmitry Savvinov e8181c0473 Introduce -Xprogressive 2018-05-18 16:16:23 +03:00