Skip to content

Commit

Permalink
Added language trait HasImplicitReceiver (#1778)
Browse files Browse the repository at this point in the history
Added language trait `HasImplicit Receiver`

This is needed in preparation for #1777 to better handle access to fields/members of a class when an implicit receiver is used.
  • Loading branch information
oxisto authored Oct 3, 2024
1 parent 5887086 commit b7cfbdf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ interface HasSuperClasses : LanguageTrait {
): Boolean
}

/**
* A language trait, that specifies that this language has support for implicit receiver, e.g., that
* one can omit references to a base such as `this`.
*/
interface HasImplicitReceiver : LanguageTrait {

val receiverName: String
}

/**
* A language trait, that specifies that this language has certain qualifiers. If so, we should
* consider them when parsing the types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ open class CPPLanguage :
HasUnknownType,
HasFunctionStyleCasts,
HasFunctionOverloading,
HasOperatorOverloading {
HasOperatorOverloading,
HasImplicitReceiver {
override val fileExtensions = listOf("cpp", "cc", "cxx", "c++", "hpp", "hh")
override val elaboratedTypeSpecifier = listOf("class", "struct", "union", "enum")
override val unknownTypeString = listOf("auto")
Expand Down Expand Up @@ -317,4 +318,7 @@ open class CPPLanguage :

return Pair(false, listOf())
}

override val receiverName: String
get() = "this"
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ open class JavaLanguage :
HasQualifier,
HasUnknownType,
HasShortCircuitOperators,
HasFunctionOverloading {
HasFunctionOverloading,
HasImplicitReceiver {
override val fileExtensions = listOf("java")
override val namespaceDelimiter = "."
@Transient override val frontend: KClass<out JavaLanguageFrontend> = JavaLanguageFrontend::class
Expand Down Expand Up @@ -116,4 +117,6 @@ open class JavaLanguage :

override val startCharacter = '<'
override val endCharacter = '>'
override val receiverName: String
get() = "this"
}

0 comments on commit b7cfbdf

Please sign in to comment.