Commit Graph

23 Commits

Author SHA1 Message Date
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