Skip to content

Fix Java lookups #12070

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

Merged
merged 1 commit into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scaladoc-testcases/src/tests/lookupInheritedMembers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ package lookupInheritedMembers {
* [[tests.lookupInheritedMembers.pack2.B.x]]
* [[tests.lookupInheritedMembers.pack2.B.y]]
* [[tests.lookupInheritedMembers.pack2.B.MyType]]
*
*/
class LookupInheritedMembers

/**
* This look up is problematic, because is lazyloaded by dotty.
*
* [[java.util.Formatter]]
*/
class JavaInheritedMembers
}

Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ trait MemberLookup {
members.asInstanceOf[Iterator[Symbol]]
}

private def hackIsNotAbsent(using Quotes)(rsym: quotes.reflect.Symbol) = {
private def hackIsNotAbsent(using Quotes)(rsym: quotes.reflect.Symbol) =
import dotty.tools.dotc
given dotc.core.Contexts.Context = quotes.asInstanceOf[scala.quoted.runtime.impl.QuotesImpl].ctx
val sym = rsym.asInstanceOf[dotc.core.Symbols.Symbol]
// note: Predef has .info = NoType for some reason
sym.isCompleted && sym.info.exists
}
val iorc = sym.infoOrCompleter
iorc match
case _: dotc.core.SymDenotations.ModuleCompleter | dotc.core.SymDenotations.NoCompleter | dotc.core.Types.NoType | _: dotc.core.NoLoader => false
case _ => true

private def localLookup(using Quotes)(
sel: MemberLookup.Selector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class LookupTestCases[Q <: Quotes](val q: Quotes) {

"java.util.AbstractCollection" -> cls("java.util.AbstractCollection"),
"java.lang.String" -> cls("java.lang.String"),
"java.util.Formatter" -> cls("java.util.Formatter"),
"java.io.Flushable" -> cls("java.io.Flushable"),
"java.util.List" -> cls("java.util.List"),

"tests.lookupInheritedMembers.pack1.A.x" ->
cls("tests.lookupInheritedMembers.pack1.A").fun("x"),
Expand Down