Treat expect classes as not having implicit default constructors

#KT-15522 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2017-09-27 15:56:41 +03:00
parent 887e71a7c1
commit f3344ec2b2
29 changed files with 145 additions and 50 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ enum class WrongResolutionToClassifier(val message: (Name) -> String) {
TYPE_PARAMETER_AS_FUNCTION({ "Type parameter $it cannot be called as function" }),
INTERFACE_AS_VALUE({ "Interface $it does not have companion object" }),
INTERFACE_AS_FUNCTION({ "Interface $it does not have constructors" }),
EXPECT_CLASS_AS_FUNCTION({ "Expected class $it does not have default constructor" }),
CLASS_AS_VALUE({ "Class $it does not have companion object" }),
INNER_CLASS_CONSTRUCTOR_NO_RECEIVER({ "Constructor of inner class $it can be called only with receiver of containing class" }),
OBJECT_AS_FUNCTION({ "Function 'invoke()' is not found in object $it" })
@@ -105,6 +106,7 @@ private fun ErrorCandidateContext.getWrongResolutionToClassifier(classifier: Cla
ClassKind.CLASS -> when {
asFunction && explicitReceiver is QualifierReceiver? && classifier.isInner -> INNER_CLASS_CONSTRUCTOR_NO_RECEIVER
asFunction && classifier.isExpect -> EXPECT_CLASS_AS_FUNCTION
!asFunction -> CLASS_AS_VALUE
else -> null
}