Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #398: Include inherited members in the PackageRef fallback lookup. #400

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

sjrd
Copy link
Contributor

@sjrd sjrd commented Nov 28, 2023

If we have a package object that extends other classes, we may have to look member selections among inherited members. This is done by getMember instead of getDecl.

To test this, we need a Scala 2 package object with an extends clause. There is no such thing in the standard library, which is our only source of Scala 2 code, unfortunately. So we don't add a test for that.


Locally, given the following dependency in the testSources:

libraryDependencies += "com.softwaremill.sttp.client" % "core_2.13" % "2.0.4",

the following TypeSuite test used to fail before, and now works:

  testWithContext("test") {
    import Signatures.*

    val sttpClientPackage = ctx.findPackage("sttp.client")
    val UriContextName = termName("UriContext")
    val UriInterpolatorClass = ctx.findTopLevelClass("sttp.model.UriInterpolator")
    val UriContextClass = UriInterpolatorClass.findDecl(typeName("UriContext")).asClass
    val StringContextClass = ctx.findTopLevelClass("scala.StringContext")

    val sig = Signature(List(ParamSig.Term(StringContextClass.signatureName)), UriContextClass.signatureName)
    val signedName = SignedName(UriContextName, sig)
    println(signedName)
    val tpRef = TermRef(sttpClientPackage.packageRef, signedName)
    val sym = tpRef.symbol
    println(sym)
    val tpe = tpRef.underlyingOrMethodic
    println(tpe.showBasic)
  }

…back lookup.

If we have a `package object` that extends other classes, we may
have to look member selections among inherited members. This is
done by `getMember` instead of `getDecl`.

To test this, we need a Scala 2 `package object` with an `extends`
clause. There is no such thing in the standard library, which is
our only source of Scala 2 code, unfortunately. So we don't add a
test for that.
@sjrd sjrd requested a review from adpi2 November 28, 2023 09:40
@sjrd sjrd merged commit b8008da into scalacenter:main Nov 28, 2023
4 checks passed
@sjrd sjrd deleted the fix-package-ref-inherited-member-lookup branch November 28, 2023 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants