Commit Graph

41 Commits

Author SHA1 Message Date
Mikhail Zarechenskiy 32531b3afc Allow to have all parameters with default values in actual annotation
#KT-19656 In Progress
2017-09-25 16:19:05 +03:00
Alexander Udalov 2d9f07deec Minor, add test for obsolete issue on "actual missing" error
#KT-20142
2017-09-25 11:58:20 +03:00
Alexander Udalov 2281ac842a Prohibit super constructor call for 'expect' class
#KT-15490 Fixed
2017-09-25 11:58:20 +03:00
Alexander Udalov 8ae7343557 Prohibit 'expect' lateinit member properties
#KT-20319 Fixed
2017-09-25 11:58:20 +03:00
Alexander Udalov 1f992ed845 Improve error on 'expect' delegated property
#KT-15054 Fixed
 #KT-15055 Fixed
2017-09-25 11:58:20 +03:00
Mikhail Glukhikh 9b0f15137f Expect/actual: introduce DEPRECATED_MODIFIER instead of ..._FOR_TARGET 2017-09-18 16:19:41 +03:00
Mikhail Glukhikh fcc84d00c3 Migration: make header/impl/expect/actual contradictory to each other 2017-09-15 18:30:25 +03:00
Stanislav Erokhin 2b186909d4 Migrate diagnostic names for header/impl 2017-09-15 18:29:29 +03:00
Mikhail Glukhikh 5d25106267 Migration: deprecation tests for header/impl 2017-09-15 18:28:14 +03:00
Mikhail Glukhikh dd8bed8b46 Migration: expect/actual in diagnostic tests 2017-09-15 18:28:07 +03:00
Alexander Udalov ac1c7d9a6a Drop Incompatible.NoImpl, fix no "missing impl" on nested class
Header/impl declarations are now considered fully compatible even in the
case when the impl declaration has no "impl" modifier. The error about
no "impl" is now reported separately and only on the impl declaration,
never on the header declaration

 #KT-20087 Fixed
2017-09-12 14:41:11 +03:00
Dmitry Petrov d951e957ea Support lateinit modifier on top-level properties
Allow lateinit modifier on top-level properties.
Modifiers 'lateinit' and 'header' are incompatible.
2017-08-31 11:28:08 +03:00
Alexander Udalov b87abc9f0f Relax rules related to noinline/crossinline/reified in header/impl functions
See the comments in KT-18752 for the current resolution

 #KT-15377 Fixed
 #KT-18752 Fixed
2017-08-25 15:40:38 +03:00
Alexander Udalov d1cff41ce0 Treat nested class of header class as header
Note that the quick fix to implement header class works incorrectly when
that class has nested classes at the moment; this should be fixed
separately

 #KT-15494 Fixed
 #KT-18573 Fixed
2017-08-25 15:40:37 +03:00
Alexander Udalov 3a2d93f73e Do not report "header with no impl" on incorrect header
Descriptor for a 'header' member in a non-'header' class now has
isHeader = false

 #KT-18442 Fixed
2017-08-25 15:40:36 +03:00
Alexander Udalov 3bc8ca5913 Report "declaration should be marked with impl" when possible
Also support a quick fix to add 'impl' modifier (KT-18454), although it
doesn't work yet on classes because there's no error on them in the IDE

 #KT-18087 Fixed
 #KT-18452 Fixed
 #KT-18454
2017-08-25 15:35:05 +03:00
Alexander Udalov 9ecd04f628 Improve diagnostics on header/impl classes when scopes don't match
Try to report most of the errors on the actual members of the impl
class. In many cases, there's a 1:1 mapping of header to impl class
members, so the error "some members are not implemented" on the class
declaration itself is redundant. Exceptions include functions/properties
from supertypes (there may be no other place to report a signature
mismatch error in this case), functions/properties not marked with
'impl' (the checker is only run for declarations explicitly marked with
'impl') and default constructors (the checker is not run for them)

 #KT-18447 Fixed
2017-08-25 15:35:05 +03:00
Alexander Udalov 74ba0080b1 Improve header/impl mismatch diagnostic messages
Try to report most mismatch errors on the 'impl' declaration. Only
report a mismatch error on the 'header' declaration if no error would be
otherwise reported on any 'impl' declaration in the compilation unit.
Also render declaration kind in the message

 #KT-18447 In Progress
2017-08-25 15:35:05 +03:00
Alexander Udalov ccd3781403 Disallow using named arguments for members of header classes
#KT-17083 Fixed
2017-03-27 20:10:18 +03:00
Alexander Udalov b971ac9312 Allow impl declarations to have flexible types
Types of the corresponding parameters (or type parameter bounds, types
in supertypes, etc) are now compatible not only if they're equal, but
also if values of those types are mutually assignable (if "a" is subtype
of "b" and "b" is subtype of "a")

 #KT-17005 Fixed
