Commit Graph

816 Commits

Author SHA1 Message Date
Mads Ager 3b2843fe7a Introduce local variable type checker.
CheckLocalVariablesTableTests will now check the validity of
the locals table against types of locals computed based on the
bytecode.

These checks and the new destructuringInFor test act as a
regression test for the changes in
https://github.com/JetBrains/kotlin/pull/2613

These checks also caught a similar issue for destructuring
lambda parameters, where the local is introduced before the
value has been written to the local slot. This change also
fixes that.

Finally, this change fixes the asmLike tests to correctly
look up the name of parameters in the locals table.
2019-10-07 15:06:44 +02:00
Jiaxiang Chen 2c78f1fe85 debug information test: instantiate a single thread for all tests under same test class 2019-10-05 10:41:11 +02:00
Jiaxiang Chen 0a2812f83b Add a JVM backend debug information test, this commit is for verifying
line numbers for stepping.

Running JVM instance and read stepping events from it to verify with the
test data.
2019-10-05 10:41:11 +02:00
Mikhail Glukhikh e8cf0b5d4f Add test for kotlin.streams function usage in Kotlin code
NB: does not pass in javac mode due to lack of JvmPackageName support
2019-10-03 11:16:24 +03:00
Dmitry Petrov 107ab06042 Minor: make diagnostic tests usable with IDEA & JPS 2019-10-02 17:14:48 +04:00
Dmitry Petrov a633a33627 KT-14513 Don't generate delegated property metadata when unused
If the delegated property operators involved are inline, and delegated
property metadata parameter is not used (which is often the case, e.g.,
'lazy'), we can skip those properties in metadata generation.

NOT implemented: special case when only 'kProperty.name' is used by the
corresponding delegated property operators.

Also a sneak fix for KT-34060.
2019-10-02 17:14:48 +04:00
Denis Zharkov 67410f7a57 Parametrize behavior of DescriptorEquivalenceForOverrides::areCallableDescriptorsEquivalent
The changes introduced 471134d31e are only needed
for the case of HMPP project while for other cases it might break the behavior
a bit like in KT-34027

See org.jetbrains.kotlin.resolve.calls.results.OverloadingConflictResolver#filterOutEquivalentCalls

Before 471134d we were comparing
"fun foo(x: String)" with "[substituted] fun foo(x: String)"
and areCallableDescriptorsEquivalent returned false for such case.
Thus, both overrides were left in the resulting set.

After 471134d, those two descriptors
becamed considered as equal thus having a possibility to remove any of them.

The problem is that "areCallableDescriptorsEquivalent" has kind of
unclear contract. Effectively it checks whether two descriptors match
to the same declaration

But straightforward fixing of this exact call-site (using original descriptors)
doesn't help: behavior might change in a very subtle way (see org.jetbrains.kotlin.spec.checkers.DiagnosticsTestSpecGenerated.NotLinked.Dfa.Pos#test72)

So, the main idea is changing the contract for areCallableDescriptorsEquivalent
only when project is HMPP one.

^KT-34027 In Progress
2019-09-30 20:09:42 +03:00
Nikolay Krasko 057c16bf10 Allow to mute and assert special failure for generated tests 2019-09-30 00:53:03 +03:00
Vyacheslav Gerasimov d54bc3a4bb 193: Fix tests compilation for 193 platform 2019-09-24 18:22:35 +03:00
Dmitry Savvinov bfacc1a3c5 Introduce AbstractResolverForProject
Previously, ResolverForProjectImpl had multiple callbacks in
constructor. Some of those callbacks were used only to overcome module
visibility and provide an ability to inject IDE-specific logic into
compiler (ResolverForProject is in the 'compiler'-module)

This commit introduces abstract class which implements
environment-independent logic (previously, this logic had been stored in
ResolverForProjectImpl) with several abstract met hods (previously,
callbacks). Then, we provide few concrete implementations of
AbstractResolverForProject with clear semantics:

- IdeaResolverForProject: resolver used in IDE, where we have indices,
  oracles, multiple modules, etc.
- ResolverForSingleModuleProject: resolver for project with only one
  module, commonly used for CLI compiler/tests
- one anonymous implementation for MultimoduleTests

This refactoring achieves several things:
- now it is easier to see what kinds of ResolverForProject you might see
  in some particular environment (previously, one had to inspect all
  call-sites of constructor)
- we can easily add IDE-specific logic in IdeaResolverForProject without
  adding noisy callbacks (which most probably wouldn't have any other
  non-trivial implementations)
2019-09-24 17:05:05 +03:00
Ivan Gavrilovic 573e7f2eee Run JDK11 tests for KAPT only if JDK11 is available
Otherwise, just skip running them.
2019-09-23 17:32:37 +09:00
Ivan Gavrilovic 0cdfe89a26 KT-33052: Fix KAPT stub generation for enums on JDK11
When using JDK11, generating stubs for enums is broken.
This commit handles the faulty generation by JDK11 by
fully printing enums in custom implementation of tree
printing.

