Skip to content

Commit

Permalink
Merge pull request #12070 from BarkingBad/scaladoc/java-lookups
Browse files Browse the repository at this point in the history
Fix Java lookups
  • Loading branch information
abgruszecki authored Apr 16, 2021
2 parents 090b1b1 + a2e2a3d commit 1f503e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
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

0 comments on commit 1f503e7

Please sign in to comment.