Commit Graph

70289 Commits

Author SHA1 Message Date
Jinseong Jeon 2424f2438c FIR2IR: towards comprehensive visits in implicit cast inserter 2020-10-28 15:44:45 +03:00
Jinseong Jeon 5f6d2c5362 FIR2IR: utilize argument conversions 2020-10-28 15:44:44 +03:00
Jinseong Jeon f1fd3d6b5d FIR2IR: avoid using constant -1 2020-10-28 15:44:42 +03:00
Jinseong Jeon 707e94bab5 FIR2IR: add test about coercion-to-Unit for nested when 2020-10-28 15:44:41 +03:00
Jinseong Jeon 318f4b5f02 FIR2IR: refactor implicit cast insertion, part 3: implicit not_null 2020-10-28 15:44:40 +03:00
Jinseong Jeon 8708bdec0d FIR2IR: refactor implicit cast insertion, part 2: coerce-to-Unit 2020-10-28 15:44:39 +03:00
Jinseong Jeon 8f8ee88957 FIR2IR: refactor implicit cast insertion, part 1: implicit cast 2020-10-28 15:44:38 +03:00
Jinseong Jeon e9a7b64ca0 FIR2IR: use AnnotationGenerator to convert file annotations 2020-10-28 15:44:37 +03:00
Mikhail Glukhikh ef6b643b9c [FIR2IR] Don't set WHILE_LOOP origin for blocks 2020-10-28 15:44:36 +03:00
Yan Zhulanow eb9b5da82b Kapt: Never mark static methods 'default' (KT-42915) 2020-10-28 21:03:26 +09:00
Toshiaki Kameyama 09e1bed5c9 Redundant 'inner' modifier: fix false positive/negative with constructor call
#KT-40879 Fixed
#KT-41223 Fixed
#KT-41311 Fixed
#KT-41680 Fixed
2020-10-28 18:16:57 +07:00
nataliya.valtman e9669bf5cb fix unstable IncrementalFileToPathConverterTest tests 2020-10-28 12:33:03 +03:00
Denis Zharkov 2589de6c49 FIR: Refine delegated members introduced to use-site scope
- Do not add hashCode/equals/toString
- Do not add privates and ones that are already declared
2020-10-28 11:43:25 +03:00
Denis Zharkov 2105a041a5 FIR: Optimize usages of containingClass and its implementation 2020-10-28 11:43:25 +03:00
Denis Zharkov 923bb3b674 FIR2IR: Mute failing bb test
^KT-42946 Open
2020-10-28 11:43:25 +03:00
Denis Zharkov 2bdb21793f FIR: Adjust test data 2020-10-28 11:43:25 +03:00
Denis Zharkov b6a312483a FIR: Fix fir2symbol inconsistencies for imported properties
Do not copy delegateFieldSymbol because otherwise the old symbol will be rebound
to the new instance of a property
2020-10-28 11:43:25 +03:00
Denis Zharkov 09b7237ae5 FIR: Introduce importedFromObjectClassId 2020-10-28 11:43:25 +03:00
Denis Zharkov 4d9ef4d414 FIR: Get rid of CallableId::classId usages
Use dispatchReceiverType or containingClassAttr instead
2020-10-28 11:43:25 +03:00
Denis Zharkov 9996c983c9 FIR: Initialize dispatchReceiverType and containingClassAttr for callable members 2020-10-28 11:43:25 +03:00
Denis Zharkov ecb89a66be FIR: Copy attributes when copying declaration
Otherwise they share FirDeclarationAttributes instance that might lead
to problems when modifying only one of them
2020-10-28 11:43:25 +03:00
Denis Zharkov 52c6aebec2 FIR: Use copy-builders at FirObjectImportedCallableScope 2020-10-28 11:43:25 +03:00
Denis Zharkov 995b1aa1eb FIR: Add FirCallableMemberDeclaration::dispatchReceiverType 2020-10-28 11:43:25 +03:00
Ilya Gorbunov 0fa2cc15de Cleanup more test files and directories after tests
#KT-19192
2020-10-28 07:36:22 +03:00
Ilya Gorbunov fe098ec821 Revise functions in PathReadWrite
- Adjust implementations to avoid excessive vararg copies
- Remove options from forEachLine, it doesn't make much sense and
isn't consistent with the other read* functions.
- Revise inlineness of functions in PathReadWrite
- Compact implementations of those that are remained inline.
- Clarify docs of functions for reading the entire file

#KT-19192
2020-10-28 07:36:19 +03:00
Ilya Gorbunov a43cc0d1f9 Implement additional Path extensions
#KT-19192
2020-10-28 07:36:16 +03:00
Ilya Gorbunov 038f1cbd1e Add glob filtering when listing directory entries
#KT-19192
2020-10-28 07:36:14 +03:00
Ilya Gorbunov e7c888a2e6 Avoid introducing Path.printWriter
#KT-19192
2020-10-28 07:36:11 +03:00
Ilya Gorbunov 9f659d74df Introduce dedicated experimental annotation for Path extensions
#KT-19192
2020-10-28 07:36:08 +03:00
Ilya Gorbunov 997cd35e06 Move Path extensions to the new package kotlin.io.path
This avoids the conflict with the existing top-level functions in
kotlin.io package.

#KT-19192
2020-10-28 07:36:06 +03:00
Ilya Gorbunov 7d58a5e2f2 Simplify Path.copyTo implementation
Delegate most checks to the platform Files.copy.
This changes the exception type thrown in one case,
so document when it happens. Also 'copyTo' no longer
creates target parent directory if it doesn't exist.

#KT-19192
2020-10-28 07:36:02 +03:00
Ilya Gorbunov f6d2400208 Workaround bugs in Path.relativize
Also add actual paths to the relativeTo error message.

#KT-19192
2020-10-28 07:36:00 +03:00
AJ b3a87356bd Add java.nio.Path extensions to stdlib-jdk7: part 2
- Add notExists
- Rename isFile to isRegularFile
- Remove forEachBlock
- Rename listFiles
- Add relativeTo extensions
- Remove extra overloads
- Update doc comments
- Address review comments

#KT-19192
2020-10-28 07:35:57 +03:00
AJ 03cc0bf6aa Add java.nio.Path extensions to stdlib-jdk7
This PR adds most extensions on `java.io.File` in `kotlin.io` to `java.nio.Path`. This includes extensions from `FileReadWrite.kt`, `Utils.kt`, and `FileTreeWalk.kt`.

I attempted to keep the implementations, documentation, and tests as similar as possible to the existing implementations.

I am happy to add, remove, or move to separate PRs any of the functions of this PR.

### `File` extensions that were not added to `Path`

##### `createTempDir`, `createTempFile`

These functions have no `File` parameters, so can't be overloaded. Equivalents exist as `Files.createTempFile()` and `Files.createTempDirectory()`.

##### `startsWith`, `endsWith`, `normalize`, `resolve`, `resolveSibling`

These exist as member functions on `Path`

##### `relativeTo`, `relativeToOrNull`, `relativeToOrSelf`, `toRelativeString`, `toRelativeStringOrNull`

This functionality exists as the `Path.relativize` member function, which is equivalent to `relativeTo`, but with the receiver and parameter flipped. `foo.relativeTo(bar)` is equivalent to `bar.relativize(foo)`. We could potentially add a `relativizeOrNull` extension to make that pattern simpler.

##### `isRooted`

`Path` has a `root` method, so `isRooted` is equivalent to `root != null`

### New extensions

All of the simple boolean attribute checks from `java.nio.Files` were added as extensions on `Path`. These extensions are used commonly enough that it seems worth supporting them. This functionality for `File` is implemented as member methods.

The following `Path` extensions were added:

- `exists`
- `isDirectory`
- `isExecutable`
- `isFile`
- `isHidden`
- `isReadable`
- `isSameFile`
- `isSymbolicLink`
- `isWritable`

Some of these extensions take options that are forwarded to their `Files` method, so all of the extensions were implemented as functions rather than properties for consistency.

Additionally, `Path.listFiles` was added to match the `File.listFiles` method. One motivation for its addition was that it's used several times in the implementation of other file extensions. The way to list directory contents with `java.nio` is via `Files.newDirectoryStream()`, which returns an iterable object that must be closed to avoid leaking resources. It's difficult to use correctly with functions like `map` and `filter`, so this extension was added as a simpler, less error-prone alternative.

### Other changes

I added overloads of several of the read-write that take `OpenOptions` to expose the greater control that `java.nio` introduces. For example, you can use `printWriter(APPEND)` to create a `PrintWriter` that doesn't delete the contents of an existing file.

All the new extensions throw exceptions (such as `NoSuchFileException`) from `java.nio` rather than the copies from `kotlin.io`. The `kotlin.io` copies take `File` objects as parameters, and so aren't compatible with `Path`s.

### Address review comments

- Move varargs parameters to the last position
- Remove PathTreeWalk

#KT-19192
2020-10-28 07:35:54 +03:00
Yan Zhulanow 008da87160 Minor: Update Android Extensions deprecation message in relevant test 2020-10-28 00:43:20 +09:00
Yan Zhulanow 9faf91f55d Fix Parcelize settings serialization (KT-42958) 2020-10-28 00:43:20 +09:00
Yaroslav Chernyshev 3386b93009 [Gradle, Cocoapods] Added useLibraries() to allow static library pods
#KT-42531 fixed
2020-10-27 17:57:53 +03:00
Mikhael Bogdanov 21521aa397 Deprecate protected constructors call from public inline function
#KT-21177
2020-10-27 14:51:08 +01:00
Dmitry Gridin a72cdeabb4 fix testData
^KT-40861
2020-10-27 18:58:48 +07:00
Ilya Goncharov e6edb62911 [Gradle, JS] Fix for IDEA import with dukat binaries
^KT-42954 fixed
2020-10-27 14:21:34 +03:00
Mikhail Zarechenskiy bb2e9e2d56 Extract new method from the publicly used interface for compatibility
Note that we can't just use ``@JvmDefault` annotation as the main change
 is in the `core` module which targets Java 6

 #KT-42259 Fixed
2020-10-27 14:14:39 +03:00
Alexander Dudinsky 0e7e657657 Migrate MultiModuleLineMarkerTest to the new CodeMetaInfo test infrastructure 2020-10-27 12:31:45 +03:00
Alexander Dudinsky 94bf38a7b5 Added support for various platforms for CodeMetaInfo tests. ^KT-41996
The tests need to be able to parse and render CodeMetaInfo for different
 platforms. For example, we must draw a run gutter a MAC application on
 OSX, but for a Win application, the gutter should not be drawn at the
 same time. This commit allows to do such checks. In order to indicate
 on which platform it should be rendered, it is necessary to specify the
 platform for a specific CodeMetaInfo in the test data in the format
 {OSX,Unix,Win}, if the block with platforms is missing, this means
 that it should be rendered on each platform.

<!LINE_MARKER{OSX}(...)!> - should only be on OSX
<!LINE_MARKER(...)!> - should be on any platform
2020-10-27 12:31:18 +03:00
Alexander Dudinsky 84d24e5b76 Migrate MultiplatformAnalysisTest to new test runner 2020-10-27 12:23:50 +03:00
Alexander Dudinsky ac98bc9853 New highlighting/line markers/diagnostics test infrastructure
The current test framework has a number of shortcomings, such as
different markups for different kinds, those formats can not be
mixed in one test file, lacks composability, re-use of it is complicated
This commit contains the first version of the new test runner
to which tests will be migrated in the future.
2020-10-27 12:23:50 +03:00
Yan Zhulanow 994cb6f28e Update deprecation message for the Android Extensions plugin 2020-10-27 18:08:39 +09:00
Toshiaki Kameyama 5e9333773c Remove explicit type arguments: don't report when type argument has annotations
#KT-40985 Fixed
2020-10-27 15:44:44 +07:00
nataliya.valtman e1a380ec95 KT-34862 use relative path for incremental build cache 2020-10-27 10:45:06 +03:00
Mikhail Glukhikh 09043fb98d [FIR] JvmMappedScope: add mutable methods or not depending on a class 2020-10-27 10:27:06 +03:00
Mikhail Glukhikh 5c3269f489 [FIR] JvmMappedScope: don't add Java methods if Kotlin ones are here 2020-10-27 10:26:55 +03:00