Test: added JDK11 tests for KAPT stub  generation
2019-09-20 00:04:27 +09:00
Nikolay Krasko 4387862d20 Remap android home directory to allow parallel test execution (KT-33870)
Using same directory for android (user home) leads to exception on Windows
because of file lock:

com.google.gson.JsonSyntaxException: java.io.IOException: The process cannot access the file because another process has locked a portion of the file
at com.google.gson.Gson.fromJson(Gson.java:942)
at com.google.gson.Gson.fromJson(Gson.java:865)
at com.android.tools.analytics.AnalyticsSettings.loadSettingsData(AnalyticsSettings.kt:140)
at com.android.tools.analytics.AnalyticsSettings.initialize(AnalyticsSettings.kt:211)
at org.jetbrains.android.AndroidPlugin.initializeForNonStudio(AndroidPlugin.java:56)
at org.jetbrains.android.AndroidPlugin.initComponent(AndroidPlugin.java:30)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:503)
at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponents(ComponentManagerImpl.java:126)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:411)
at com.intellij.idea.IdeaTestApplication.a(IdeaTestApplication.java:114)
at com.intellij.idea.IdeaTestApplication.getInstance(IdeaTestApplication.java:61)
at com.intellij.idea.IdeaTestApplication.getInstance(IdeaTestApplication.java:54)
at com.intellij.testFramework.LightPlatformTestCase.initApplication(LightPlatformTestCase.java:166)
at com.intellij.testFramework.fixtures.impl.LightIdeaTestFixtureImpl.setUp(LightIdeaTestFixtureImpl.java:41)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.lambda$setUp$27(CodeInsightTestFixtureImpl.java:1142)
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:18)
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:13)
at com.intellij.testFramework.EdtTestUtilKt.runInEdtAndWait(EdtTestUtil.kt:63)
at com.intellij.testFramework.EdtTestUtil$Companion.runInEdtAndWait(EdtTestUtil.kt:18)
at com.intellij.testFramework.EdtTestUtil.runInEdtAndWait(EdtTestUtil.kt)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.setUp(CodeInsightTestFixtureImpl.java:1141)
at com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase.setUp(LightJavaCodeInsightFixtureTestCase.java:96)
at org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase.setUp(KotlinLightCodeInsightFixtureTestCase.kt:66)
at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:388)
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:18)
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:13)
at com.intellij.testFramework.EdtTestUtilKt$runInEdtAndWait$3.run(EdtTestUtil.kt:67)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:433)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.FileDispatcherImpl.read(FileDispatcherImpl.java:61)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:197)
at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:159)
at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65)
at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:109)
at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1295)
at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1333)
at com.google.gson.stream.JsonReader.consumeNonExecutePrefix(JsonReader.java:1576)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:534)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
at com.google.gson.Gson.fromJson(Gson.java:923)
... 41 more

#KT-33870 Fixed
2019-09-18 11:30:02 +03:00
Nikolay Krasko d253cd5032 Ignore external annotations in AbstractResolveByStubTest (KT-33732)
In IDE with have descriptors with additional annotations obtained from
external annotations manager. They are probably only java overrides so
shouldn't be present in stubs, thus must be ignored in this test.

Tests with enums started to fail after upgrading to 192 platform because
of additional NotNull annotation on `getDeclaringClass()` method.

 #KT-33732 Fixed
2019-09-09 14:35:58 +03:00
Natalia Selezneva 961e8c2c74 Refactor the mechanism how script configurations are updated
Introduce file attributes cache, which is only applicable when no dependencies are cached in memory cache
Refactor ScriptDependenciesCache to memory cache that is able to get configuration from cache and checks if it is up to date
Move all public methods to ScriptDependenciesManager
Introduce ScriptClassRootsManager that checks if root change event should be called after script configuration update
2019-09-06 10:52:17 +03:00
Georgy Bronnikov 7ede26e8f4 IrCompileKotlinAgainstInlineKotlin tests 2019-09-06 09:19:57 +03:00
Simon Ogorodnik 312e93859b Add more info to fir bench report & format as table
Properly measure raw fir builder time in fir benchmark
2019-08-30 16:32:48 +03:00
Steven Schäfer a90ac2438d Set correct field visibility in psi2ir 2019-08-28 19:41:11 +02:00
Svyatoslav Kuzmich 6e6ffa12a6 [WASM] Initial infrastructure
- New module ":compiler:backend.wasm"
    - Initial compiler infra (driver, phaser, context)
    - Subset of Wasm AST
    - Skeleton of IR -> Wasm AST
    - Wasm AST -> WAT transformer

- Testing infra

- SpiderMonkey jsshell tool
2019-08-22 15:59:54 +03:00
victor.petukhov 9487d291da Fail spec box tests if they have unexpected behaviour and passed 2019-08-19 18:31:48 +03:00
Georgy Bronnikov b9db4148cc Check whether test is ignored before reporting failure 2019-08-13 19:37:11 +03:00
Alexander Udalov 570d66be46 Support "// !API_VERSION: LATEST" directive in tests
Useful for tests that check behavior which depends on having a recent
API version enabled, and that don't want to depend on a specific fixed
API version (to prevent eventual obsoletion)
2019-08-09 15:47:58 +02:00
Alexander Udalov 13b07e71e8 Set AnalysisFlags.explicitApiVersion in tests with API_VERSION directive
To mimic the case of user passing an explicit "-api-version" flag to
avoid API version being inferred to the version of stdlib in
dependencies by JvmRuntimeVersionsConsistencyChecker
2019-08-09 15:47:09 +02:00
Alexander Udalov 45f93521d9 JVM IR: add IrWriteSignatureTestGenerated 2019-08-05 21:27:20 +02:00
Mikhail Glukhikh a38b4756b5 FIR tree refactoring: move FirElement.session to FirDeclaration
#KT-30275 Fixed
2019-07-30 16:28:16 +03:00
Dmitry Savvinov 2b4d70fcf0 [Resolve] Rewrite how built-ins are created
Under COMPOSITE mode we don't have a globally known way to create
built-ins, instead, we have to create them on per-module basis.

So, in this commit we:

1. Use builtInsProvider: (ModuleInfo) -> KotlinBuiltIns instead of
precomputed builtIns instance, in order to be able to calculate
builtIns on per-module basis

2. Introduce new entity, called BuiltInsCache, which, roughly
speaking, is a map of form ModuleInfo -> KotlinBuiltIns, to prevent
creation of multiple builtInsInstances
NB. Actually, it's of form BuiltInsCacheKey -> KotlinBuiltIns, because
we shouldn't create new builtIns for each module. Also, currently,
each platform has its own BuiltInsCacheKey implementation, because
parameters by which built-ins are created, are a bit different across
different platforms. Ideally, we should eliminate those differences
and they use one concrete implementation as a key.
2019-07-30 12:41:40 +03:00
Dmitry Savvinov b48218e722 [Resolve] Make ResolversForModule less static
As consequence, remove IdePlatformKindTooling.resolverForModule, because
it became more than just field, and it duplicates similar API in
IdePlatformKindResolution anyways
2019-07-30 12:41:40 +03:00
Dmitry Savvinov 43ef0ffa50 [Testing] Support diagnostics filters in MultiModuleIdeResolveTest 2019-07-30 12:41:40 +03:00
Ilmir Usmanov cc06798e2c Implement unit suspend functions tail-call optimisation
Unlike previously, this optimisation works on every callee return type.
Tail-calls inside unit functions can be either
INVOKE...
ARETURN
or
INVOKE
POP
GETSTATIC kotlin/Unit.INSTANCE
ARETURN
The first pattern is already covered. The second one is a bit tricky,
since we cannot just assume than the function is tail-call, we also need
to check whether the callee returned COROUTINE_SUSPENDED marker.
Thus, resulting bytecode of function's 'epilogue' look like
DUP
INVOKESTATIC getCOROUTINE_SUSPENDED
IF_ACMPNE LN
ARETURN
LN:
POP

 #KT-28938 Fixed
2019-07-29 20:34:48 +03:00
Nikolay Krasko 58f294a757 Fix kotlin compiler tests in 192 (KT-32193)
#KT-32193 Fixed
2019-07-26 12:38:40 +03:00
Nikolay Krasko 9e002b3ff8 Fix inability to instantiate UsefulTestCase because of JdomSerializer
Stack Trace
	  at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:184)
	  at com.intellij.configurationStore.XmlSerializer.<clinit>(xmlSerializer.kt:15)
	  at com.intellij.codeInsight.CodeInsightSettings.writeExternal(CodeInsightSettings.java:228)
	  at com.intellij.testFramework.UsefulTestCase.<clinit>(UsefulTestCase.java:104)
	  at com.intellij.testFramework.TestLoggerFactory.log(TestLoggerFactory.java:154)
	  at com.intellij.testFramework.TestLogger.info(TestLogger.java:70)
	  at org.jetbrains.kotlin.scripting.compiler.plugin.definitions.CliScriptDependenciesProvider.calculateRefinedConfiguration(CliScriptDependenciesProvider.kt:45)
	  ...