2017-03-27 20:10:17 +03:00
Alexander Udalov 116380a826 Allow impl declarations to have non-stable parameter names
#KT-17027 Fixed
2017-03-27 19:50:25 +03:00
Alexander Udalov e4ae7ca4ce Use type substitution when matching header-impl members
Previously, type substitution, which is critical for matching generic
header/impl members with each other, was only performed when
checkImplementationHasHeaderDeclaration was called for impl class
(areCompatibleClassifiers creates the correct substitutor). This was
done in areCompatibleClassifiers: a substitutor which maps type
parameters of the header class to type parameters of the impl class was
created.

Now we create the same substitutor when
checkImplementationHasHeaderDeclaration is called for an impl member of
an impl class as well, manually.

 #KT-15230 Fixed
2017-03-22 20:19:14 +03:00
Alexander Udalov 21f79cd737 Fix test data 2016-12-26 17:11:32 +03:00
Alexander Udalov e4e50017d0 Render header/impl on properties in tests and diagnostic messages
As a side effect, header/impl and some other modifiers on functions are now
rendered in a different, more natural, order
2016-12-26 17:06:24 +03:00
Alexander Udalov 5556c59fc9 Render platform name in multiplatform diagnostic tests
Prepend the platform name to the diagnostic in a common module, which is
reported when sources of that common module are analyzed as a part of the
platform source set: "<!JVM:...!> ... <!>". Fix some existing tests, mostly by
adding "impl" to implementations
2016-12-26 17:06:15 +03:00
Alexander Udalov e4d85ac527 Support header annotation classes in common modules
Properties are only allowed to be declared in a header class' primary
constructor if that class is an annotation class. However, we did not correctly
determine that such properties are also "header". The test passed because the
diagnostic was lost
2016-12-26 17:01:24 +03:00
Alexander Udalov 63cc5d872d Minor, fix test data 2016-12-19 12:15:59 +03:00
Alexander Udalov da6c3c3231 Support header/impl enum classes
- prohibit constructors for header enum classes
- prohibit bodies for header enum entries
- all entries from header enum must be present in impl enum
2016-12-19 11:54:40 +03:00
Alexander Udalov 56d4ff0cad Support nested header/impl classes 2016-12-19 11:54:38 +03:00
Alexander Udalov a57455ce62 Relax requirements on function modifiers in multiplatform projects
Allow to implement header functions with external/tailrec/inline/infix/operator
functions
2016-12-19 11:53:39 +03:00
Alexander Udalov 0634782e47 Allow open impl class for final header class 2016-12-19 11:50:49 +03:00
Alexander Udalov 546e47dc44 Allow fake overrides and delegates to be impl for header declarations
Also fix a bug with matching supertype lists of header/impl classes
2016-12-19 11:50:40 +03:00
Alexander Udalov 7deaf8cc41 Allow impl class to be data class, allow impl constructor properties 2016-12-19 11:50:30 +03:00
Alexander Udalov 3e97c9fff9 Rename platform->header, definition->impl in test data 2016-12-19 11:50:21 +03:00
Stanislav Erokhin 59efedf610 Rename platform to header. 2016-12-13 18:00:00 +03:00
Alexander Udalov 8d3f6f1ce7 Check platform<->impl declaration compatibility
For each platform declaration, there must be at least one impl declaration in
the module with the compatible signature; similarly, for each impl declaration,
there must be at least one platform declaration with the compatible signature.

Note that currently the presence of the 'impl' modifier is not checked yet.

Also, the sad fact is that if you have platform and impl declarations which are
not compatible, you get two errors: on the platform delcaration and on the impl
declaration. This needs to be addressed as well
2016-11-25 20:50:26 +03:00
Alexander Udalov ad59d5a1c8 Define applicability for platform/impl modifiers 2016-11-25 20:50:24 +03:00
Alexander Udalov a8bd82e863 Support only simple declarations for 'impl' type aliases
E.g. 'impl typealias Foo<A, B> = Bar<A, B>' is allowed; everything else
(variance, changing order of parameters, etc.) is pretty much disallowed.

This is done for simplicity: otherwise matching the platform/impl class scopes
would be not so straightforward
2016-11-25 20:50:20 +03:00
Alexander Udalov 751949db69 Support platform/impl modifiers for classes
Do not report "unused parameter" for parameters of platform declarations. Do
not allow platform class constructors to have val/var parameters or have an
explicit delegation call to another constructor. Do not allow platform classes
to have 'init' blocks.

Also suppress the "supertype not initialized" error for platform classes: the
supertype should be initialized in the impl class
2016-11-25 20:50:19 +03:00
Alexander Udalov ce9691cd2b Support platform/impl modifiers for properties
Do not allow platform properties to have backing fields, initializers, be
delegated, lateinit or const, or have accessors with bodies
2016-11-25 20:50:18 +03:00
Alexander Udalov af1264a46d Support platform/impl modifiers for functions
Also add a new capability for ModuleDescriptor, which is used to obtain the
platform in the multi-platform scenario in tests.

Suppress the following errors for platform functions: "function has no body"
and "nothing to inline". Also do not report redeclaration between platform and
non-platform functions because this is the case when the common +
platform-specific code are analyzed together.

Note that some diagnostics reported in tests are not yet implemented in this
commit, they appear in subsequent commits
2016-11-25 20:50:17 +03:00