Skip to content

Commit 979921a

Browse files
committed
Fix: Decline extension functions whose receiver has a supertype off the compile classpath (#66)
1 parent 4449d37 commit 979921a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • python-multiplatform-gradle-plugin/src/main/kotlin/python/multiplatform/gradle/artifact

‎python-multiplatform-gradle-plugin/src/main/kotlin/python/multiplatform/gradle/artifact/ArtifactScanner.kt‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,17 @@ internal object ArtifactScanner {
19111911
if (function.hasUnsubstitutableTypeParameters) {
19121912
return declined("a bounded or reified type parameter: kotlin.Any? cannot stand for it")
19131913
}
1914+
// Issue #66: `receiver.alias(...)` resolves against the receiver's member scope, which needs
1915+
// every supertype of it -- the rule an extension property's receiver already gets.
1916+
if (function.isExtension) {
1917+
val receiverName = (function.receiverType?.classifier as? KmClassifier.Class)?.name
1918+
if (receiverName != null) {
1919+
val missing = classpath.unreachableSupertypeOf(receiverName.replace('.', '$'))
1920+
if (missing != null) {
1921+
return declined(unreachableReceiverReason(missing, receiverName.replace('/', '.')))
1922+
}
1923+
}
1924+
}
19141925

19151926
// Read before `resolveKotlinType` is asked anything, because for a function-typed parameter
19161927
// it is the one that would answer -- and would answer "no". See [functionSlotOrNull].

0 commit comments

Comments
 (0)