2019-07-17 23:50:32 +03:00
Mikhail Glukhikh b8c3947827 Measure unresolved function call & qualified access # in FIR bench 2019-07-17 10:45:05 +03:00
Mikhael Bogdanov 496765f41e Support target templates in bytecode tests
Avoid test data duplication
2019-07-16 14:08:27 +02:00
Ilya Chernikov cfab89385f Do not override path calculation in light virtual files in tests:
seems unnecessary anymore and breaks some script testing logic
2019-07-16 12:20:21 +02:00
Steven Schäfer dd20b74030 Split GenerateNotNullAssertionsTests into standard box and bytecode tests 2019-07-08 17:48:33 +02:00
Nikolay Krasko 12bb1a5bd1 Make invalidateOnOOCB explicit in ResolverForProjectImpl and remove usage in tests 2019-07-02 13:45:35 +03:00
Vyacheslav Gerasimov fc68bb46dc Build: Move compiler.xml extensions to cli-common 2019-06-27 17:56:51 +03:00
Nikolay Krasko beb1bc09d4 Update to 192.5118.30 2019-06-25 11:48:59 +03:00
Mikhail Glukhikh d820b6ca52 More accurate messages about types in FirResolveBench 2019-06-19 22:45:14 +03:00
Vyacheslav Gerasimov 54222bd429 Build: compiler tests-common test runtime 2019-06-17 16:30:14 +03:00
Denis Zharkov fdebb38706 Disable slow assertions in type checker everywhere except for tests 2019-06-17 10:29:23 +03:00
Vyacheslav Gerasimov dc2a7fdc13 Build: Fix compiler tests, add missing test runtime dependencies 2019-06-14 00:35:01 +03:00
Vyacheslav Gerasimov 5a39c637c2 Build: Fix intellij dependency leak from ir tree module 2019-06-13 21:03:55 +03:00
Leonid Startsev b78d84c120 Add some tests for kotlinx.serialization plugin:
- declaration checker
- bytecode listings
- JVM IR

Improve @Transient redundant reporting
2019-06-11 19:32:40 +03:00
Alexander Udalov c67517cb2b JVM IR: use fast class reading mode in boxAgainstJava tests
annotationsViaActualTypeAliasFromBinary.kt is ignored because
ExpectActualRemover can't find actual for the expected constructor of
Anno now, because `ExpectedActualResolver.findActualForExpected`
incorrectly filters out actual declarations without any source file, and
Java classes loaded in the fast mode don't have any source files.

This will need to be fixed separately, probably by making
ExpectedActualResolver look for the actual class of an expected class
member first (with source file-based filtering), and then
unconditionally locating the corresponding member there
2019-06-11 15:26:07 +02:00
Alexander Udalov c6d61346dd Avoid compiling Java files twice in boxAgainstJava tests
After b602c08773, this test started to put all .java files to the
dependencies when compiling .kt files, _in addition_ to the already
compiled class files from those Java sources. This is incorrect because
the test should actually check how Kotlin compiles _against_ Java
binaries. The other behavior (compiling against Java sources) is already
supported and used in normal box tests with .java sources.

However, we can't simply filter out all .java files before calling
`super.doMultiFileTest` because many of those contain directives
(WITH_RUNTIME, FULL_JDK, etc.) and we should load them in
`CodegenTestCase.compile`. As a workaround, remove '.java' file
extension to prevent their compilation but still be able to resolve
directives.
2019-06-11 15:26:07 +02:00
Dmitry Savvinov 4e12701145 [Expect/Actual] Introduce ModuleStructureOracle 2019-06-10 13:34:27 +03:00
Mikhail Zarechenskiy b7849da19e [NI] Introduce flag to change constraint system for overload resolution
This commit doesn't change behaviour of any inference algorithm, it
 introduces opportunity to switch constraint system that is used for
 overload resolution and fix problematic cases by changing one enum
 entry.

 Due to fundamental changes, there are cases where a new inference
 algorithm reports overload resolution ambiguity errors (#KT-31670,
 #KT-31758), which is correct from its point of view. However, this is
 a breaking change and to really make it, we should be very confident
 and have enough motivation for it, therefore, we don't change behavior
 now in order to collect more examples (if there are any). And if we
 find a lot of erroneous examples, we'll be able to change the behavior
 quite simply
2019-06-07 18:38:00 +03:00
Mikhail Zarechenskiy 787a8bb9bd Revert "[NI] Disable capturing/approximation type in TypeSubstitutor with enabled NI"
This reverts commit 7c4101e21c.

 #KT-31866 Fixed
 #KT-31868 Fixed
 #EA-125401 Fixed
 #KT-25290 Open
2019-06-07 12:31:38 +03:00
Ilya Chernikov e542c9ea84 Refactor script definitions and resolving/refining infrastructure:
- implement wrappers to wrap old and new API providers and resolvers
- make old API deprecated (with error where possible)
- drop old internal classes related to the old API
- refactor usages accordingly
- fix and add missing features to the scripting API where necessary
2019-06-06 17:21:00 +02:00