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

Singleton type subtyping fix #240

Merged
merged 7 commits into from
Nov 19, 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,5 @@ project/plugins/project/
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*


.vscode
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ abstract class DbInspector(protected val shift: Int) extends InspectorBase {
val allbases = tpeBases(i).filter(!_._takesTypeArgs)
val targetRef = {
val tpef = i.dealias.simplified._resultType
inspector.makeNameReferenceFromSymbol(tpef.typeSymbol)
inspector.makeNameReferenceFromType(tpef)
}
allbases.map(b => (targetRef, inspector.makeNameReferenceFromSymbol(b.typeSymbol)))
allbases.map(b => (targetRef, inspector.makeNameReferenceFromType(b)))
}

baseclassReferences
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ object Inspect {
println(s"${SubtypeDBs(res.basesdb, res.idb)} => ${strDbs.size} bytes, ${string2hex(strDbs)}")
println(strDbs)
}

'{ LightTypeTag.parse(${Expr(hashCodeRef)}, ${Expr(strRef)}, ${Expr(strDbs)}, ${Expr(LightTypeTag.currentBinaryFormatVersion)}) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,16 @@ abstract class Inspector(protected val shift: Int) extends InspectorBase {
orTypeTags ++ otherTypeTags
}

private def makeNameReferenceFromType(t: TypeRepr): NameReference = {
private[dottyreflection] def makeNameReferenceFromType(t: TypeRepr): NameReference = {
t match {
case ref: TypeRef =>
makeNameReferenceFromSymbol(ref.typeSymbol)
case term: TermRef =>
makeNameReferenceFromSymbol(term.termSymbol)
case t: ParamRef =>
NameReference(tpeName = t.binder.asInstanceOf[{ def paramNames: List[Object] }].paramNames(t.paramNum).toString)
case ref =>
makeNameReferenceFromSymbol(ref.typeSymbol)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ object ID {
type Identity[+A] = A
}

trait Clock
object ClockLive extends Clock

trait ZY extends Assertions {
type T
type U = T
Expand Down Expand Up @@ -55,7 +58,7 @@ final case class testTag2[T: Tag]() {

trait T2[A, B, C[_[_], _], D[_], E]

abstract class SharedTagTest extends AnyWordSpec with XY[String] {
abstract class SharedTagTest extends AnyWordSpec with XY[String] with TagAssertions {

type Swap[A, B] = Either[B, A]
type SwapF2[F[_, _], A, B] = F[B, A]
Expand Down Expand Up @@ -198,6 +201,9 @@ abstract class SharedTagTest extends AnyWordSpec with XY[String] {
assert(TagTK[Id1].tag != TagK[Id].tag)
}

"handle singleton types" in {
assertChild(Tag[ClockLive.type].tag, Tag[Clock].tag)
}
}

}