Skip to content

Commit

Permalink
Merge pull request #366 from sjrd/redesign-names-2
Browse files Browse the repository at this point in the history
Redesign Names.
  • Loading branch information
sjrd authored Oct 20, 2023
2 parents aa16c42 + fc96252 commit 316490c
Show file tree
Hide file tree
Showing 24 changed files with 602 additions and 558 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ inThisBuild(Def.settings(
Developer("sjrd", "Sébastien Doeraene", "[email protected]", url("https://github.com/sjrd/")),
Developer("bishabosha", "Jamie Thompson", "[email protected]", url("https://github.com/bishabosha")),
),
versionPolicyIntention := Compatibility.BinaryCompatible,
versionPolicyIntention := Compatibility.None,
// Ignore dependencies to internal modules whose version is like `1.2.3+4...` (see https://github.com/scalacenter/sbt-version-policy#how-to-integrate-with-sbt-dynver)
versionPolicyIgnoredInternalDependencyVersions := Some("^\\d+\\.\\d+\\.\\d+\\+\\d+".r)
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object Annotations:
else
tpe.prefix match
case pkg: PackageRef =>
if pkg.fullyQualifiedName == FullyQualifiedName.scalaAnnotationInternalPackage then Some(pkg)
if pkg.fullyQualifiedName == PackageFullName.scalaAnnotationInternalPackage then Some(pkg)
else None
case _ =>
None
Expand Down
10 changes: 5 additions & 5 deletions tasty-query/shared/src/main/scala/tastyquery/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object Contexts {
throw new UnknownClasspathEntry(entry)
}

def findPackageFromRoot(fullyQualifiedName: FullyQualifiedName): PackageSymbol =
def findPackageFromRoot(fullyQualifiedName: PackageFullName): PackageSymbol =
@tailrec
def rec(owner: PackageSymbol, path: List[Name]): PackageSymbol =
path match
Expand Down Expand Up @@ -111,7 +111,7 @@ object Contexts {
end findSymbolFromRoot

def findPackage(fullyQualifiedName: String): PackageSymbol =
findPackageFromRoot(FullyQualifiedName(fullyQualifiedName.split('.').toList.map(termName(_))))
findPackageFromRoot(PackageFullName(fullyQualifiedName.split('.').toList.map(termName(_))))

def findTopLevelClass(fullyQualifiedName: String): ClassSymbol =
val (pkg, nameStr) = splitPackageAndName(fullyQualifiedName)
Expand Down Expand Up @@ -200,11 +200,11 @@ object Contexts {
private def splitPackageAndName(fullyQualifiedName: String): (PackageSymbol, String) =
fullyQualifiedName.split('.').toList match
case name :: Nil => (EmptyPackage, name)
case path => (findPackageFromRoot(FullyQualifiedName(path.init.map(termName(_)))), path.last)
case path => (findPackageFromRoot(PackageFullName(path.init.map(termName(_)))), path.last)

private[tastyquery] def findPackageFromRootOrCreate(fullyQualifiedName: FullyQualifiedName): PackageSymbol =
private[tastyquery] def findPackageFromRootOrCreate(fullyQualifiedName: PackageFullName): PackageSymbol =
fullyQualifiedName.path.foldLeft(RootPackage) { (owner, name) =>
owner.getPackageDeclOrCreate(name.asSimpleName)
owner.getPackageDeclOrCreate(name)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ final class Definitions private[tastyquery] (ctx: Context, rootPackage: PackageS

// Magic symbols that are not found on the classpath, but rather created by hand

private def createSpecialClass(name: TypeName, parents: List[Type], flags: FlagSet): ClassSymbol =
private def createSpecialClass(name: SimpleTypeName, parents: List[Type], flags: FlagSet): ClassSymbol =
val cls = ClassSymbol.create(name, scalaPackage)
cls.withTypeParams(Nil)
cls.withParentsDirect(parents)
Expand Down Expand Up @@ -302,7 +302,7 @@ final class Definitions private[tastyquery] (ctx: Context, rootPackage: PackageS
end createPredefMagicMethods

private def createSpecialPolyClass(
name: TypeName,
name: SimpleTypeName,
paramFlags: FlagSet,
parentConstrs: Type => List[Type]
): ClassSymbol =
Expand Down
9 changes: 6 additions & 3 deletions tasty-query/shared/src/main/scala/tastyquery/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,19 @@ private[tastyquery] object Erasure:
* - subtypes <= supertypes
*
* Since this isn't enough to order to unrelated classes, we use
* lexicographic ordering of the class symbol full name as a tie-breaker.
* This ensure that `A <= B && B <= A` iff `A =:= B`.
* lexicographic ordering of the class symbol's signature name as a
* tie-breaker. This ensure that `A <= B && B <= A` iff `A =:= B`.
*
* Note that dotc uses the class symbol's `fullName`. Our `signatureName` is
* precisely what corresponds to dotc's `fullName`, as a requirement.
*
* @see erasedGlb
*/
private def compareErasedGlb(tp1: ErasedTypeRef, tp2: ErasedTypeRef)(using Context): Int =
def compareClasses(cls1: ClassSymbol, cls2: ClassSymbol): Int =
if cls1.isSubClass(cls2) then -1
else if cls2.isSubClass(cls1) then 1
else cls1.fullName.toString.compareTo(cls2.fullName.toString)
else cls1.signatureName.toString.compareTo(cls2.signatureName.toString)
end compareClasses

(tp1, tp2) match
Expand Down
Loading

0 comments on commit 316490c

Please sign in to comment.